From dc76efb4a22ef63089a10de8d97145062d73ef7d Mon Sep 17 00:00:00 2001 From: Teake Nutma <t.a.nutma@rug.nl> Date: Thu, 16 Jun 2022 11:32:53 +0200 Subject: [PATCH] Run test_report_diff on MRs as well --- templates/changedfiles/_shared.yml | 2 +- templates/changedfiles/mergerequest.yml | 4 ++-- templates/changedfiles/push.yml | 4 ++-- templates/testreport/diff.yml | 28 +++++++++++++++++++++---- 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/templates/changedfiles/_shared.yml b/templates/changedfiles/_shared.yml index 162e78d..87f6e39 100644 --- a/templates/changedfiles/_shared.yml +++ b/templates/changedfiles/_shared.yml @@ -21,7 +21,7 @@ include: entrypoint: [""] stage: pre script: - - git diff --name-only ${COMPARE_REF}...${CI_COMMIT_SHA} > changed_files.log + - git diff --name-only ${CHANGED_FILES_COMPARE_REF}...${CI_COMMIT_SHA} > changed_files.log artifacts: paths: - changed_files.log diff --git a/templates/changedfiles/mergerequest.yml b/templates/changedfiles/mergerequest.yml index d010d18..1020554 100644 --- a/templates/changedfiles/mergerequest.yml +++ b/templates/changedfiles/mergerequest.yml @@ -3,10 +3,10 @@ include: changed_files_mr: extends: .changed_files + variables: + CHANGED_FILES_COMPARE_REF: origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME rules: - if: $CI_AWE_SKIP_CHANGED_FILES when: never - if: $CI_AWE_RUN_CHANGED_FILES - !reference [.merge_request_jobs, rules] - before_script: - - COMPARE_REF="origin/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}" diff --git a/templates/changedfiles/push.yml b/templates/changedfiles/push.yml index 5e3654d..bea5621 100644 --- a/templates/changedfiles/push.yml +++ b/templates/changedfiles/push.yml @@ -3,10 +3,10 @@ include: changed_files_push: extends: .changed_files + variables: + CHANGED_FILES_COMPARE_REF: $CI_COMMIT_BEFORE_SHA rules: - if: $CI_AWE_SKIP_CHANGED_FILES || $CI_PIPELINE_SOURCE != 'push' when: never - if: $CI_AWE_RUN_CHANGED_FILES - !reference [.primary_ref_jobs, rules] - before_script: - - COMPARE_REF=${CI_COMMIT_BEFORE_SHA} diff --git a/templates/testreport/diff.yml b/templates/testreport/diff.yml index 25961f1..4b72ae0 100644 --- a/templates/testreport/diff.yml +++ b/templates/testreport/diff.yml @@ -1,9 +1,8 @@ -test_report_diff: +.test_report_diff: image: ${CI_AWE_IMAGE_BASE}/ci-tools:${CI_AWE_IMAGE_TAG} variables: TEST_REPORT_JOB: conda_test TEST_REPORT_ARTIFACT_FILE: report.xml - TEST_REPORT_ARTIFACT_URL: "$CI_API_V4_URL/projects/$CI_PROJECT_ID/jobs/artifacts/$CI_COMMIT_REF_NAME/raw/$TEST_REPORT_ARTIFACT_FILE?job=$TEST_REPORT_JOB" stage: test_post rules: - if: $CI_AWE_SKIP_TEST_REPORT_DIFF @@ -12,9 +11,10 @@ test_report_diff: - !reference [.primary_ref_jobs, rules] script: # Download the report of the previous pipeline. - - 'curl --output "$TEST_REPORT_FILE.old" --location --header "JOB-TOKEN: $CI_JOB_TOKEN" "$TEST_REPORT_ARTIFACT_URL"' + - TEST_REPORT_ARTIFACT_URL="$CI_API_V4_URL/projects/$CI_PROJECT_ID/jobs/artifacts/$TEST_REPORT_DIFF_REF/raw/$TEST_REPORT_ARTIFACT_FILE?job=$TEST_REPORT_JOB" + - 'curl --output "$TEST_REPORT_ARTIFACT_FILE.old" --location --header "JOB-TOKEN: $CI_JOB_TOKEN" "$TEST_REPORT_ARTIFACT_URL"' # Compare it to the report of this pipeline. - - report_diff "$TEST_REPORT_FILE.old" "$TEST_REPORT_ARTIFACT_FILE" report_diff.xml + - report_diff "$TEST_REPORT_ARTIFACT_FILE.old" "$TEST_REPORT_ARTIFACT_FILE" report_diff.xml - junitparser verify report_diff.xml artifacts: expire_in: 1 day @@ -23,3 +23,23 @@ test_report_diff: - report_diff.xml reports: junit: report_diff.xml + +test_report_diff_mr: + extends: .test_report_diff + variables: + TEST_REPORT_DIFF_REF: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME + rules: + - if: $CI_AWE_SKIP_TEST_REPORT_DIFF + when: never + - if: $CI_AWE_RUN_TEST_REPORT_DIFF + - !reference [.merge_request_jobs, rules] + +test_report_diff_branch: + extends: .test_report_diff + variables: + TEST_REPORT_DIFF_REF: $CI_COMMIT_REF_NAME + rules: + - if: $CI_AWE_SKIP_TEST_REPORT_DIFF + when: never + - if: $CI_AWE_RUN_TEST_REPORT_DIFF + - !reference [.primary_ref_jobs, rules] -- GitLab