Skip to content

Commit fdcaf7f

Browse files
committed
ci: add GitHub Actions validation workflow
1 parent 03a6995 commit fdcaf7f

1 file changed

Lines changed: 78 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
workflow-lint:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Check out repository
18+
uses: actions/checkout@v4
19+
20+
- name: Lint workflow syntax
21+
run: |
22+
docker run --rm -v "${{ github.workspace }}:/workspaces" rhysd/actionlint:1.7.7 /workspaces/.github/workflows/ci.yml
23+
24+
detect-relevant-changes:
25+
needs: workflow-lint
26+
runs-on: ubuntu-latest
27+
outputs:
28+
run_ci: ${{ steps.change_flags.outputs.run_ci }}
29+
steps:
30+
- name: Check out repository
31+
uses: actions/checkout@v4
32+
33+
- name: Detect CI-relevant changes
34+
if: github.event_name != 'workflow_dispatch'
35+
id: change_filter
36+
uses: dorny/paths-filter@v3
37+
with:
38+
filters: |
39+
relevant:
40+
- 'src/**'
41+
- 'tests/**'
42+
- '.github/workflows/**'
43+
- 'package.json'
44+
- 'bun.lock'
45+
- 'tsconfig.json'
46+
47+
- name: Resolve CI gate
48+
id: change_flags
49+
shell: bash
50+
run: |
51+
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
52+
echo "run_ci=true" >> "$GITHUB_OUTPUT"
53+
elif [[ "${{ steps.change_filter.outputs.relevant }}" == "true" ]]; then
54+
echo "run_ci=true" >> "$GITHUB_OUTPUT"
55+
else
56+
echo "run_ci=false" >> "$GITHUB_OUTPUT"
57+
fi
58+
59+
validate:
60+
needs:
61+
- workflow-lint
62+
- detect-relevant-changes
63+
if: needs.detect-relevant-changes.outputs.run_ci == 'true' || github.event_name == 'push'
64+
runs-on: ubuntu-latest
65+
steps:
66+
- name: Check out repository
67+
uses: actions/checkout@v4
68+
69+
- name: Set up Bun
70+
uses: oven-sh/setup-bun@v2
71+
with:
72+
bun-version: 1.3.5
73+
74+
- name: Install dependencies
75+
run: bun install --frozen-lockfile
76+
77+
- name: Run typecheck, tests, and build
78+
run: bun run check

0 commit comments

Comments
 (0)