stages: - test - deploy variables: NODE_VERSION: "20" APOPHIS_LOG_LEVEL: "info" cache: key: ${CI_COMMIT_REF_SLUG} paths: - node_modules/ - .apophis-cache.json contract_tests: stage: test image: node:${NODE_VERSION} before_script: - npm ci script: # Determine changed routes from merge request diff - | if [ "$CI_MERGE_REQUEST_IID" != "" ]; then CHANGED=$(git diff --name-only $CI_MERGE_REQUEST_DIFF_BASE_SHA $CI_COMMIT_SHA | \ grep -E 'src/routes|src/schemas' | \ sed 's|src/routes||; s|\.ts$||' | \ paste -sd ',' -) export APOPHIS_CHANGED_ROUTES="$CHANGED" fi - npm test artifacts: when: always paths: - .apophis-cache.json - "*.tap" reports: junit: junit.xml rules: - if: $CI_MERGE_REQUEST_IID - if: $CI_COMMIT_BRANCH == "main" # Optional: Clear cache after deployment to main clear_cache: stage: deploy image: node:${NODE_VERSION} script: - rm -f .apophis-cache.json rules: - if: $CI_COMMIT_BRANCH == "main" when: on_success