]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Move out-of-tree workspace back to $CI_PROJECT_DIR
authorMichał Kępień <michal@isc.org>
Wed, 22 Jun 2022 10:59:33 +0000 (12:59 +0200)
committerMichał Kępień <michal@isc.org>
Wed, 22 Jun 2022 10:59:33 +0000 (12:59 +0200)
Out-of-tree build & test jobs currently defined in GitLab CI use
/tmp/out_of_tree_workspace as the working directory.  This requires
juggling that directory around as it gets passed from the build job to
the test jobs and then again after the test jobs are finished, so that
artifacts can be collected for the purpose of investigating test
failures.  The original intention of doing this was to ensure that
bin/tests/system/run.sh does not rely on being executed from within a
Git working copy (which happens e.g. if the out-of-tree workspace is a
subdirectory of $CI_PROJECT_DIR, i.e. the path into which GitLab
Runner clones the project in each job).

However, even with these complications in place, not all possible
scenarios that should be handled properly by the system test framework
(e.g. invoking a given test one time after another from the same
out-of-tree build directory) are tested in GitLab CI anyway.  Meanwhile,
the requirement for moving the out-of-tree workspace into
$CI_PROJECT_DIR in the 'after_script' for each out-of-tree job makes
these jobs less robust than they could be; for example, if any step in
the 'after_script' returns a non-zero exit code, the job's artifacts
will not include the out-of-tree workspace, hindering troubleshooting.

Simplify job definitions in .gitlab-ci.yml by moving the workspace used
by out-of-tree build & test jobs back to a subdirectory of
$CI_PROJECT_DIR.  Whether the out-of-tree workspace exists within a Git
working copy or not does not matter for Autotools, so this is considered
to be a reasonable trade-off in terms of test coverage.

.gitlab-ci.yml

index 4da8a511e41a59f3abd7e58f3a7f284a45794e6e..71560c670f1204e0e2c13ab1e586c87103366d6b 100644 (file)
@@ -259,18 +259,6 @@ stages:
   - rm -f bind-*.tar.${TARBALL_EXTENSION}
   - cd bind-*
 
-# Move the out-of-tree workspace to CI project dir to save it for use in
-# dependent jobs.
-.save_out_of_tree_workspace: &save_out_of_tree_workspace
-  - test -n "${OUT_OF_TREE_WORKSPACE}" && mv "${OUT_OF_TREE_WORKSPACE}" "${CI_PROJECT_DIR}"
-
-# Move the artifacts from the out-of-tree build job to their original
-# location (the out-of-tree workspace) and then continue work in the
-# out-of-tree workspace.
-.retrieve_out_of_tree_workspace: &retrieve_out_of_tree_workspace
-  - test -n "${OUT_OF_TREE_WORKSPACE}" && mv "$(basename "${OUT_OF_TREE_WORKSPACE}")" "${OUT_OF_TREE_WORKSPACE}"
-  - test -n "${OUT_OF_TREE_WORKSPACE}" && cd "${OUT_OF_TREE_WORKSPACE}"
-
 .build: &build_job
   <<: *default_triggering_rules
   stage: build
@@ -288,8 +276,6 @@ stages:
     - test -z "${CROSS_COMPILATION}" || file lib/dns/gen | grep -F -q "ELF 64-bit LSB"
     - test -z "${CROSS_COMPILATION}" || ( ! git ls-files -z --others --exclude lib/dns/gen | xargs -0 file | grep "ELF 64-bit LSB" )
     - if test -z "${OUT_OF_TREE_WORKSPACE}" && test "$(git status --porcelain | grep -Ev '\?\?' | wc -l)" -gt "0"; then git status --short; exit 1; fi
-  after_script:
-    - *save_out_of_tree_workspace
   needs:
     - job: autoreconf
       artifacts: true
@@ -309,7 +295,7 @@ stages:
   <<: *default_triggering_rules
   stage: system
   before_script:
-    - *retrieve_out_of_tree_workspace
+    - test -n "${OUT_OF_TREE_WORKSPACE}" && cd "${OUT_OF_TREE_WORKSPACE}"
     - *setup_interfaces
   script:
     - cd bin/tests/system
@@ -320,7 +306,6 @@ stages:
     - test -n "${OUT_OF_TREE_WORKSPACE}" && cd "${OUT_OF_TREE_WORKSPACE}"
     - test -d bind-* && cd bind-*
     - cat bin/tests/system/test-suite.log
-    - *save_out_of_tree_workspace
 
 .system_test: &system_test_job
   <<: *system_test_common
@@ -355,12 +340,11 @@ stages:
   <<: *default_triggering_rules
   stage: unit
   before_script:
-    - *retrieve_out_of_tree_workspace
+    - test -n "${OUT_OF_TREE_WORKSPACE}" && cd "${OUT_OF_TREE_WORKSPACE}"
   script:
     - make -j${TEST_PARALLEL_JOBS:-1} -k unit V=1
   after_script:
     - (source bin/tests/system/conf.sh; $PYTHON bin/tests/convert-trs-to-junit.py . > junit.xml)
-    - *save_out_of_tree_workspace
 
 .unit_test: &unit_test_job
   <<: *unit_test_common
@@ -792,13 +776,13 @@ gcc:out-of-tree:
     CONFIGURE: "${CI_PROJECT_DIR}/configure"
     EXTRA_CONFIGURE: "--with-libidn2 --with-lmdb"
     RUN_MAKE_INSTALL: 1
-    OUT_OF_TREE_WORKSPACE: /tmp/out_of_tree_workspace
+    OUT_OF_TREE_WORKSPACE: workspace
   <<: *base_image
   <<: *build_job
 
 system:gcc:out-of-tree:
   variables:
-    OUT_OF_TREE_WORKSPACE: /tmp/out_of_tree_workspace
+    OUT_OF_TREE_WORKSPACE: workspace
   needs:
     - job: gcc:out-of-tree
       artifacts: true
@@ -808,7 +792,7 @@ system:gcc:out-of-tree:
 
 unit:gcc:out-of-tree:
   variables:
-    OUT_OF_TREE_WORKSPACE: /tmp/out_of_tree_workspace
+    OUT_OF_TREE_WORKSPACE: workspace
   needs:
     - job: gcc:out-of-tree
       artifacts: true