-
Notifications
You must be signed in to change notification settings - Fork 7
197 lines (191 loc) · 6.09 KB
/
build-lint-test.yml
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
name: Build, lint & test
on:
workflow_dispatch:
pull_request:
merge_group:
types: [checks_requested]
push:
branches:
- main
jobs:
backend:
name: Backend (${{ matrix.target.os }})
strategy:
matrix:
target:
- os: ubuntu-latest
name: x86_64-unknown-linux-musl
binary: backend/target/x86_64-unknown-linux-musl/debug/abacus
- os: macos-latest
name: aarch64-apple-darwin
binary: backend/target/aarch64-apple-darwin/debug/abacus
- os: windows-latest
name: x86_64-pc-windows-msvc
binary: backend/target/x86_64-pc-windows-msvc/debug/abacus.exe
runs-on: ${{ matrix.target.os }}
defaults:
run:
working-directory: ./backend
env:
CARGO_TERM_COLOR: always
ASSET_DIR: ${{ github.workspace }}/frontend/dist
SQLX_OFFLINE: "true"
NODE_ENV: production
steps:
- uses: actions/checkout@v4
# Build frontend so that it can be included in the backend build
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 22
- name: Install dependencies
run: npm ci
working-directory: ./frontend
- name: Build
run: npm run build
working-directory: ./frontend
# Compile and test backend
- name: Setup Rust
shell: bash
run: >
rustup update stable &&
rustup default stable &&
echo RUST_VERSION=$(rustc --version | cut -d' ' -f2) >> $GITHUB_ENV
- name: Cargo cache
uses: actions/cache@v4
with:
path: |
~/.cargo/.crates.toml
~/.cargo/.crates2.json
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
./backend/target/
key: ${{ runner.os }}-cargo-${{ env.RUST_VERSION }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-${{ env.RUST_VERSION }}-
- name: Install musl
run: sudo apt-get update && sudo apt-get install -y musl-tools
if: matrix.target.os == 'ubuntu-latest'
- name: Install target
run: rustup target add ${{ matrix.target.name }}
- name: Check rustfmt
run: cargo --verbose --locked fmt --all -- --check
- name: Check Clippy with all features
run: cargo --verbose --locked clippy --target=${{ matrix.target.name }} --all-targets --all-features -- -D warnings
- name: Check Clippy without default features
run: cargo --verbose --locked clippy --target=${{ matrix.target.name }} --all-targets --no-default-features -- -D warnings
- name: Run tests
run: cargo --verbose --locked test --target=${{ matrix.target.name }} -- --nocapture
- name: Build
run: cargo --verbose --locked build --features memory-serve --target=${{ matrix.target.name }}
- uses: actions/upload-artifact@v4
with:
name: abacus-${{ matrix.target.os }}
path: ${{ matrix.target.binary }}
frontend:
name: Frontend
runs-on: ubuntu-latest
defaults:
run:
working-directory: frontend
steps:
- uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 22
- name: Install dependencies
run: npm ci
- name: Check formatting
run: npx prettier --check .
- name: Lint
run: npm run lint
- name: Test
run: npm test
- name: Build
run: npm run build
- uses: actions/upload-artifact@v4
with:
name: frontend-build
path: frontend/dist
playwright-ladle:
name: Playwright ladle tests
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: frontend
steps:
- uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 22
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps --no-shell
- name: Run ladle playwright tests
run: npm run test:ladle
playwright-e2e:
name: Playwright e2e tests (${{ matrix.os }})
needs:
- backend
- frontend # for the tests, frontend build is included in backend job
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: frontend
steps:
- uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 22
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps --no-shell
- name: Download abacus
uses: actions/download-artifact@v4
with:
name: abacus-${{ matrix.os }}
path: builds/backend
- name: make backend build executable
run: chmod a+x ../builds/backend/abacus
if: runner.os != 'Windows'
- name: Run e2e playwright tests
run: npm run test:e2e
deploy:
name: Deploy to abacus-test.nl
needs:
- backend
- frontend # for the tests, frontend build is included in backend job
environment:
name: test
url: https://${{ github.sha }}.abacus-test.nl
permissions:
contents: read
deployments: write
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Download abacus
uses: actions/download-artifact@v4
with:
name: abacus-ubuntu-latest
- name: Strip debug symbols
run: strip abacus
- name: Upload binary to test server
run: |
curl -s \
--fail \
-H "Authorization: Bearer ${{ secrets.ABACUS_TEST_API_KEY }}" \
-T ./abacus \
https://abacus-test.nl/etes/api/v1/executable/${{ github.event.pull_request.head.sha || github.sha }}/${{ github.sha }}