From ef4e2d296458367aa1628dee238bb534087792e4 Mon Sep 17 00:00:00 2001 From: Tom Krizek Date: Wed, 27 Sep 2023 15:26:10 +0200 Subject: [PATCH] ci: move baseline version detection into separate job Multiple CI jobs may utilize a baseline version, i.e. the version that the current code should be tested against when doing comparative testing. To avoid repeating the non-trivial detection of the baseline version, move it into a separate job which creates an environment file that subsequent jobs may require via `needs` option. It is then possible to use the variable(s) defined in the script section of the new job. --- .gitlab-ci.yml | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0cdf0d98f2..a711d0ab9b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -340,6 +340,24 @@ stages: sudo sh -x bin/tests/system/ifconfig.sh up; fi +ci-variables: + stage: precheck + <<: *precheck_job + script: + - export BIND_BASELINE_BRANCH="$(sed -n -E "s|^m4_define\(\[bind_VERSION_MINOR\], ([0-9]+)\)dnl$|\1|p" configure.ac)" + # When testing a .0 release, compare it against the previous development + # release (e.g., 9.19.0 and 9.18.0 should both be compared against 9.17.22). + - if [ "$(sed -n -E "s|^m4_define\(\[bind_VERSION_PATCH\], ([0-9]+)\)dnl$|\1|p" configure.ac)" = "0" ]; then export BIND_BASELINE_BRANCH=$((BIND_BASELINE_BRANCH - 1 - (BIND_BASELINE_BRANCH % 2))); fi + - export BIND_BASELINE_VERSION="$(curl -s "https://gitlab.isc.org/api/v4/projects/1/repository/tags?search=^v9.${BIND_BASELINE_BRANCH}&order_by=version" | jq -r ".[0].name")" + - echo "BIND_BASELINE_BRANCH=$BIND_BASELINE_BRANCH" >> ci_vars.env + - echo "BIND_BASELINE_VERSION=$BIND_BASELINE_VERSION" >> ci_vars.env + needs: + - job: autoreconf + artifacts: true + artifacts: + reports: + dotenv: ci_vars.env + cross-version-config-tests: stage: system <<: *base_image @@ -354,13 +372,8 @@ cross-version-config-tests: - *configure - *setup_interfaces - make -j${BUILD_PARALLEL_JOBS:-1} - - export BIND_BRANCH="$(sed -n -E "s|^m4_define\(\[bind_VERSION_MINOR\], ([0-9]+)\)dnl$|\1|p" configure.ac)" - # When testing a .0 release, compare it against the previous development - # release (e.g., 9.19.0 and 9.18.0 should both be compared against 9.17.22). - - if [ "$(sed -n -E "s|^m4_define\(\[bind_VERSION_PATCH\], ([0-9]+)\)dnl$|\1|p" configure.ac)" = "0" ]; then export BIND_BRANCH=$((BIND_BRANCH - 1 - (BIND_BRANCH % 2))); fi - - BASELINE="$(curl -s "https://gitlab.isc.org/api/v4/projects/1/repository/tags?search=^v9.${BIND_BRANCH}&order_by=version" | jq -r ".[0].name")" - - git clone --branch "${BASELINE}" --depth 1 https://gitlab.isc.org/isc-projects/bind9.git "bind-${BASELINE}" - - cd "bind-${BASELINE}" + - git clone --branch "${BIND_BASELINE_VERSION}" --depth 1 https://gitlab.isc.org/isc-projects/bind9.git "bind-${BIND_BASELINE_VERSION}" + - cd "bind-${BIND_BASELINE_VERSION}" - autoreconf -fi - *configure - make -j${BUILD_PARALLEL_JOBS:-1} @@ -375,6 +388,8 @@ cross-version-config-tests: needs: - job: autoreconf artifacts: true + - job: ci-variables + artifacts: true artifacts: reports: junit: junit.xml