Speed up CI pipeline: merge lint+test, remove runInBand, drop unused mongo service
- Combine lint and test into a single 'ci' job (eliminates duplicate checkout + npm ci, saving ~60-90s) - Remove --runInBand flag so Jest parallelizes across worker pools - Remove unused mongo:7 service container (tests use MongoMemoryServer) - Fix failure detection: check step outcomes instead of job result, which was always 'success' due to continue-on-error Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
68
.github/workflows/deploy.yml
vendored
68
.github/workflows/deploy.yml
vendored
@ -12,15 +12,17 @@ env:
|
||||
|
||||
jobs:
|
||||
# ============================================================
|
||||
# Lint Job - ESLint static analysis
|
||||
# CI Job - Lint + Test in a single job (one checkout, one npm ci)
|
||||
# ============================================================
|
||||
lint:
|
||||
name: Run Linting
|
||||
ci:
|
||||
name: Lint & Test
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
outputs:
|
||||
status: ${{ steps.lint.outcome }}
|
||||
output: ${{ steps.lint.outputs.lint_output }}
|
||||
lint_status: ${{ steps.lint.outcome }}
|
||||
lint_output: ${{ steps.lint.outputs.lint_output }}
|
||||
test_status: ${{ steps.test.outcome }}
|
||||
test_output: ${{ steps.test.outputs.test_output }}
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
@ -47,54 +49,18 @@ jobs:
|
||||
echo "EOF" >> $GITHUB_OUTPUT
|
||||
exit $EXIT_CODE
|
||||
|
||||
# ============================================================
|
||||
# Test Job - Runs first, blocks everything if tests fail
|
||||
# ============================================================
|
||||
test:
|
||||
name: Run Tests
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
outputs:
|
||||
status: ${{ steps.test.outcome }}
|
||||
output: ${{ steps.test.outputs.test_output }}
|
||||
|
||||
services:
|
||||
mongodb:
|
||||
image: mongo:7
|
||||
ports:
|
||||
- 27018:27017
|
||||
options: >-
|
||||
--health-cmd "mongosh --eval 'db.runCommand(\"ping\").ok'"
|
||||
--health-interval 10s
|
||||
--health-timeout 5s
|
||||
--health-retries 5
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
cache: 'npm'
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Run tests
|
||||
id: test
|
||||
continue-on-error: true
|
||||
run: |
|
||||
set +e
|
||||
OUTPUT=$(npm test -- --runInBand 2>&1)
|
||||
OUTPUT=$(npm test 2>&1)
|
||||
EXIT_CODE=$?
|
||||
echo "test_output<<EOF" >> $GITHUB_OUTPUT
|
||||
echo "$OUTPUT" >> $GITHUB_OUTPUT
|
||||
echo "EOF" >> $GITHUB_OUTPUT
|
||||
exit $EXIT_CODE
|
||||
env:
|
||||
MONGO_URI: mongodb://localhost:27018
|
||||
JWT_SECRET: test-jwt-secret-for-ci
|
||||
NODE_ENV: test
|
||||
|
||||
@ -104,16 +70,16 @@ jobs:
|
||||
notify:
|
||||
name: Send Webhook Notification
|
||||
runs-on: ubuntu-latest
|
||||
needs: [lint, test]
|
||||
needs: [ci]
|
||||
if: always()
|
||||
|
||||
steps:
|
||||
- name: Send results to n8n webhook
|
||||
env:
|
||||
LINT_STATUS: ${{ needs.lint.result }}
|
||||
TEST_STATUS: ${{ needs.test.result }}
|
||||
RAW_LINT_OUTPUT: ${{ needs.lint.outputs.output }}
|
||||
RAW_TEST_OUTPUT: ${{ needs.test.outputs.output }}
|
||||
LINT_STATUS: ${{ needs.ci.outputs.lint_status }}
|
||||
TEST_STATUS: ${{ needs.ci.outputs.test_status }}
|
||||
RAW_LINT_OUTPUT: ${{ needs.ci.outputs.lint_output }}
|
||||
RAW_TEST_OUTPUT: ${{ needs.ci.outputs.test_output }}
|
||||
GH_REPO: ${{ github.repository }}
|
||||
GH_BRANCH: ${{ github.head_ref || github.ref_name }}
|
||||
GH_SHA: ${{ github.sha }}
|
||||
@ -191,11 +157,11 @@ jobs:
|
||||
--fail --silent --show-error
|
||||
|
||||
- name: Fail if lint or tests failed
|
||||
if: needs.lint.result != 'success' || needs.test.result != 'success'
|
||||
if: needs.ci.outputs.lint_status != 'success' || needs.ci.outputs.test_status != 'success'
|
||||
run: |
|
||||
echo "❌ Pipeline failed:"
|
||||
echo " Lint: ${{ needs.lint.result }}"
|
||||
echo " Test: ${{ needs.test.result }}"
|
||||
echo " Lint: ${{ needs.ci.outputs.lint_status }}"
|
||||
echo " Test: ${{ needs.ci.outputs.test_status }}"
|
||||
exit 1
|
||||
|
||||
# ============================================================
|
||||
@ -228,7 +194,7 @@ jobs:
|
||||
build:
|
||||
name: Build & Push Image
|
||||
runs-on: ubuntu-latest
|
||||
needs: [lint, test, scan-deps, notify]
|
||||
needs: [ci, scan-deps, notify]
|
||||
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
|
||||
|
||||
outputs:
|
||||
|
||||
Reference in New Issue
Block a user