Skip to content

Commit 8eb8fd4

Browse files
committed
chore: report action status as GH status checks
1 parent e62579b commit 8eb8fd4

4 files changed

Lines changed: 128 additions & 3 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Commit status
2+
description: Report a commit status on the PR head commit via the GitHub Statuses API.
3+
4+
inputs:
5+
context:
6+
description: Status context (the check name shown on the PR).
7+
required: true
8+
state:
9+
description: One of pending, success, failure, error.
10+
required: true
11+
description:
12+
description: Short human-readable status description.
13+
required: false
14+
default: ''
15+
16+
runs:
17+
using: composite
18+
steps:
19+
- shell: bash
20+
env:
21+
GH_TOKEN: ${{ github.token }}
22+
run: |
23+
gh api "repos/${{ github.repository }}/statuses/${{ github.event.pull_request.head.sha }}" \
24+
-f state="${{ inputs.state }}" \
25+
-f context="${{ inputs.context }}" \
26+
-f description="${{ inputs.description }}" \
27+
-f target_url="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"

.github/workflows/e2e.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ concurrency:
99
group: e2e-${{ github.ref }}
1010
cancel-in-progress: true
1111

12+
permissions:
13+
contents: read
14+
statuses: write
15+
1216
jobs:
1317
e2e:
1418
runs-on: ubuntu-latest
@@ -19,6 +23,14 @@ jobs:
1923
with:
2024
fetch-depth: 1
2125

26+
- name: Report pending status
27+
if: github.event_name == 'pull_request'
28+
uses: ./.github/actions/commit-status
29+
with:
30+
context: e2e
31+
state: pending
32+
description: Running E2E tests
33+
2234
- name: Setup Bun
2335
uses: oven-sh/setup-bun@v2
2436

@@ -58,3 +70,11 @@ jobs:
5870
name: playwright-report
5971
path: playwright-report/
6072
retention-days: 7
73+
74+
- name: Report final status
75+
if: ${{ !cancelled() && github.event_name == 'pull_request' }}
76+
uses: ./.github/actions/commit-status
77+
with:
78+
context: e2e
79+
state: ${{ job.status == 'success' && 'success' || 'failure' }}
80+
description: ${{ job.status == 'success' && 'E2E tests passed' || 'E2E tests failed' }}

.github/workflows/schema.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77
- 'supabase/migrations/**'
88
workflow_dispatch:
99

10+
permissions:
11+
contents: read
12+
statuses: write
13+
1014
jobs:
1115
schema:
1216
runs-on: ubuntu-latest
@@ -15,6 +19,14 @@ jobs:
1519
- name: Checkout repository
1620
uses: actions/checkout@v5
1721

22+
- name: Report pending status
23+
if: github.event_name == 'pull_request'
24+
uses: ./.github/actions/commit-status
25+
with:
26+
context: schema
27+
state: pending
28+
description: Checking schema and generated types
29+
1830
- name: Setup Bun
1931
uses: oven-sh/setup-bun@v2
2032

@@ -60,3 +72,11 @@ jobs:
6072
echo "::error::Generated DB types are out of date. Run 'bun schema' locally and commit the result."
6173
exit 1
6274
fi
75+
76+
- name: Report final status
77+
if: ${{ !cancelled() && github.event_name == 'pull_request' }}
78+
uses: ./.github/actions/commit-status
79+
with:
80+
context: schema
81+
state: ${{ job.status == 'success' && 'success' || 'failure' }}
82+
description: ${{ job.status == 'success' && 'Schema in sync' || 'Schema out of sync' }}

.github/workflows/test.yml

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@ on:
55
branches: [main]
66
pull_request:
77

8+
permissions:
9+
contents: read
10+
statuses: write
11+
812
jobs:
9-
test:
13+
unit:
1014
runs-on: ubuntu-latest
1115
timeout-minutes: 15
1216
steps:
@@ -15,6 +19,14 @@ jobs:
1519
with:
1620
fetch-depth: 1
1721

22+
- name: Report pending status
23+
if: github.event_name == 'pull_request'
24+
uses: ./.github/actions/commit-status
25+
with:
26+
context: unit
27+
state: pending
28+
description: Running unit tests
29+
1830
- name: Setup Bun
1931
uses: oven-sh/setup-bun@v2
2032

@@ -28,10 +40,56 @@ jobs:
2840
- name: Install dependencies
2941
run: bun install --frozen-lockfile
3042

31-
# No Postgres/Supabase/S3 services needed: the DB is an ephemeral in-memory PGlite started by
32-
# the test script, and S3/Supabase are faked (see .env.test).
3343
- name: Unit tests
3444
run: bun run test:unit
3545

46+
- name: Report final status
47+
if: ${{ !cancelled() && github.event_name == 'pull_request' }}
48+
uses: ./.github/actions/commit-status
49+
with:
50+
context: unit
51+
state: ${{ job.status == 'success' && 'success' || 'failure' }}
52+
description: ${{ job.status == 'success' && 'Unit tests passed' || 'Unit tests failed' }}
53+
54+
integration:
55+
runs-on: ubuntu-latest
56+
timeout-minutes: 15
57+
steps:
58+
- name: Checkout repository
59+
uses: actions/checkout@v5
60+
with:
61+
fetch-depth: 1
62+
63+
- name: Report pending status
64+
if: github.event_name == 'pull_request'
65+
uses: ./.github/actions/commit-status
66+
with:
67+
context: integration
68+
state: pending
69+
description: Running integration tests
70+
71+
- name: Setup Bun
72+
uses: oven-sh/setup-bun@v2
73+
74+
- name: Cache bun install cache
75+
uses: actions/cache@v4
76+
with:
77+
path: ~/.bun/install/cache
78+
key: bun-${{ runner.os }}-${{ hashFiles('bun.lock') }}
79+
restore-keys: bun-${{ runner.os }}-
80+
81+
- name: Install dependencies
82+
run: bun install --frozen-lockfile
83+
84+
# No Postgres/Supabase/S3 services needed: the DB is an ephemeral in-memory PGlite started by
85+
# the test script, and S3/Supabase are faked (see .env.test).
3686
- name: Integration tests
3787
run: bun run test:integration
88+
89+
- name: Report final status
90+
if: ${{ !cancelled() && github.event_name == 'pull_request' }}
91+
uses: ./.github/actions/commit-status
92+
with:
93+
context: integration
94+
state: ${{ job.status == 'success' && 'success' || 'failure' }}
95+
description: ${{ job.status == 'success' && 'Integration tests passed' || 'Integration tests failed' }}

0 commit comments

Comments
 (0)