From 62fb5fc6e4cff85988862e514496afb868529364 Mon Sep 17 00:00:00 2001 From: ale <ale@incal.net> Date: Fri, 3 Jan 2025 16:59:30 +0000 Subject: [PATCH] Expose test artifacts to the Gitlab CI interface --- .gitlab-ci.yml | 12 ++++++------ test-driver | 2 +- test/integration-test.yml | 9 ++++++++- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a1441637..533f48d3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -38,11 +38,16 @@ variables: CREATE_ENV_VARS: "" TEST_DIR: "" tags: [ai3] + # Some artifacts may be missing, depending on the specific job. artifacts: - when: on_failure + when: always expire_in: 1 week name: "${CI_JOB_NAME}_${CI_COMMIT_REF_SLUG}_${CI_COMMIT_SHORT_SHA}" + reports: + dotenv: deploy.env + junit: pytest.xml paths: + - ".vmine_group_review*" - "${BUILD_DIR}/ansible.log" - "${BUILD_DIR}/logs" @@ -72,11 +77,6 @@ full_test_review: FLOATUP_ARGS: "--state-file .vmine_group_review_$CI_MERGE_REQUEST_ID --ttl 6h --env deploy.env --dashboard-url https://vm.investici.org" TEST_DIR: "test/full.ref" allow_failure: true - artifacts: - when: always - reports: - dotenv: deploy.env - paths: ['.vmine_group_review*'] environment: name: review/$CI_COMMIT_REF_SLUG url: $VMINE_GROUP_URL diff --git a/test-driver b/test-driver index 863c7176..671d8e6a 100755 --- a/test-driver +++ b/test-driver @@ -131,7 +131,7 @@ do_provision() { do_test() { for playbook in "${float_dir}/test/integration-test.yml" "$@"; do log Running test playbook ${playbook} - ${float_dir}/float run ${playbook} \ + ANSIBLE_STDOUT_CALLBACK=default ANSIBLE_CALLBACKS_ENABLED=default ${float_dir}/float run -vv ${playbook} \ || die "test playbook failed" done } diff --git a/test/integration-test.yml b/test/integration-test.yml index bff929ae..3000cd1e 100644 --- a/test/integration-test.yml +++ b/test/integration-test.yml @@ -22,16 +22,23 @@ - name: Run tests command: "podman run --rm --network host --mount type=bind,source=/tmp/test-config.yml,destination=/test-config.yml --mount type=bind,source=/artifacts,destination=/artifacts {{ test_image }}" + - name: Check existence of pytest.xml + stat: + path: "/artifacts/pytest.xml" + register: pytest_xml_stat + - name: Retrieve test result slurp: src: "/artifacts/pytest.xml" register: pytest_xml + when: "pytest_xml_stat.stat.exists" - name: Store test results locally local_action: module: copy - dest: "pytest.xml" + dest: "{{ lookup('env', 'CI_PROJECT_DIR') | default('..') }}/pytest.xml" content: "{{ pytest_xml['content'] | b64decode }}" + when: "pytest_xml_stat.stat.exists" vars: test_image: "registry.git.autistici.org/ai3/float:integration-test" -- GitLab