|
1 | 1 | name: PR Test Gate |
2 | 2 |
|
3 | 3 | on: |
4 | | - pull_request: |
5 | | - branches: |
6 | | - - main |
| 4 | + workflow_run: |
| 5 | + workflows: ["CI"] |
| 6 | + types: [completed] |
7 | 7 |
|
8 | 8 | jobs: |
9 | 9 | contracts-test: |
10 | 10 | name: Contracts cargo test |
11 | 11 | runs-on: ubuntu-latest |
| 12 | + if: github.event.workflow_run.event == 'pull_request' |
12 | 13 | steps: |
13 | | - - name: Checkout code |
14 | | - uses: actions/checkout@v4 |
15 | | - |
16 | | - - name: Setup Rust |
17 | | - uses: dtolnay/rust-toolchain@stable |
18 | | - with: |
19 | | - targets: wasm32-unknown-unknown |
20 | | - |
21 | | - - name: Run cargo test |
22 | | - run: cargo test |
23 | | - working-directory: contracts |
| 14 | + - name: Verify CI succeeded for the pull request |
| 15 | + env: |
| 16 | + CI_CONCLUSION: ${{ github.event.workflow_run.conclusion }} |
| 17 | + PR_NUMBER: ${{ github.event.workflow_run.pull_requests[0].number }} |
| 18 | + run: | |
| 19 | + if [ "$CI_CONCLUSION" != "success" ]; then |
| 20 | + echo "CI workflow failed for pull request #${PR_NUMBER}." |
| 21 | + exit 1 |
| 22 | + fi |
| 23 | + echo "CI workflow succeeded for pull request #${PR_NUMBER}; no duplicate contract run is required." |
24 | 24 |
|
25 | 25 | backend-test: |
26 | 26 | name: Backend npm test |
27 | 27 | runs-on: ubuntu-latest |
28 | | - services: |
29 | | - postgres: |
30 | | - # Pinned to match the version used in ci.yml and docker-compose.yml |
31 | | - # (production target). Keep these in sync — see issue #1282. |
32 | | - image: postgres:16-alpine@sha256:e013e867e712fec275706a6c51c966f0bb0c93cfa8f51000f85a15f9865a28cb |
33 | | - env: |
34 | | - POSTGRES_USER: postgres |
35 | | - POSTGRES_PASSWORD: password |
36 | | - POSTGRES_DB: flowfi_test |
37 | | - ports: |
38 | | - - 5432:5432 |
39 | | - options: >- |
40 | | - --health-cmd "pg_isready -U postgres" |
41 | | - --health-interval 10s |
42 | | - --health-timeout 5s |
43 | | - --health-retries 5 |
| 28 | + if: github.event.workflow_run.event == 'pull_request' |
44 | 29 | steps: |
45 | | - - name: Checkout code |
46 | | - uses: actions/checkout@v4 |
47 | | - |
48 | | - - name: Setup Node.js |
49 | | - uses: actions/setup-node@v4 |
50 | | - with: |
51 | | - node-version: "20" |
52 | | - cache: "npm" |
53 | | - cache-dependency-path: package-lock.json |
54 | | - |
55 | | - - name: Install dependencies |
56 | | - run: npm ci --include=optional |
57 | | - |
58 | | - - name: Prepare database schema |
59 | | - run: | |
60 | | - npx prisma generate --schema=prisma/schema.prisma |
61 | | - npx prisma db push --accept-data-loss --schema=prisma/schema.prisma |
62 | | - working-directory: backend |
| 30 | + - name: Verify CI succeeded for the pull request |
63 | 31 | env: |
64 | | - DATABASE_URL: postgresql://postgres:password@127.0.0.1:5432/flowfi_test |
65 | | - |
66 | | - - name: Run backend tests |
| 32 | + CI_CONCLUSION: ${{ github.event.workflow_run.conclusion }} |
| 33 | + PR_NUMBER: ${{ github.event.workflow_run.pull_requests[0].number }} |
67 | 34 | run: | |
68 | | - ls -la src/generated/prisma |
69 | | - npm test --silent -- --reporter=basic |
70 | | - working-directory: backend |
71 | | - env: |
72 | | - DATABASE_URL: postgresql://postgres:password@127.0.0.1:5432/flowfi_test |
73 | | - NODE_ENV: test |
| 35 | + if [ "$CI_CONCLUSION" != "success" ]; then |
| 36 | + echo "CI workflow failed for pull request #${PR_NUMBER}." |
| 37 | + exit 1 |
| 38 | + fi |
| 39 | + echo "CI workflow succeeded for pull request #${PR_NUMBER}; no duplicate backend run is required." |
0 commit comments