-
Notifications
You must be signed in to change notification settings - Fork 0
160 lines (148 loc) · 4.93 KB
/
check.yml
File metadata and controls
160 lines (148 loc) · 4.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
name: CI
on:
pull_request:
permissions:
contents: read
jobs:
changes:
name: Detect changes
runs-on: ubuntu-latest
outputs:
code: ${{ steps.filter.outputs.code }}
docker: ${{ steps.filter.outputs.docker }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
predicate-quantifier: 'every'
filters: |
code:
- '**'
- '!*.md'
- '!**/*.md'
- '!docs/**'
- '!decisions/**'
docker:
- 'test/docker/**'
static-analysis:
name: Static analysis
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: oven-sh/setup-bun@v2
- run: bun install
- name: Validate commit messages
run: bunx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }}
- name: Lint
run: bun run lint
- name: Typecheck
run: bun run typecheck
- name: Check circular dependencies
run: bun run cycles
- name: Validate version stamping
run: |
bun run scripts/set-version.ts
VERSION=$(grep -oP 'ARB_VERSION = "\K[^"]+' src/version.ts)
if [[ -z "$VERSION" ]]; then
echo "::error::set-version.ts produced an empty version"
exit 1
fi
echo "Version stamp OK: $VERSION"
git checkout src/version.ts
unit-tests:
name: Unit tests
needs: changes
runs-on: ubuntu-latest
steps:
- name: Skip (no code changes)
if: needs.changes.outputs.code != 'true'
run: echo "No code changes detected, skipping tests"
- uses: actions/checkout@v4
if: needs.changes.outputs.code == 'true'
- uses: oven-sh/setup-bun@v2
if: needs.changes.outputs.code == 'true'
- name: Configure git
if: needs.changes.outputs.code == 'true'
run: |
git config --global user.name "CI"
git config --global user.email "ci@localhost"
- run: bun install
if: needs.changes.outputs.code == 'true'
- name: Unit tests
if: needs.changes.outputs.code == 'true'
run: bun run test
integration:
name: Integration tests (${{ matrix.os }})
needs: changes
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- name: Skip (no code changes)
if: needs.changes.outputs.code != 'true'
run: echo "No code changes detected, skipping tests"
- uses: actions/checkout@v4
if: needs.changes.outputs.code == 'true'
with:
fetch-depth: 0
- uses: oven-sh/setup-bun@v2
if: needs.changes.outputs.code == 'true'
- name: Configure git
if: needs.changes.outputs.code == 'true'
run: |
git config --global user.name "CI"
git config --global user.email "ci@localhost"
- run: bun install
if: needs.changes.outputs.code == 'true'
- name: Build
if: needs.changes.outputs.code == 'true'
run: bun run build
- name: Integration tests
if: needs.changes.outputs.code == 'true'
run: |
if [ "${{ matrix.os }}" = "macos-latest" ]; then
bun test test/integration/macos.test.ts --concurrent --timeout 30000
else
bun test test/integration/ --concurrent --timeout 30000
fi
integration-git217:
name: Integration tests (git 2.17)
needs: changes
if: needs.changes.outputs.code == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
steps:
- uses: actions/checkout@v4
- name: Compute image tag
id: tag
run: |
HASH=$(cat test/docker/git217.Dockerfile test/docker/entrypoint.sh | sha256sum | cut -c1-16)
echo "hash=$HASH" >> "$GITHUB_OUTPUT"
- name: Pull pre-built image
id: pull
if: needs.changes.outputs.docker != 'true'
continue-on-error: true
run: |
docker pull "ghcr.io/${{ github.repository }}/git217:${{ steps.tag.outputs.hash }}"
docker tag "ghcr.io/${{ github.repository }}/git217:${{ steps.tag.outputs.hash }}" arb-git217:latest
- name: Set up Docker Buildx
if: needs.changes.outputs.docker == 'true' || steps.pull.outcome == 'failure'
uses: docker/setup-buildx-action@v3
- name: Build Docker image
if: needs.changes.outputs.docker == 'true' || steps.pull.outcome == 'failure'
uses: docker/build-push-action@v6
with:
context: test/docker/
file: test/docker/git217.Dockerfile
tags: arb-git217:latest
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Integration tests (git 2.17)
run: docker run --rm -v "$PWD":/app -w /app arb-git217