-
Notifications
You must be signed in to change notification settings - Fork 1.3k
280 lines (236 loc) · 7.82 KB
/
ci.yml
File metadata and controls
280 lines (236 loc) · 7.82 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
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
name: "CI"
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.head_ref || github.ref_name }}
cancel-in-progress: true
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
jobs:
changes:
name: Detect Changes
runs-on: ubuntu-latest
outputs:
rust: ${{ steps.filter.outputs.rust }}
tauri-plugins: ${{ steps.filter.outputs.tauri-plugins }}
branch: ${{ steps.branch.outputs.branch }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Check for changes
uses: dorny/paths-filter@v2
id: filter
with:
filters: |
desktop:
- 'apps/desktop/**'
rust:
- '.cargo/**'
- '.github/**'
- 'crates/**'
- 'apps/desktop/src-tauri/**'
- 'Cargo.toml'
- 'Cargo.lock'
tauri-plugins:
- 'Cargo.lock'
- 'pnpm-lock.yaml'
- name: Output branch name
id: branch
run: |
echo "branch=${{ env.BRANCH_NAME }}" >> $GITHUB_OUTPUT
typecheck:
name: Typecheck
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: ./.github/actions/setup-js
- run: pnpm web exec next typegen
- name: Typecheck
run: pnpm typecheck
format-biome:
name: Format (Biome)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Biome
uses: biomejs/setup-biome@v2
with:
# Don't use `latest` as Biome throws an error when it doesn't match the
# schema version in the config file.
version: 2.2.0
- name: Run Biome
run: biome ci . --linter-enabled=false
format-rust:
name: Format (Cargo)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Check formatting
run: cargo fmt --check
clippy:
name: Clippy
needs: changes
if: needs.changes.outputs.rust == 'true'
strategy:
fail-fast: false
matrix:
settings:
- target: aarch64-apple-darwin
runner: macos-latest
- target: x86_64-pc-windows-msvc
runner: windows-latest
runs-on: ${{ matrix.settings.runner }}
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Rust setup
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.settings.target }}
components: clippy
- uses: ./.github/actions/setup-rust-cache
with:
target: ${{ matrix.settings.target }}
- name: Create .env file in root
run: |
echo "VITE_ENVIRONMENT=production" >> .env
echo "CAP_DESKTOP_SENTRY_URL=https://6a3b6a09e6ae976c2ad6fff710e88748@o4506859771527168.ingest.us.sentry.io/4508330917101568" >> .env
echo "NEXT_PUBLIC_WEB_URL=${{ secrets.NEXT_PUBLIC_WEB_URL }}" >> .env
echo 'NEXTAUTH_URL=${{ secrets.NEXT_PUBLIC_WEB_URL }}' >> .env
echo 'NEXT_PUBLIC_POSTHOG_KEY=${{ secrets.NEXT_PUBLIC_POSTHOG_KEY }}' >> .env
echo 'NEXT_PUBLIC_POSTHOG_HOST=${{ secrets.NEXT_PUBLIC_POSTHOG_HOST }}' >> .env
echo 'VITE_POSTHOG_KEY=${{ secrets.NEXT_PUBLIC_POSTHOG_KEY }}' >> .env
echo 'VITE_POSTHOG_HOST=${{ secrets.NEXT_PUBLIC_POSTHOG_HOST }}' >> .env
echo 'VITE_SERVER_URL=${{ secrets.NEXT_PUBLIC_WEB_URL }}' >> .env
cat .env >> $GITHUB_ENV
- name: Run setup
shell: bash
run: node scripts/setup.js
- name: Run Clippy
run: cargo clippy --workspace --all-features --locked -- -D warnings
lint-biome:
name: Lint (Biome)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Biome
uses: biomejs/setup-biome@v2
with:
version: latest
- name: Run Biome
run: biome ci . || true
build-desktop:
name: Build Desktop
needs: changes
if: needs.changes.outputs.desktop == 'true'
strategy:
fail-fast: false
matrix:
settings:
- target: aarch64-apple-darwin
runner: macos-latest
- target: x86_64-pc-windows-msvc
runner: windows-latest
runs-on: ${{ matrix.settings.runner }}
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Rust setup
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.settings.target }}
- uses: ./.github/actions/setup-rust-cache
with:
target: ${{ matrix.settings.target }}
- uses: ./.github/actions/setup-js
- name: Create .env file in root
run: |
echo "VITE_ENVIRONMENT=production" >> .env
echo "CAP_DESKTOP_SENTRY_URL=https://6a3b6a09e6ae976c2ad6fff710e88748@o4506859771527168.ingest.us.sentry.io/4508330917101568" >> .env
echo "NEXT_PUBLIC_WEB_URL=${{ secrets.NEXT_PUBLIC_WEB_URL }}" >> .env
echo 'NEXTAUTH_URL=${{ secrets.NEXT_PUBLIC_WEB_URL }}' >> .env
echo 'NEXT_PUBLIC_POSTHOG_KEY=${{ secrets.NEXT_PUBLIC_POSTHOG_KEY }}' >> .env
echo 'NEXT_PUBLIC_POSTHOG_HOST=${{ secrets.NEXT_PUBLIC_POSTHOG_HOST }}' >> .env
echo 'VITE_POSTHOG_KEY=${{ secrets.NEXT_PUBLIC_POSTHOG_KEY }}' >> .env
echo 'VITE_POSTHOG_HOST=${{ secrets.NEXT_PUBLIC_POSTHOG_HOST }}' >> .env
echo 'VITE_SERVER_URL=${{ secrets.NEXT_PUBLIC_WEB_URL }}' >> .env
- name: Copy .env to apps/desktop
run: cp .env apps/desktop/.env
- name: Output .env file
run: cat apps/desktop/.env
- name: Build app
working-directory: apps/desktop
run: |
pnpm -w cap-setup
pnpm tauri build --debug --target ${{ matrix.settings.target }} --no-bundle
env:
RUST_TARGET_TRIPLE: ${{ matrix.settings.target }}
tauri-plugins:
name: Verify Tauri plugin versions
runs-on: ubuntu-latest
needs: changes
if: needs.changes.outputs.tauri-plugins == 'true'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 20
- name: Run verify
shell: bash
run: node scripts/check-tauri-plugin-versions.js
rust-cache:
name: Rust cache
needs: changes
if: needs.changes.outputs.branch == 'main'
strategy:
fail-fast: false
matrix:
settings:
- target: x86_64-apple-darwin
runner: macos-latest
- target: aarch64-apple-darwin
runner: macos-latest
- target: x86_64-pc-windows-msvc
runner: windows-latest
runs-on: ${{ matrix.settings.runner }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Rust setup
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.settings.target }}
- uses: ./.github/actions/setup-rust-cache
with:
target: ${{ matrix.settings.target }}
save-cache: true
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 24
- run: node scripts/setup.js
- name: Build debug
run: cargo build --all
- name: Build release
run: cargo check --all --release
- name: Run Clippy
if: ${{ matrix.settings.target == 'aarch64-apple-darwin' || matrix.settings.target == 'x86_64-pc-windows-msvc' }}
run: cargo clippy --workspace --all-features --locked -- -D warnings