diff options
author | Manikandan Kandasamy <manikandan.kandasamy@here.com> | 2019-01-10 13:46:07 +0100 |
---|---|---|
committer | Kandasamy <manikandan.kandasamy@here.com> | 2019-03-03 23:46:20 +0100 |
commit | a9494095cc75e64542ed1eecac681c99d41492fd (patch) | |
tree | 45cc9d63cfa6b0d0effa193fe3443eb63c28bd54 | |
parent | 29c3476c8286649210ab8d731bfa063c76907f3b (diff) | |
download | meta-updater-a9494095cc75e64542ed1eecac681c99d41492fd.tar.gz |
oe-selftest from GitLab resolves OTA-1937ci/gitlab/ota-1937
Signed-off-by: Manikandan Kandasamy <manikandan.kandasamy@here.com>
-rw-r--r-- | scripts/ci/Dockerfile.bitbake | 4 | ||||
-rw-r--r-- | scripts/ci/gitlab/.gitlab-ci.yml | 48 | ||||
-rwxr-xr-x | scripts/ci/gitlab/bitbaker.sh | 82 |
3 files changed, 134 insertions, 0 deletions
diff --git a/scripts/ci/Dockerfile.bitbake b/scripts/ci/Dockerfile.bitbake index c91f94c..04e8e79 100644 --- a/scripts/ci/Dockerfile.bitbake +++ b/scripts/ci/Dockerfile.bitbake | |||
@@ -20,10 +20,12 @@ RUN apt-get update -q && apt-get install -qy \ | |||
20 | locales \ | 20 | locales \ |
21 | ovmf \ | 21 | ovmf \ |
22 | procps \ | 22 | procps \ |
23 | python-pip \ | ||
23 | python \ | 24 | python \ |
24 | python3 \ | 25 | python3 \ |
25 | python3-pexpect \ | 26 | python3-pexpect \ |
26 | qemu \ | 27 | qemu \ |
28 | repo \ | ||
27 | socat \ | 29 | socat \ |
28 | texinfo \ | 30 | texinfo \ |
29 | unzip \ | 31 | unzip \ |
@@ -40,3 +42,5 @@ RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen | |||
40 | ENV LC_ALL="en_US.UTF-8" | 42 | ENV LC_ALL="en_US.UTF-8" |
41 | ENV LANG="en_US.UTF-8" | 43 | ENV LANG="en_US.UTF-8" |
42 | ENV LANGUAGE="en_US.UTF-8" | 44 | ENV LANGUAGE="en_US.UTF-8" |
45 | |||
46 | RUN pip install awscli \ No newline at end of file | ||
diff --git a/scripts/ci/gitlab/.gitlab-ci.yml b/scripts/ci/gitlab/.gitlab-ci.yml new file mode 100644 index 0000000..93ab062 --- /dev/null +++ b/scripts/ci/gitlab/.gitlab-ci.yml | |||
@@ -0,0 +1,48 @@ | |||
1 | stages: | ||
2 | - setup_docker | ||
3 | - setup_data | ||
4 | - execute | ||
5 | |||
6 | variables: | ||
7 | DEBIAN_BITBAKE_MASTER_IMAGE: ${CI_REGISTRY_IMAGE}:ci-master-DEBIAN_BITBAKE | ||
8 | # The docker images will be specific to the branch we are pushing to | ||
9 | DEBIAN_BITBAKE_CI_IMAGE: ${CI_REGISTRY_IMAGE}:ci-${CI_COMMIT_REF_SLUG}-DEBIAN_BITBAKE | ||
10 | BITBAKE_CACHE: "/data/bitbake-cache" | ||
11 | |||
12 | # Build the Docker image that will be used in subsequent CI/CD stages | ||
13 | setup docker image: | ||
14 | image: docker:latest | ||
15 | stage: setup_docker | ||
16 | services: | ||
17 | - docker:dind | ||
18 | before_script: | ||
19 | - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY | ||
20 | script: | ||
21 | - docker pull "$DEBIAN_BITBAKE_CI_IMAGE" || docker pull "$DEBIAN_BITBAKE_MASTER_IMAGE" || true | ||
22 | - docker build --pull --cache-from "$DEBIAN_BITBAKE_MASTER_IMAGE" --cache-from "$DEBIAN_BITBAKE_CI_IMAGE" -f "${CI_PROJECT_DIR}/scripts/ci/Dockerfile.bitbake" -t "$DEBIAN_BITBAKE_CI_IMAGE" . | ||
23 | - docker push "$DEBIAN_BITBAKE_CI_IMAGE" | ||
24 | |||
25 | setup data: | ||
26 | stage: setup_data | ||
27 | image: "$DEBIAN_BITBAKE_CI_IMAGE" | ||
28 | artifacts: | ||
29 | paths: | ||
30 | - data/ | ||
31 | |||
32 | script: | ||
33 | - mkdir data | ||
34 | - aws s3 ls s3://ota-gitlab-ci/ | ||
35 | - aws s3 cp s3://ota-gitlab-ci/hereotaconnect_prod.zip data/credentials.zip | ||
36 | - chmod +x data/credentials.zip | ||
37 | |||
38 | #Build step to perform bitbake or run oe-selftest based on input params | ||
39 | oe-selftest: | ||
40 | image: "$DEBIAN_BITBAKE_CI_IMAGE" | ||
41 | stage: execute | ||
42 | dependencies: | ||
43 | - setup data | ||
44 | |||
45 | script: | ||
46 | - export DEVICE=${DEVICE:-'qemux86-64'} | ||
47 | - export REPO_BRANCH=${REPO_BRANCH:-'master'} | ||
48 | - scripts/ci/gitlab/bitbaker.sh \ No newline at end of file | ||
diff --git a/scripts/ci/gitlab/bitbaker.sh b/scripts/ci/gitlab/bitbaker.sh new file mode 100755 index 0000000..7e3def1 --- /dev/null +++ b/scripts/ci/gitlab/bitbaker.sh | |||
@@ -0,0 +1,82 @@ | |||
1 | #!/bin/bash -x | ||
2 | |||
3 | echo "Device --> $DEVICE" | ||
4 | echo "Platform --> $PLATFORM" | ||
5 | echo "Test --> $TEST" | ||
6 | echo "REPO_BRANCH --> $REPO_BRANCH" | ||
7 | echo "BITBAKE_CACHE -- $BITBAKE_CACHE" | ||
8 | |||
9 | export DEVICE=${DEVICE:-'qemux86-64'} | ||
10 | export LANG=en_US.UTF-8 | ||
11 | export REPO_BRANCH=${REPO_BRANCH:-'master'} | ||
12 | |||
13 | repo_sync() | ||
14 | { | ||
15 | if [ "${PLATFORM}" == "agl" ] || [ "${PLATFORM}" == "AGL" ] | ||
16 | then | ||
17 | repo init -b eel -m default.xml -u https://gerrit.automotivelinux.org/gerrit/AGL/AGL-repo.git | ||
18 | else | ||
19 | repo init -u https://github.com/advancedtelematic/updater-repo.git | ||
20 | fi | ||
21 | |||
22 | echo "Manifest before update" | ||
23 | REPO_MANIFEST=".repo/manifests/$REPO_BRANCH.xml" | ||
24 | cat $REPO_MANIFEST | ||
25 | |||
26 | METAUPDATER_REV=`git rev-parse HEAD` | ||
27 | |||
28 | sed -i 's/meta-updater" remote="github" revision="'$REPO_BRANCH'"/meta-updater" remote="github" revision="'$METAUPDATER_REV'"/' $REPO_MANIFEST | ||
29 | |||
30 | echo "Manifest after update" | ||
31 | cat $REPO_MANIFEST | ||
32 | |||
33 | repo init -m ${REPO_BRANCH}.xml | ||
34 | repo sync | ||
35 | |||
36 | if [ "${PLATFORM}" == "agl" ] || [ "${PLATFORM}" == "AGL" ] | ||
37 | then | ||
38 | source meta-agl/scripts/aglsetup.sh -m $DEVICE agl-demo agl-appfw-smack agl-sota | ||
39 | else | ||
40 | source meta-updater/scripts/envsetup.sh $DEVICE | ||
41 | fi | ||
42 | } | ||
43 | |||
44 | customize_build() | ||
45 | { | ||
46 | CONF_FILE_PATH="conf/local.conf" | ||
47 | if [ -f "$CONF_FILE_PATH" ] | ||
48 | then | ||
49 | echo "SOTA_PACKED_CREDENTIALS = \"${CI_PROJECT_DIR}/data/credentials.zip\"" >> $CONF_FILE_PATH | ||
50 | echo 'OSTREE_BRANCHNAME = "ostree_qemu_from_gitlab"' >> $CONF_FILE_PATH | ||
51 | echo "DL_DIR = \"${BITBAKE_CACHE}\"" >> $CONF_FILE_PATH | ||
52 | echo "SSTATE_DIR = \"${BITBAKE_CACHE}\"" >> $CONF_FILE_PATH | ||
53 | echo 'IMAGE_INSTALL_append = " vim dropbear"' >> $CONF_FILE_PATH | ||
54 | echo 'SANITY_TESTED_DISTROS = ""' >> conf/local.conf | ||
55 | cat $CONF_FILE_PATH | ||
56 | else | ||
57 | echo "$CONF_FILE_PATH not found." | ||
58 | exit 1 | ||
59 | fi | ||
60 | touch conf/sanity.conf | ||
61 | } | ||
62 | |||
63 | run_command() | ||
64 | { | ||
65 | if [ "${PLATFORM}" == "agl" ] || [ "${PLATFORM}" == "AGL" ]; then | ||
66 | bitbake agl-demo-platform | ||
67 | elif [ "${TEST}" == "oe-selftest" ] || [ "${TEST}" == "OE-SELFTEST" ]; then | ||
68 | oe-selftest -r updater | ||
69 | elif [ "${DEVICE}" == "raspberrypi3" ]; then | ||
70 | bitbake rpi-basic-image | ||
71 | elif [ "${DEVICE}" == "qemux86-64" ]; then | ||
72 | bitbake core-image-minimal | ||
73 | else | ||
74 | echo "Unknown parameter provided" | ||
75 | exit 1 | ||
76 | fi | ||
77 | } | ||
78 | |||
79 | repo_sync | ||
80 | customize_build | ||
81 | run_command | ||
82 | df -h \ No newline at end of file | ||