stages: - validate - test variables: DENO_VERSION: "2.6.4" PORT: "8000" # Global template for Deno jobs .deno_template: image: denoland/deno:${DENO_VERSION} before_script: - deno --version # ===== VALIDATION STAGE ===== fmt:check: extends: .deno_template stage: validate script: - deno fmt --check rules: - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' - if: "$CI_COMMIT_BRANCH" lint:check: extends: .deno_template stage: validate script: - deno lint rules: - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' - if: "$CI_COMMIT_BRANCH" type:check: extends: .deno_template stage: validate script: - deno check src/main.ts - deno check src/main.test.ts rules: - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' - if: "$CI_COMMIT_BRANCH" # ===== TEST STAGE ===== integration:test: extends: .deno_template stage: test variables: DEEPL_AUTH_KEY: "${DEEPL_AUTH_KEY}" BEARER_TOKEN: "${BEARER_TOKEN}" PORT: "8000" script: # Start server in background - echo "Starting server in background..." - deno run --allow-net --allow-env src/main.ts & - SERVER_PID=$! - echo "Server started with PID $SERVER_PID" # Wait for server to be ready (poll health endpoint) - echo "Waiting for server to be ready..." - | deno eval " for (let i = 1; i <= 30; i++) { try { await fetch('http://localhost:8000/health'); console.log('Server is ready!'); Deno.exit(0); } catch { console.log('Waiting for server... attempt ' + i + '/30'); await new Promise(r => setTimeout(r, 1000)); } } console.log('Server health check failed'); Deno.exit(1); " # Run tests - echo "Running integration tests..." - deno test --allow-net --allow-env src/main.test.ts # Cleanup: Kill the server - echo "Stopping server..." - kill $SERVER_PID || true - wait $SERVER_PID || true rules: - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' - if: "$CI_COMMIT_BRANCH" retry: max: 2 when: - runner_system_failure - stuck_or_timeout_failure