-
-
Notifications
You must be signed in to change notification settings - Fork 1
223 lines (212 loc) · 6.45 KB
/
ci.yml
File metadata and controls
223 lines (212 loc) · 6.45 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
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
# CI workflow for Pull Requests
# Runs tests, linting, frontend checks, and Docker build with PR tag
name: CI
permissions:
contents: read
packages: write
on:
pull_request:
branches:
- main
# Cancel in-progress runs for same PR
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# Build test binaries and create nextest archive
build-tests:
name: Build Tests
runs-on: ubuntu-latest
timeout-minutes: 60
env:
SCCACHE_GHA_ENABLED: "true"
SCCACHE_GHA_VERSION: test
RUSTC_WRAPPER: sccache
steps:
- uses: actions/checkout@v4
- name: Install mold linker
run: sudo apt-get update && sudo apt-get install -y mold
- name: Install cargo-nextest
uses: taiki-e/install-action@nextest
- name: Setup sccache
uses: mozilla-actions/sccache-action@v0.0.9
- name: Build and archive tests
run: cargo nextest archive --features rar --archive-file nextest-archive.tar.zst
- name: Upload test archive
uses: actions/upload-artifact@v4
with:
name: nextest-archive
path: nextest-archive.tar.zst
retention-days: 1
# Run tests in parallel partitions
test:
name: Test (${{ matrix.partition }}/5)
needs: build-tests
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
partition: [1, 2, 3, 4, 5]
steps:
- uses: actions/checkout@v4
- name: Install cargo-nextest
uses: taiki-e/install-action@nextest
- name: Download test archive
uses: actions/download-artifact@v4
with:
name: nextest-archive
- name: Run tests (partition ${{ matrix.partition }}/5)
run: cargo nextest run --archive-file nextest-archive.tar.zst --partition hash:${{ matrix.partition }}/5
# Run linting checks
lint:
name: Lint
runs-on: ubuntu-latest
timeout-minutes: 30
env:
SCCACHE_GHA_ENABLED: "true"
SCCACHE_GHA_VERSION: lint
RUSTC_WRAPPER: sccache
steps:
- uses: actions/checkout@v4
- name: Install mold linker
run: sudo apt-get update && sudo apt-get install -y mold
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.95.0
components: rustfmt, clippy
- name: Setup sccache
uses: mozilla-actions/sccache-action@v0.0.9
- name: Format check
run: cargo fmt -- --check
- name: Clippy check
run: cargo clippy --features rar -- -D warnings
# Run frontend tests and build
frontend:
name: Frontend
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
- name: Install dependencies
working-directory: web
run: |
rm -rf node_modules package-lock.json
npm install
- name: Lint check
working-directory: web
run: npm run lint
- name: Run tests
uses: nick-fields/retry@v3
with:
timeout_minutes: 10
max_attempts: 3
command: cd web && npm run test:run
- name: Build frontend
working-directory: web
run: npm run build
# Run plugin checks (lint, typecheck, tests)
plugins:
name: Plugins (${{ matrix.plugin }})
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
plugin:
- sdk-typescript
- metadata-echo
- metadata-mangabaka
- metadata-openlibrary
- recommendations-anilist
- sync-anilist
- release-mangaupdates
- release-nyaa
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
# SDK must be built first for other plugins to use
- name: Build SDK (dependency)
if: matrix.plugin != 'sdk-typescript'
working-directory: plugins/sdk-typescript
run: |
rm -rf node_modules package-lock.json
npm install
npm run build
- name: Install dependencies
working-directory: plugins/${{ matrix.plugin }}
run: |
rm -rf node_modules package-lock.json
npm install
- name: Lint
working-directory: plugins/${{ matrix.plugin }}
run: npm run lint
- name: Typecheck
working-directory: plugins/${{ matrix.plugin }}
run: npx tsc --noEmit
- name: Test
working-directory: plugins/${{ matrix.plugin }}
run: npm run test
- name: Build
working-directory: plugins/${{ matrix.plugin }}
run: npm run build
# Build and push Docker image with PR tag
docker:
name: Docker
needs: [test, lint, frontend, plugins]
runs-on: ubuntu-latest
timeout-minutes: 240
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Determine build info
id: info
run: |
echo "DOCKER_REGISTRY=${GITHUB_REPOSITORY,,}" >> "$GITHUB_ENV"
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=ref,event=pr
type=sha,prefix=pr-${{ github.event.pull_request.number }}-sha-
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile.cross
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=ghcr.io/${{ env.DOCKER_REGISTRY }}-buildcache:latest
cache-to: type=registry,ref=ghcr.io/${{ env.DOCKER_REGISTRY }}-buildcache:latest,mode=max
# Clean up intermediate artifacts
cleanup:
name: Cleanup
needs:
- test
- docker
if: ${{ !failure() && !cancelled() }}
runs-on: ubuntu-latest
steps:
- name: Delete intermediate artifacts
uses: geekyeggo/delete-artifact@v5
with:
name: nextest-archive