From 008729039d1882aab310f3620a407ea0972a95fe Mon Sep 17 00:00:00 2001 From: Laurent Bonnans Date: Thu, 4 Jul 2019 15:35:44 +0200 Subject: Gitlab pipeline for building core-image-minimal Including these points (initially as separate commits): * Try caching updater-repo in gitlab * Only patch aktualizr recipe in CI if needed * Run under user 4321 in bitbake docker image * Add ability to supply METADIR to envsetup.sh So that we can bypass the "relative path from the script" trick that doesn't work with symlinks. * Checkout the PR base branch * do not run on pushes * run on runners with "gitlab" tag * Print all revisions after repo checkout on CI * Pull CI image from the base branch instead of master * More robust checkout in CI * Only store updater-repo artifacts for one day * Use "stretch" instead of "stable" for Debian release in Dockerfile (in fact, stable just changed to buster) * Move UPDATER_REPO variable out of .gitlab-ci.yml To be defined in the project's settings * Make docker CI stage buildable on shared runners Signed-off-by: Laurent Bonnans --- .gitlab-ci.yml | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .gitlab-ci.yml (limited to '.gitlab-ci.yml') diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..94a614c --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,63 @@ +stages: + - docker + - checkout + - test + +# notes: +# - could be useful https://docs.gitlab.com/ee/ci/yaml/#include + +variables: + # Needs $PR_BASE_BRANCH to be defined as a pipeline variable to work correctly + + CHECKOUT_MASTER_IMAGE: ${CI_REGISTRY_IMAGE}:ci-${PR_BASE_BRANCH}-checkout + CHECKOUT_PR_IMAGE: ${CI_REGISTRY_IMAGE}:ci-${CI_COMMIT_REF_SLUG}-checkout + + BITBAKE_MASTER_IMAGE: ${CI_REGISTRY_IMAGE}:ci-${PR_BASE_BRANCH}-bitbake + BITBAKE_PR_IMAGE: ${CI_REGISTRY_IMAGE}:ci-${CI_COMMIT_REF_SLUG}-bitbake + + +Docker Setup: + image: docker:stable + stage: docker + services: + - docker:dind + except: + - pushes + before_script: + - docker login -u gitlab-ci-token -p "$CI_JOB_TOKEN" "$CI_REGISTRY" + script: + - docker pull "$BITBAKE_PR_IMAGE" || docker pull "$BITBAKE_MASTER_IMAGE" || true + - docker build --pull --cache-from "$BITBAKE_MASTER_IMAGE" --cache-from "$BITBAKE_PR_IMAGE" -f ./scripts/ci/Dockerfile.bitbake -t "$BITBAKE_PR_IMAGE" ./scripts/ci + - docker push "$BITBAKE_PR_IMAGE" + + - docker pull "$CHECKOUT_PR_IMAGE" || docker pull "$CHECKOUT_MASTER_IMAGE" || true + - docker build --pull --cache-from "$CHECKOUT_MASTER_IMAGE" --cache-from "$CHECKOUT_PR_IMAGE" -f ./scripts/ci/Dockerfile.checkout -t "$CHECKOUT_PR_IMAGE" ./scripts/ci + - docker push "$CHECKOUT_PR_IMAGE" + +Checkout: + image: "$CHECKOUT_PR_IMAGE" + stage: checkout + except: + - pushes + cache: + paths: + - updater-repo + artifacts: + expire_in: "1 day" + paths: + - updater-repo + script: + - MANIFEST=$PR_BASE_BRANCH ./scripts/ci/checkout-oe.sh + +Build core-image-minimal: + image: "$BITBAKE_PR_IMAGE" + stage: test + except: + - pushes + dependencies: + - Checkout + tags: + - bitbake + script: + - ./scripts/ci/configure.sh + - ./scripts/ci/build.sh core-image-minimal -- cgit v1.2.3-54-g00ecf