Repository navigation
183 lines (177 loc) · 7.79 KB
/
Copy pathci.yml
File metadata and controls
183 lines (177 loc) · 7.79 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
# Builds and tests on every platform the app supports. Platform-only code (ConPTY, the
# OpenSSH agent pipe / Pageant on Windows, GTK on Linux) cannot be checked from another one,
# so each runs the frontend build, clippy and the tests. The runners are those the release
# builds on, so that what breaks only there shows up before a release: Windows on ARM64
# (where ring needs clang), and Ubuntu 22.04's older GTK and WebKitGTK. Intel Macs aren't
# checked apart: the code has nothing specific to the processor.
# Actions are pinned to a commit (Dependabot updates the hash and the version comment), so
# that a moved tag can't change what runs.
name: CI
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
# Weekly, for the advisories published meanwhile (the other jobs are skipped then).
schedule:
- cron: "17 3 * * 1"
permissions:
contents: read
# A newer push to a pull request replaces its run. Runs on main all finish: a release checks
# that CI passed on its commit (a group of their own, since a group keeps one pending run).
concurrency:
group: ci-${{ github.event_name == 'pull_request' && github.ref || github.sha }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
check:
strategy:
fail-fast: false
matrix:
include:
- name: macOS
os: macos-latest
- name: Windows
os: windows-latest
- name: Windows ARM64
os: windows-11-arm
- name: Linux
os: ubuntu-22.04
name: ${{ matrix.name }}
if: github.event_name != 'schedule'
runs-on: ${{ matrix.os }}
timeout-minutes: 60
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# What Tauri needs on Linux (WebKitGTK, GTK), and libdbus for Tao. The packages downloaded
# are kept from run to run, since the runners' Ubuntu mirror is at times very slow (over
# 20 minutes for them): only those Ubuntu updated since are downloaded. The release
# restores them too, under the same key.
- name: Restore Linux packages
id: apt-cache
if: runner.os == 'Linux'
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/apt-archives/*.deb
key: apt-${{ matrix.os }}
restore-keys: apt-${{ matrix.os }}-
- name: Linux libraries
if: runner.os == 'Linux'
run: |
# Into a folder of the runner's own, which the cache can read (apt's `partial` folder
# is closed to it). Packages Ubuntu no longer has are dropped, so it doesn't grow.
archives=(-o Dir::Cache::Archives="$HOME/apt-archives" -o APT::Keep-Downloaded-Packages=true)
mkdir -p ~/apt-archives/partial
sudo apt-get update
sudo apt-get install -y "${archives[@]}" libwebkit2gtk-4.1-dev libgtk-3-dev libsoup-3.0-dev libssl-dev libxdo-dev librsvg2-dev libdbus-1-dev
sudo apt-get autoclean "${archives[@]}"
# The cache's key: the packages' file names, which hold their versions.
echo "APT_PACKAGES=apt-${{ matrix.os }}-$(ls ~/apt-archives/*.deb | xargs -n1 basename | sha256sum | cut -c1-16)" >> "$GITHUB_ENV"
# Saved from main only, as Rust's cache below, and only when packages changed.
- name: Save Linux packages
if: runner.os == 'Linux' && github.ref == 'refs/heads/main' && steps.apt-cache.outputs.cache-matched-key != env.APT_PACKAGES
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/apt-archives/*.deb
key: ${{ env.APT_PACKAGES }}
- uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1
with:
version: 12
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 26
cache: pnpm
# pnpm/action-setup 6.1.0 left a pnpm on Windows whose commands ran nothing and still
# succeeded under PowerShell, so the frontend build and tests passed without running.
- name: Check that pnpm runs
shell: pwsh
run: |
$version = pnpm --version
if ($LASTEXITCODE -ne 0 -or -not $version) {
Write-Output "::error::pnpm --version printed nothing: pnpm commands would not run"
exit 1
}
Write-Output "pnpm $version"
- run: pnpm install --frozen-lockfile
# Formatting doesn't depend on the platform (.gitattributes checks out LF everywhere).
- if: runner.os == 'macOS'
run: pnpm format:check
# tauri::generate_context! embeds the built frontend.
- run: pnpm build
- run: pnpm test
- uses: dtolnay/rust-toolchain@686976e191b89faba57d3206551f0f330d8cb249 # stable
with:
toolchain: "1.99.0"
components: clippy, rustfmt
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
with:
workspaces: src-tauri
# Saved from main only: pull requests (Dependabot's every week) would fill the
# cache's quota and push main's out, and with it the release's, which then builds
# from scratch.
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Rustfmt
if: runner.os == 'macOS'
working-directory: src-tauri
run: cargo fmt --check
- name: Clippy
working-directory: src-tauri
run: cargo clippy --locked --all-targets -- -D warnings
- name: Test
working-directory: src-tauri
run: cargo test --locked
# Known security advisories for the Rust dependencies (RustSec) and the npm packages the app
# ships. Rust ones that don't apply are ignored in src-tauri/.cargo/audit.toml, each with why
# and when to look again; npm ones would be with `--ignore <GHSA>` below, with a comment.
audit:
name: Advisories
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: taiki-e/install-action@cfdb7ed4ccc7c7dce37759eae89dc5674b469b39 # v2.90.3
with:
tool: cargo-audit
- name: Audit
working-directory: src-tauri
run: cargo audit
- uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1
with:
version: 12
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 26
# Those of the packages the frontend bundles; build tools don't ship.
- name: Audit npm packages
run: pnpm audit --prod
# The third-party license notices (scripts/generate-licenses.mjs), which fail on a license
# not accepted in src-tauri/about.toml or a stale clarification there. The release
# workflow generates them too, but finding out there is too late. Not platform-specific,
# so once.
licenses:
name: Licenses
if: github.event_name != 'schedule'
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1
with:
version: 12
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 26
cache: pnpm
- run: pnpm install --frozen-lockfile
- uses: dtolnay/rust-toolchain@686976e191b89faba57d3206551f0f330d8cb249 # stable
with:
toolchain: "1.99.0"
- uses: taiki-e/install-action@cfdb7ed4ccc7c7dce37759eae89dc5674b469b39 # v2.90.3
with:
tool: cargo-about
- run: pnpm licenses:generate