Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Commit

Permalink
Use proper syntax for gitlab job dependencies
Browse files Browse the repository at this point in the history
The 'dependencies' actually means the list of artifacts, while the dependencies
are expressed with 'needs' keyword which by default implies artifact list as
well. While at it, also reduce code duplication by using templates.

N. B: we have to be careful with optional jobs because this might lead to yaml
error in case of 'needs' referring to non-existent job.

Signed-off-by: Max <max.suraev@here.com>
  • Loading branch information
Max committed Aug 20, 2020
1 parent 6c61fc6 commit 99cd775
Showing 1 changed file with 45 additions and 51 deletions.
96 changes: 45 additions & 51 deletions ci/gitlab/.gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,24 @@ Docker Setup:

# static scans:

bandit-sast:
license_scanning:
stage: static scans

flawfinder-sast:
bandit-sast:
stage: static scans
needs: []

license_scanning:
flawfinder-sast:
stage: static scans
needs: []

secret_detection:
stage: static scans
needs: []

secrets-sast:
stage: static scans
needs: []


coverage:
Expand All @@ -108,6 +112,7 @@ coverage:
TEST_SOTA_PACKED_CREDENTIALS: "$CI_PROJECT_DIR/credentials.zip"
image: "$UBUNTU_BIONIC_PR_IMAGE"
stage: test
needs: ["Docker Setup"]
except:
- /^20\d\d\.\d\d?-docs$/
- /^docs\//
Expand Down Expand Up @@ -135,6 +140,7 @@ nop11:
TEST_WITH_TESTSUITE: '0'
image: "$UBUNTU_BIONIC_PR_IMAGE"
stage: test
needs: ["Docker Setup"]
except:
- /^20\d\d\.\d\d?-docs$/
- /^docs\//
Expand All @@ -160,6 +166,7 @@ focal-build-static:
TEST_WITH_DOCS: '1'
image: "$UBUNTU_FOCAL_PR_IMAGE"
stage: test
needs: ["Docker Setup"]
except:
- /^20\d\d\.\d\d?-docs$/
- /^docs\//
Expand All @@ -176,16 +183,9 @@ focal-build-static:
- ./scripts/test.sh
- xsltproc -o build-ubuntu-focal/report.xml ./third_party/junit/ctest2junit.xsl build-ubuntu-focal/Testing/**/Test.xml > /dev/null

bionic-pkg:
variables:
GIT_CLONE_PATH: $CI_BUILDS_DIR/aktualizr-bionic-pkg-$CI_JOB_ID
GIT_SUBMODULE_STRATEGY: 'recursive'

TEST_BUILD_DIR: 'build-bionic'
TEST_INSTALL_RELEASE_NAME: '-ubuntu_18.04'
TEST_INSTALL_DESTDIR: "$CI_PROJECT_DIR/build-bionic/pkg"

image: "$UBUNTU_BIONIC_PR_IMAGE"
.u-pkg:
needs: ["Docker Setup"]
stage: test
except:
- /^20\d\d\.\d\d?-docs$/
Expand All @@ -194,43 +194,40 @@ bionic-pkg:
key: "$CI_JOB_NAME"
paths:
- ccache/
artifacts:
paths:
- build-bionic/pkg
script:
- mkdir -p $TEST_INSTALL_DESTDIR
- ./scripts/build_ubuntu.sh

bionic-pkg:
extends: .u-pkg
variables:
GIT_CLONE_PATH: $CI_BUILDS_DIR/aktualizr-bionic-pkg-$CI_JOB_ID
GIT_SUBMODULE_STRATEGY: 'recursive'

TEST_BUILD_DIR: 'build-bionic'
TEST_INSTALL_RELEASE_NAME: '-ubuntu_18.04'
TEST_INSTALL_DESTDIR: "$CI_PROJECT_DIR/build-bionic/pkg"
image: "$UBUNTU_BIONIC_PR_IMAGE"
artifacts:
paths:
- build-bionic/pkg

xenial-pkg:
extends: .u-pkg
variables:
GIT_CLONE_PATH: $CI_BUILDS_DIR/aktualizr-xenial-pkg-$CI_JOB_ID
GIT_SUBMODULE_STRATEGY: 'recursive'

TEST_BUILD_DIR: 'build-xenial'
TEST_INSTALL_RELEASE_NAME: '-ubuntu_16.04'
TEST_INSTALL_DESTDIR: "$CI_PROJECT_DIR/build-xenial/pkg"

image: "$UBUNTU_XENIAL_PR_IMAGE"
stage: test
except:
- /^20\d\d\.\d\d?-docs$/
- /^docs\//
cache:
key: "$CI_JOB_NAME"
paths:
- ccache/
artifacts:
paths:
- build-xenial/pkg
script:
- mkdir -p $TEST_INSTALL_DESTDIR
- ./scripts/build_ubuntu.sh

bionic-pkg-test:
variables:
TEST_INSTALL_DESTDIR: "$CI_PROJECT_DIR/build-bionic/pkg"
needs: ["bionic-pkg"]
image: "$UBUNTU_BIONIC_PR_INSTALLIMAGE"

.pkg-test:
stage: pkg-test
except:
- /^20\d\d\.\d\d?-docs$/
Expand All @@ -239,18 +236,20 @@ bionic-pkg-test:
- ./scripts/test_install_garage_deploy.sh
- ./scripts/test_install_aktualizr.sh

bionic-pkg-test:
extends: .pkg-test
variables:
TEST_INSTALL_DESTDIR: "$CI_PROJECT_DIR/build-bionic/pkg"
needs: ["bionic-pkg"]
image: "$UBUNTU_BIONIC_PR_INSTALLIMAGE"

xenial-pkg-test:
extends: .pkg-test
variables:
TEST_INSTALL_DESTDIR: "$CI_PROJECT_DIR/build-xenial/pkg"
needs: ["xenial-pkg"]
image: "$UBUNTU_XENIAL_PR_INSTALLIMAGE"
stage: pkg-test
except:
- /^20\d\d\.\d\d?-docs$/
- /^docs\//
script:
- ./scripts/test_install_garage_deploy.sh
- ./scripts/test_install_aktualizr.sh


# -- yocto tests

Expand All @@ -272,7 +271,7 @@ OE Docker setup:
OE Checkout:
extends: .bb_checkout
stage: oe-checkout
dependencies: []
needs: []
variables:
GIT_CHECKOUT: 'false'
only:
Expand Down Expand Up @@ -316,10 +315,8 @@ Ptest qemux86_64:
github-release:
image: "$UBUNTU_BIONIC_PR_IMAGE"
stage: deploy
dependencies:
- bionic-pkg
- xenial-pkg
- focal-build-static # for doxygen
# focal-build-static is needed for doxygen
needs: ["bionic-pkg", "xenial-pkg", "focal-build-static"]
script:
# github release
- ./scripts/make_src_archive.sh ./aktualizr_src-$CI_COMMIT_TAG.tar.gz
Expand All @@ -345,8 +342,7 @@ github-release:

pages:
stage: deploy
dependencies:
- coverage
needs: ["coverage"]
script:
- mv build-coverage/coverage/ public/
artifacts:
Expand All @@ -369,7 +365,7 @@ app-docker-image:
- master
variables:
GIT_SUBMODULE_STRATEGY: recursive
dependencies: []
needs: []
allow_failure: true
before_script:
- docker login -u gitlab-ci-token -p "$CI_JOB_TOKEN" "$CI_REGISTRY"
Expand All @@ -390,8 +386,7 @@ trigger-otf-pipeline:
image: "$UBUNTU_BIONIC_PR_IMAGE"
stage: trigger
when: on_success
dependencies:
- github-release
needs: ["github-release"]
script:
- curl -X POST -F "token=$CI_JOB_TOKEN" -F "ref=master" -F "variables[TEST_JOB_ONLY]=true" https://main.gitlab.in.here.com/api/v4/projects/163/trigger/pipeline
only:
Expand Down Expand Up @@ -421,8 +416,7 @@ trigger-osx-build:

build-osx-release:
stage: trigger
dependencies:
- github-release
needs: ["github-release"]
variables:
VERSION: "$CI_COMMIT_TAG"
REVISION: "$CI_COMMIT_SHA"
Expand Down

0 comments on commit 99cd775

Please sign in to comment.