From c319d8a55f97dc352eca56780a39fa2069109b10 Mon Sep 17 00:00:00 2001 From: Mondo Diaz Date: Fri, 23 Jan 2026 22:31:58 +0000 Subject: [PATCH] Add pre-test stage reset to ensure known environment state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add reset_stage_pre job that runs after deploy_stage but before integration tests - Extract reset script into reusable .reset_stage_template - Ensures stage environment is in known state even if manually modified - Pipeline flow: deploy_stage → reset_stage_pre → integration_test_stage → reset_stage --- .gitlab-ci.yml | 34 ++++++++++++++++++++++------------ CHANGELOG.md | 1 + 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9de58ea..5705dfb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -197,20 +197,10 @@ release: PYTEST_SCRIPT # Integration tests for stage deployment (full suite) -integration_test_stage: - <<: *integration_test_template - needs: [deploy_stage] - variables: - ORCHARD_TEST_URL: $STAGE_URL - rules: - - if: '$CI_COMMIT_BRANCH == "main"' - when: on_success - -# Reset stage environment after integration tests (clean slate for next run) +# Reset stage template - shared by pre and post test reset jobs # Calls the /api/v1/admin/factory-reset endpoint which handles DB and S3 cleanup -reset_stage: +.reset_stage_template: &reset_stage_template stage: deploy - needs: [integration_test_stage] image: deps.global.bsf.tools/docker/python:3.12-slim timeout: 5m retry: 1 # Retry once on transient failures @@ -284,6 +274,26 @@ reset_stage: rules: - if: '$CI_COMMIT_BRANCH == "main"' when: on_success + +# Reset stage BEFORE integration tests (ensure known state) +reset_stage_pre: + <<: *reset_stage_template + needs: [deploy_stage] + +# Integration tests for stage deployment (full suite) +integration_test_stage: + <<: *integration_test_template + needs: [reset_stage_pre] + variables: + ORCHARD_TEST_URL: $STAGE_URL + rules: + - if: '$CI_COMMIT_BRANCH == "main"' + when: on_success + +# Reset stage AFTER integration tests (clean slate for next run) +reset_stage: + <<: *reset_stage_template + needs: [integration_test_stage] allow_failure: true # Don't fail pipeline if reset has issues # Integration tests for feature deployment (full suite) diff --git a/CHANGELOG.md b/CHANGELOG.md index 81a509f..3f08ec9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Changed - Simplified tag pipeline to only run deploy and smoke tests (image already built on main) (#54) +- Added pre-test stage reset to ensure known environment state before integration tests (#54) ### Fixed - Fixed production CI deployment namespace to use correct `orch-namespace` (#54)