From 024d1980ddd2e3e7affb7911128fc6965f0689b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20K=C4=99pie=C5=84?= Date: Wed, 22 Jun 2022 12:59:33 +0200 Subject: [PATCH 1/2] Move out-of-tree workspace back to $CI_PROJECT_DIR 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. (cherry picked from commit e6aebf10cc9d294edd3694a9e53504548d6046fd) --- .gitlab-ci.yml | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index baa7deff17..6cd65121e2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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 From 3777b4b6c013ab882da09cfbfbea949fe7e0eb03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20K=C4=99pie=C5=84?= Date: Wed, 22 Jun 2022 12:59:33 +0200 Subject: [PATCH 2/2] Clean up convert-trs-to-junit.py invocations - Use absolute paths when invoking the convert-trs-to-junit.py script so that it also works correctly for out-of-tree and tarball-based test jobs. - Quote the variables used in convert-trs-to-junit.py invocations to future-proof the code. - Use "&&" instead of ";" in shell pipelines invoking the convert-trs-to-junit.py script in order to prevent "source" errors from being silently ignored. - Ensure convert-trs-to-junit.py is invoked from the correct directory for out-of-tree and tarball-based unit test jobs by adding appropriate "cd" invocations. - Ensure the convert-trs-to-junit.py invocations are always the last step in each 'after_script', in order to run that script from the correct directory for out-of-tree and tarball-based system test jobs and to ensure that any potential errors in that script do not prevent more important steps in the 'after_script' from being executed. (cherry picked from commit 2cd20ee3702b72456197ffd2f612b506795d8a10) --- .gitlab-ci.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6cd65121e2..e932726513 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -302,10 +302,10 @@ stages: - make -j${TEST_PARALLEL_JOBS:-1} -k check V=1 - if git rev-parse > /dev/null 2>&1; then ( ! grep "^I:.*:file.*not removed$" *.log ); fi after_script: - - (source bin/tests/system/conf.sh; $PYTHON bin/tests/convert-trs-to-junit.py . > junit.xml) - test -n "${OUT_OF_TREE_WORKSPACE}" && cd "${OUT_OF_TREE_WORKSPACE}" - test -d bind-* && cd bind-* - cat bin/tests/system/test-suite.log + - (source bin/tests/system/conf.sh && "${PYTHON}" "${CI_PROJECT_DIR}/bin/tests/convert-trs-to-junit.py" . > "${CI_PROJECT_DIR}/junit.xml") .system_test: &system_test_job <<: *system_test_common @@ -328,7 +328,7 @@ stages: after_script: - cat bin/tests/system/test-suite.log - find bin -name 'tsan.*' -exec python3 util/parse_tsan.py {} \; - - (source bin/tests/system/conf.sh; $PYTHON bin/tests/convert-trs-to-junit.py . > junit.xml) + - (source bin/tests/system/conf.sh && "${PYTHON}" "${CI_PROJECT_DIR}/bin/tests/convert-trs-to-junit.py" . > "${CI_PROJECT_DIR}/junit.xml") artifacts: expire_in: "1 day" untracked: true @@ -344,7 +344,9 @@ stages: 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) + - test -n "${OUT_OF_TREE_WORKSPACE}" && cd "${OUT_OF_TREE_WORKSPACE}" + - test -d bind-* && cd bind-* + - (source bin/tests/system/conf.sh && "${PYTHON}" "${CI_PROJECT_DIR}/bin/tests/convert-trs-to-junit.py" . > "${CI_PROJECT_DIR}/junit.xml") .unit_test: &unit_test_job <<: *unit_test_common @@ -366,7 +368,7 @@ stages: <<: *unit_test_common after_script: - find lib -name 'tsan.*' -exec python3 util/parse_tsan.py {} \; - - (source bin/tests/system/conf.sh; $PYTHON bin/tests/convert-trs-to-junit.py . > junit.xml) + - (source bin/tests/system/conf.sh && "${PYTHON}" "${CI_PROJECT_DIR}/bin/tests/convert-trs-to-junit.py" . > "${CI_PROJECT_DIR}/junit.xml") artifacts: expire_in: "1 day" paths: