-
Notifications
You must be signed in to change notification settings - Fork 0
205 lines (180 loc) · 7.69 KB
/
Copy pathtest.yml
File metadata and controls
205 lines (180 loc) · 7.69 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
name: Tests
# Runs on every push/PR touching the daemon, the greeter, or the UI, plus a
# manual trigger. Three independent jobs (daemon / greeter / ui) so a
# failure in one surface doesn't hide failures in the others, and so they
# run in parallel rather than one long serial pipeline.
#
# This workflow is CI quality gates ONLY (fmt / clippy / lint / unit tests).
# It does not produce a release build or any downloadable artifact — that's
# build.yml, which only runs after code actually lands (push to main or a
# version tag) or on manual dispatch.
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
# ── daemon (Rust, no GUI toolkit deps — pure tokio + std) ─────────────────
daemon:
name: daemon (cargo fmt / clippy / test)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Cache cargo registry & build artifacts
uses: Swatinem/rust-cache@v2
with:
workspaces: daemon
- name: cargo fmt --check
working-directory: daemon
run: cargo fmt --check
# --deny warnings: clippy found real, deny-by-default bugs in this
# codebase before (identical if/else branches in pam_auth.rs) — this
# flag is what makes clippy actually enforce that class of issue in
# CI instead of only warning locally.
- name: cargo clippy
working-directory: daemon
run: cargo clippy --all-targets -- -D warnings
- name: cargo test
working-directory: daemon
run: cargo test --all-targets
# ── greeter (Rust + Tauri v2 — needs the GTK/WebKitGTK dev headers) ───────
greeter:
name: greeter (cargo fmt / clippy / check)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
# Tauri v2's official Linux CI dependency list — without these,
# anything that links webkit2gtk-sys / gtk-sys / javascriptcoregtk-sys
# fails at the `cc`/`pkg-config` step, not at a Rust type-checking
# step, which is a much more confusing failure to debug from a log.
- name: Install Tauri Linux build dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
libwebkit2gtk-4.1-dev \
libgtk-3-dev \
librsvg2-dev \
libsoup-3.0-dev \
libjavascriptcoregtk-4.1-dev \
libayatana-appindicator3-dev \
patchelf \
build-essential \
curl \
wget \
file
- name: Cache cargo registry & build artifacts
uses: Swatinem/rust-cache@v2
with:
workspaces: greeter
- name: cargo fmt --check
working-directory: greeter
run: cargo fmt --check
# NOTE: `tauri::generate_context!()` (called from main.rs) resolves
# `bundle.icon` in tauri.conf.json and needs that file to actually
# exist at *compile* time — for cargo clippy/check/test, not just
# `tauri build`. tauri.conf.json points icon at
# "../config/images/icon.png" (a real, always-present file in this
# repo) precisely so this step never needs an extra "prepare icons"
# step before it — a previous revision pointed it at a generated
# "icons/icon.png" that only existed after tauri build's
# beforeBuildCommand ran, which made plain `cargo clippy` fail here
# with "failed to open icon ... No such file or directory".
- name: cargo clippy
working-directory: greeter
run: cargo clippy --all-targets -- -D warnings
# `cargo test` (not just `check`) here too: greeter/src/main.rs has
# its own unit tests for the system-status parsers (any_interface_up,
# parse_battery_info, parse_amixer_volume) that don't need a display
# or real hardware to run in CI.
- name: cargo test
working-directory: greeter
run: cargo test --all-targets
# ── UI (Solid.js) ──────────────────────────────────────────────────────
ui:
name: ui (lint / test / build)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
# NOTE: deliberately NOT using `cache: npm` / `cache-dependency-path`
# here. actions/setup-node's built-in npm cache HARD-FAILS this
# entire step ("Some specified paths were not resolved, unable to
# cache dependencies") if the lockfile path doesn't resolve to an
# existing file — which is exactly what happened here twice.
# ui/package-lock.json and greeter/package-lock.json are committed
# to this repo (generated via `npm install --package-lock-only`),
# so that *shouldn't* trigger — but this class of failure is bad
# enough (it aborts the job before a single line of project code
# runs) that caching is done manually below instead, via
# actions/cache, which degrades to "no cache hit" rather than
# failing the job if a lockfile is ever briefly missing/renamed.
- name: Cache npm dependencies
uses: actions/cache@v4
with:
path: ui/node_modules
key: ${{ runner.os }}-npm-ui-${{ hashFiles('ui/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-ui-
# `npm ci` requires ui/package-lock.json to exist and match
# package.json exactly — it is committed in this repo. If it's ever
# missing (e.g. a bad merge), fall back to `npm install` instead of
# hard-failing the job, so "ui can't install npm" can never again be
# the single point of failure for the whole workflow — it just loses
# the reproducible-install guarantee for that one run instead, with a
# visible warning.
- name: Install dependencies
working-directory: ui
run: |
if [ -f package-lock.json ]; then
npm ci
else
echo "::warning::ui/package-lock.json is missing — falling back to 'npm install'. Commit the lockfile (npm install --package-lock-only) to fix this properly."
npm install
fi
- name: Formatting check (Prettier)
working-directory: ui
run: npm run format:check
- name: Lint (ESLint + eslint-plugin-solid)
working-directory: ui
run: npm run lint
- name: Unit tests (Vitest + @solidjs/testing-library)
working-directory: ui
run: npm run test
- name: Type-check + production build
working-directory: ui
run: npm run build
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: ui-dist
path: ui/dist
retention-days: 7
# Convenience job so branch protection can require one green check
# ("all-checks-passed") instead of hand-listing all three matrix jobs by
# name, which silently stops protecting anything if a job is renamed.
all-checks-passed:
name: All checks passed
runs-on: ubuntu-latest
needs: [daemon, greeter, ui]
if: always()
steps:
- name: Fail if any dependency job failed
run: |
if [[ "${{ contains(needs.*.result, 'failure') }}" == "true" ]]; then
echo "One or more required jobs failed."
exit 1
fi