From a9494095cc75e64542ed1eecac681c99d41492fd Mon Sep 17 00:00:00 2001 From: Manikandan Kandasamy Date: Thu, 10 Jan 2019 13:46:07 +0100 Subject: oe-selftest from GitLab resolves OTA-1937 Signed-off-by: Manikandan Kandasamy --- scripts/ci/Dockerfile.bitbake | 4 ++ scripts/ci/gitlab/.gitlab-ci.yml | 48 +++++++++++++++++++++++ scripts/ci/gitlab/bitbaker.sh | 82 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 134 insertions(+) create mode 100644 scripts/ci/gitlab/.gitlab-ci.yml create mode 100755 scripts/ci/gitlab/bitbaker.sh 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 \ locales \ ovmf \ procps \ + python-pip \ python \ python3 \ python3-pexpect \ qemu \ + repo \ socat \ texinfo \ unzip \ @@ -40,3 +42,5 @@ RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen ENV LC_ALL="en_US.UTF-8" ENV LANG="en_US.UTF-8" ENV LANGUAGE="en_US.UTF-8" + +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 @@ +stages: + - setup_docker + - setup_data + - execute + +variables: + DEBIAN_BITBAKE_MASTER_IMAGE: ${CI_REGISTRY_IMAGE}:ci-master-DEBIAN_BITBAKE + # The docker images will be specific to the branch we are pushing to + DEBIAN_BITBAKE_CI_IMAGE: ${CI_REGISTRY_IMAGE}:ci-${CI_COMMIT_REF_SLUG}-DEBIAN_BITBAKE + BITBAKE_CACHE: "/data/bitbake-cache" + +# Build the Docker image that will be used in subsequent CI/CD stages +setup docker image: + image: docker:latest + stage: setup_docker + services: + - docker:dind + before_script: + - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY + script: + - docker pull "$DEBIAN_BITBAKE_CI_IMAGE" || docker pull "$DEBIAN_BITBAKE_MASTER_IMAGE" || true + - 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" . + - docker push "$DEBIAN_BITBAKE_CI_IMAGE" + +setup data: + stage: setup_data + image: "$DEBIAN_BITBAKE_CI_IMAGE" + artifacts: + paths: + - data/ + + script: + - mkdir data + - aws s3 ls s3://ota-gitlab-ci/ + - aws s3 cp s3://ota-gitlab-ci/hereotaconnect_prod.zip data/credentials.zip + - chmod +x data/credentials.zip + +#Build step to perform bitbake or run oe-selftest based on input params +oe-selftest: + image: "$DEBIAN_BITBAKE_CI_IMAGE" + stage: execute + dependencies: + - setup data + + script: + - export DEVICE=${DEVICE:-'qemux86-64'} + - export REPO_BRANCH=${REPO_BRANCH:-'master'} + - 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 @@ +#!/bin/bash -x + +echo "Device --> $DEVICE" +echo "Platform --> $PLATFORM" +echo "Test --> $TEST" +echo "REPO_BRANCH --> $REPO_BRANCH" +echo "BITBAKE_CACHE -- $BITBAKE_CACHE" + +export DEVICE=${DEVICE:-'qemux86-64'} +export LANG=en_US.UTF-8 +export REPO_BRANCH=${REPO_BRANCH:-'master'} + +repo_sync() +{ +if [ "${PLATFORM}" == "agl" ] || [ "${PLATFORM}" == "AGL" ] +then + repo init -b eel -m default.xml -u https://gerrit.automotivelinux.org/gerrit/AGL/AGL-repo.git +else + repo init -u https://github.com/advancedtelematic/updater-repo.git +fi + +echo "Manifest before update" +REPO_MANIFEST=".repo/manifests/$REPO_BRANCH.xml" +cat $REPO_MANIFEST + +METAUPDATER_REV=`git rev-parse HEAD` + +sed -i 's/meta-updater" remote="github" revision="'$REPO_BRANCH'"/meta-updater" remote="github" revision="'$METAUPDATER_REV'"/' $REPO_MANIFEST + +echo "Manifest after update" +cat $REPO_MANIFEST + +repo init -m ${REPO_BRANCH}.xml +repo sync + +if [ "${PLATFORM}" == "agl" ] || [ "${PLATFORM}" == "AGL" ] +then + source meta-agl/scripts/aglsetup.sh -m $DEVICE agl-demo agl-appfw-smack agl-sota +else + source meta-updater/scripts/envsetup.sh $DEVICE +fi +} + +customize_build() +{ +CONF_FILE_PATH="conf/local.conf" +if [ -f "$CONF_FILE_PATH" ] +then + echo "SOTA_PACKED_CREDENTIALS = \"${CI_PROJECT_DIR}/data/credentials.zip\"" >> $CONF_FILE_PATH + echo 'OSTREE_BRANCHNAME = "ostree_qemu_from_gitlab"' >> $CONF_FILE_PATH + echo "DL_DIR = \"${BITBAKE_CACHE}\"" >> $CONF_FILE_PATH + echo "SSTATE_DIR = \"${BITBAKE_CACHE}\"" >> $CONF_FILE_PATH + echo 'IMAGE_INSTALL_append = " vim dropbear"' >> $CONF_FILE_PATH + echo 'SANITY_TESTED_DISTROS = ""' >> conf/local.conf + cat $CONF_FILE_PATH +else + echo "$CONF_FILE_PATH not found." + exit 1 +fi +touch conf/sanity.conf +} + +run_command() +{ +if [ "${PLATFORM}" == "agl" ] || [ "${PLATFORM}" == "AGL" ]; then + bitbake agl-demo-platform +elif [ "${TEST}" == "oe-selftest" ] || [ "${TEST}" == "OE-SELFTEST" ]; then + oe-selftest -r updater +elif [ "${DEVICE}" == "raspberrypi3" ]; then + bitbake rpi-basic-image +elif [ "${DEVICE}" == "qemux86-64" ]; then + bitbake core-image-minimal +else + echo "Unknown parameter provided" + exit 1 +fi +} + +repo_sync +customize_build +run_command +df -h \ No newline at end of file -- cgit v1.2.3-54-g00ecf