-
-
Notifications
You must be signed in to change notification settings - Fork 989
284 lines (246 loc) · 8.45 KB
/
ci.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
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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
name: CI
on: [pull_request, merge_group]
env:
SPACEDRIVE_CUSTOM_APT_FLAGS: --no-install-recommends
# From: https://github.com/rust-lang/rust-analyzer/blob/master/.github/workflows/ci.yaml
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
RUST_BACKTRACE: short
RUSTUP_MAX_RETRIES: 10
SD_AUTH: disabled
# Cancel previous runs of the same workflow on the same branch.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
typescript:
name: Type and style check
runs-on: ubuntu-22.04
timeout-minutes: 7
permissions: {}
steps:
- name: 'PR commits + 1'
run: echo "PR_FETCH_DEPTH=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> "${GITHUB_ENV}"
- name: 'Checkout PR branch and all PR commits'
uses: actions/checkout@v4
with:
fetch-depth: ${{ env.PR_FETCH_DEPTH }}
- name: Setup Node.js, pnpm and dependencies
uses: ./.github/actions/setup-pnpm
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Perform typechecks
run: pnpm typecheck
- name: Perform style check
run: |-
set -eu
pnpm autoformat only-frontend >/dev/null
_files="$(git diff --name-only --cached)"
if [ -n "$_files" ]; then
printf "\e[31mThe following files are not correctly formatted:\e[0m\n" >&2
while IFS= read -r _file || [ -n "$_file" ]; do
echo "::error file=${_file},title=Incorrectly formatted file::Please run 'pnpm autoformat' and commit the changes."
echo " - ${_file}"
done < <(printf '%s' "$_files")
printf "\e[31mPlease run 'pnpm autoformat' and commit the changes.\e[0m\n" >&2
exit 1
fi
eslint:
name: ESLint
runs-on: ubuntu-22.04
permissions: {}
timeout-minutes: 5
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js, pnpm and dependencies
uses: ./.github/actions/setup-pnpm
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Perform linting
run: pnpm lint
cypress:
name: Cypress
runs-on: macos-14
timeout-minutes: 45
permissions: {}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup System and Rust
uses: ./.github/actions/setup-system
with:
token: ${{ secrets.GITHUB_TOKEN }}
target: aarch64-apple-darwin
- name: Setup Node.js, pnpm and dependencies
uses: ./.github/actions/setup-pnpm
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Cypress
run: |
set -euxo pipefail
pnpm exec cypress install
rm -rf /Users/runner/.cache/Cypress
ln -sf /Users/runner/Library/Caches/Cypress /Users/runner/.cache/Cypress
- name: Setup Cypress
uses: cypress-io/github-action@v6
with:
runTests: false
working-directory: .
- name: Download test data
run: pnpm test-data small
- name: E2E test
uses: cypress-io/github-action@v6
with:
build: npx cypress info
install: false
command: env CI=true pnpm test:e2e
working-directory: apps/web
- name: Upload cypress screenshots
uses: actions/upload-artifact@v4
if: always()
with:
name: cypress-screenshots
path: apps/web/cypress/screenshots
if-no-files-found: ignore
- name: Upload cypress video's
uses: actions/upload-artifact@v4
if: always()
with:
name: cypress-videos
path: apps/web/cypress/videos
if-no-files-found: ignore
rustfmt:
name: Rust Formatting
runs-on: ubuntu-22.04
timeout-minutes: 10
permissions:
contents: read
steps:
- name: Maximize build space
if: ${{ runner.os == 'Linux' }}
uses: easimon/maximize-build-space@master
with:
swap-size-mb: 3072
root-reserve-mb: 6144
remove-dotnet: 'true'
remove-codeql: 'true'
remove-haskell: 'true'
remove-docker-images: 'true'
- name: Symlink target to C:\
if: ${{ runner.os == 'Windows' }}
shell: powershell
run: |
New-Item -ItemType Directory -Force -Path C:\spacedrive_target
- name: Symlink target to C:\
if: ${{ runner.os == 'Windows' }}
shell: powershell
run: |
New-Item -Path target -ItemType Junction -Value C:\spacedrive_target
- name: Checkout repository
uses: actions/checkout@v4
- name: Check if files have changed
uses: dorny/paths-filter@v3
continue-on-error: true
id: filter
with:
filters: |
changes:
- 'apps/cli/**'
- 'apps/desktop/crates/**'
- 'apps/desktop/src-tauri/**'
- 'apps/mobile/crates/**'
- 'apps/server/**'
- 'core/**'
- 'crates/**'
- 'extensions/**'
- 'Cargo.toml'
- 'Cargo.lock'
- '.github/workflows/ci.yml'
- '.github/actions/setup-rust/**'
- '.github/actions/setup-system/**'
- name: Setup Rust and Prisma
if: steps.filter.outcome != 'success' || steps.filter.outputs.changes == 'true'
uses: ./.github/actions/setup-rust
with:
restore-cache: 'false'
- name: Run rustfmt
if: steps.filter.outcome != 'success' || steps.filter.outputs.changes == 'true'
run: cargo fmt --all -- --check
clippy:
strategy:
fail-fast: true
matrix:
settings:
- host: macos-13
target: x86_64-apple-darwin
- host: macos-14
target: aarch64-apple-darwin
- host: windows-latest
target: x86_64-pc-windows-msvc
- host: ubuntu-22.04
target: x86_64-unknown-linux-gnu
name: Clippy (${{ matrix.settings.host }})
runs-on: ${{ matrix.settings.host }}
permissions:
contents: read
timeout-minutes: 45
steps:
- name: Maximize build space
if: ${{ runner.os == 'Linux' }}
uses: easimon/maximize-build-space@master
with:
swap-size-mb: 3072
root-reserve-mb: 6144
remove-dotnet: 'true'
remove-codeql: 'true'
remove-haskell: 'true'
remove-docker-images: 'true'
- name: Symlink target to C:\
if: ${{ runner.os == 'Windows' }}
shell: powershell
run: |
New-Item -ItemType Directory -Force -Path C:\spacedrive_target
New-Item -Path target -ItemType Junction -Value C:\spacedrive_target
- name: Checkout repository
uses: actions/checkout@v4
- name: Find files that have changed
uses: dorny/paths-filter@v3
continue-on-error: true
id: filter
with:
filters: |
changes:
- ${{ runner.os == 'Windows' && 'scripts/setup.ps1' || 'scripts/setup.sh' }}
- 'scripts/preprep.mjs'
- 'apps/cli/**'
- 'apps/desktop/crates/**'
- 'apps/desktop/src-tauri/**'
- 'apps/mobile/crates/**'
- 'apps/server/**'
- 'core/**'
- 'crates/**'
- 'extensions/**'
- 'Cargo.toml'
- 'Cargo.lock'
- '.github/workflows/ci.yml'
- '.github/actions/setup-rust/**'
- '.github/actions/setup-system/**'
- name: Setup System and Rust
if: steps.filter.outcome != 'success' || steps.filter.outputs.changes == 'true'
uses: ./.github/actions/setup-system
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Run Clippy
if: steps.filter.outcome != 'success' || steps.filter.outputs.changes == 'true'
uses: giraffate/clippy-action@v1
with:
reporter: github-pr-review
tool_name: 'Clippy (${{ matrix.settings.host }})'
filter_mode: diff_context
github_token: ${{ secrets.GITHUB_TOKEN }}
clippy_flags: --workspace --all-features --locked
fail_on_error: true
# - name: Run tests
# if: steps.filter.outcome != 'success' || steps.filter.outputs.changes == 'true'
# run: cargo test --workspace --all-features --locked --target ${{ matrix.settings.target }}