From 5855f0447617b9feed28a34631ff8ca7c6fe574c Mon Sep 17 00:00:00 2001 From: Laurent Bonnans Date: Fri, 5 Jul 2019 17:45:39 +0200 Subject: Reusable meta-updater pipeline suite Squashed: * Oe-selftest GitLab pipeline stage * Use credentials for CI's oe-selftest * Setup kvm trick for docker on CI The gid of the kvm group needs to match the one from the host * Run ci scripts from Docker images * Template out jobs and split .gitlab-ci.yml To be easily reused in other branches and projects Rely on this gitlab feature: https://docs.gitlab.com/ee/ci/yaml/#extends * More flexible checkout script for CI - can work without $CURRENT_PROJECT (checks out everything) - can take a list of pinned versions * Add optional CI jobs ptest and other oe-selftests * Publish bitbaked images as artifacts Signed-off-by: Laurent Bonnans --- scripts/ci/gitlab/checkout.yml | 16 ++++++++++++++++ scripts/ci/gitlab/docker.yml | 37 +++++++++++++++++++++++++++++++++++++ scripts/ci/gitlab/tests.yml | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+) create mode 100644 scripts/ci/gitlab/checkout.yml create mode 100644 scripts/ci/gitlab/docker.yml create mode 100644 scripts/ci/gitlab/tests.yml (limited to 'scripts/ci/gitlab') diff --git a/scripts/ci/gitlab/checkout.yml b/scripts/ci/gitlab/checkout.yml new file mode 100644 index 0000000..28c9177 --- /dev/null +++ b/scripts/ci/gitlab/checkout.yml @@ -0,0 +1,16 @@ +.bb_checkout: + # parameters: + # - MANIFEST + # - REMOTE_SOURCE + # - CURRENT_PROJECT (will be symlinked instead of pulled) + + image: $BITBAKE_CHECKOUT_IMAGE + cache: + paths: + - updater-repo + artifacts: + expire_in: "1 day" + paths: + - updater-repo + script: + - /scripts/checkout-oe.sh diff --git a/scripts/ci/gitlab/docker.yml b/scripts/ci/gitlab/docker.yml new file mode 100644 index 0000000..827bb47 --- /dev/null +++ b/scripts/ci/gitlab/docker.yml @@ -0,0 +1,37 @@ +.bb_docker_local: + # intended to be run on meta-updater's master branch which contains the + # reference docker files + # parameters: + # - BITBAKE_IMAGE + # - BITBAKE_CHECKOUT_IMAGE + # - BITBKAE_IMAGE_MASTER + # - BITBAKE_CHECKOUT_IMAGE_MASTER + image: docker:stable + stage: docker + services: + - docker:dind + before_script: + - docker login -u gitlab-ci-token -p "$CI_JOB_TOKEN" "$CI_REGISTRY" + script: + - docker pull "$BITBAKE_IMAGE" || docker pull "$BITBKAE_IMAGE_MASTER" || true + - docker build --pull --cache-from "$BITBKAE_IMAGE_MASTER" --cache-from "$BITBAKE_IMAGE" -f ./scripts/ci/Dockerfile.bitbake -t "$BITBAKE_IMAGE" ./scripts/ci + - docker push "$BITBAKE_IMAGE" + + - docker pull "$BITBAKE_CHECKOUT_IMAGE" || docker pull "$BITBAKE_CHECKOUT_IMAGE_MASTER" || true + - docker build --pull --cache-from "$BITBAKE_CHECKOUT_IMAGE_MASTER" --cache-from "$BITBAKE_CHECKOUT_IMAGE" -f ./scripts/ci/Dockerfile.checkout -t "$BITBAKE_CHECKOUT_IMAGE" ./scripts/ci + - docker push "$BITBAKE_CHECKOUT_IMAGE" + +.bb_docker_remote: + # intended to be run on other branches and repos: just pulls the last master image + # parameters: + # - BITBAKE_IMAGE + # - BITBAKE_CHECKOUT_IMAGE + image: docker:stable + stage: docker + services: + - docker:dind + before_script: + - docker login -u gitlab-ci-token -p "$CI_JOB_TOKEN" "$CI_REGISTRY" + script: + - docker pull "$BITBAKE_IMAGE" + - docker pull "$BITBAKE_CHECKOUT_IMAGE" diff --git a/scripts/ci/gitlab/tests.yml b/scripts/ci/gitlab/tests.yml new file mode 100644 index 0000000..4bd5844 --- /dev/null +++ b/scripts/ci/gitlab/tests.yml @@ -0,0 +1,36 @@ +.bitbake: + # parameters: + # - TEST_BUILD_DIR + # - TEST_MACHINE (defaults to qemux86-64) + # - BITBAKE_TARGETS + image: $BITBAKE_IMAGE + dependencies: + - Checkout + tags: + - bitbake + script: + - /scripts/configure.sh + - /scripts/build.sh $BITBAKE_TARGETS + +.oe-selftest: + # parameters: + # - TEST_BUILD_DIR + # - TEST_MACHINE (defaults to qemux86-64) + # - OE_SELFTESTS + image: $BITBAKE_IMAGE + dependencies: + - Checkout + tags: + - bitbake + variables: + TEST_AKTUALIZR_CREDENTIALS: $CI_PROJECT_DIR/credentials.zip + before_script: + - aws s3 cp s3://ota-gitlab-ci/hereotaconnect_prod.zip credentials.zip + - sudo /usr/local/bin/setup_kvm.sh + script: + - | + # sg is needed after adding bitbake to the kvm group (see setup_kvm.sh) + sg kvm << EOS + /scripts/configure.sh + /scripts/oe-selftest.sh $OE_SELFTESTS + EOS -- cgit v1.2.3-54-g00ecf