-
Notifications
You must be signed in to change notification settings - Fork 0
129 lines (121 loc) · 5.89 KB
/
Copy pathci.yml
File metadata and controls
129 lines (121 loc) · 5.89 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
name: CI
# Deck is a cargo-generate TEMPLATE: its tracked source contains {{ }} Liquid tokens
# (see cargo-generate.toml `include`) and so does NOT build directly. Every job below
# therefore GENERATES a throwaway project from the template first, then builds / lints /
# tests THAT. Editing the template? Read the "cargo-generate template" note in CLAUDE.md.
#
# COST: free. Standard GitHub-hosted runners (macos-latest, ubuntu-latest) are free +
# unlimited on PUBLIC repos — the macOS 10x multiplier only burns quota on PRIVATE repos.
# If you ever make this repo private, gate the `macos` job to tags to avoid eating minutes:
# if: github.event_name == 'pull_request' || startsWith(github.ref, 'refs/tags/v')
# (Don't switch to "*-large" runners — those are billed even on public repos.)
on:
push:
branches: [main]
tags: ["v*"]
pull_request:
branches: [main]
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
# Least-privilege GITHUB_TOKEN: this workflow only checks out, generates, builds, lints,
# tests, and runs cargo-deny — it needs read access to repo contents and nothing else.
permissions:
contents: read
# Cancel a still-running CI for a branch when a newer commit is pushed (faster feedback,
# fewer minutes — the generated project's first git-gpui build is slow).
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
# Prebuilt cargo-generate (fast, deterministic — no compile). SHA-pinned;
# Dependabot (github-actions) keeps it current.
- uses: taiki-e/install-action@7a79fe8c3a13344501c80d99cae481c1c9085912 # v2.81.10
with:
tool: cargo-generate
# Render the template into a sibling dir (NOT inside the repo — a nested cargo
# project confuses cargo, see rust-lang/cargo#9922). --silent uses the placeholder
# defaults (bundle_qualifier=com, bundle_org=example).
- name: Generate a project from the template
run: |
mkdir -p "$RUNNER_TEMP/gen"
cargo generate --path . --name deck-ci --silent --vcs none --destination "$RUNNER_TEMP/gen"
# No toolchain pin here: rust-toolchain.toml (copied into the generated project) is
# the single source of truth; rustup auto-installs it on the first cargo call.
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
with:
workspaces: ${{ runner.temp }}/gen/deck-ci
# No --locked: the generated Cargo.lock's root entry is renamed at generate time, so
# cargo refreshes just that on first build (the git-gpui deps stay pinned).
- name: Build, lint, and test the generated project
working-directory: ${{ runner.temp }}/gen/deck-ci
run: |
cargo build
cargo build --features tray
cargo clippy --all-targets -- -D warnings
cargo clippy --all-targets --features tray -- -D warnings
cargo clippy --all-targets --features overlay -- -D warnings
cargo clippy --all-targets --features tray,overlay -- -D warnings
cargo test
cargo test --features overlay
linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
# System libraries GPUI needs on Linux (X11 + Wayland + Vulkan + fonts), plus
# GTK/appindicator for the optional tray feature.
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
build-essential pkg-config \
libxcb1-dev libxkbcommon-dev libxkbcommon-x11-dev \
libwayland-dev \
libvulkan-dev \
libfontconfig1-dev libfreetype6-dev \
libssl-dev \
libgtk-3-dev libayatana-appindicator3-dev libxdo-dev
- uses: taiki-e/install-action@7a79fe8c3a13344501c80d99cae481c1c9085912 # v2.81.10
with:
tool: cargo-generate
- name: Generate a project from the template
run: |
mkdir -p "$RUNNER_TEMP/gen"
cargo generate --path . --name deck-ci --silent --vcs none --destination "$RUNNER_TEMP/gen"
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
with:
workspaces: ${{ runner.temp }}/gen/deck-ci
# Formatting is OS-independent, so gate `cargo fmt --check` once on the cheaper
# Linux runner. The overlay feature is a compile-only no-op on Linux (no LayerShell).
- name: Format-check, build, lint, and test the generated project
working-directory: ${{ runner.temp }}/gen/deck-ci
run: |
cargo fmt --all --check
cargo build
cargo build --features tray
cargo clippy --all-targets -- -D warnings
cargo clippy --all-targets --features tray -- -D warnings
cargo clippy --all-targets --features overlay -- -D warnings
cargo test
cargo test --features overlay
# Supply-chain gate (advisories / bans / sources / licenses) via cargo-deny, run against
# the GENERATED project (the raw template Cargo.toml has tokens and won't parse). REQUIRED:
# a deny.toml violation fails the build.
cargo-deny:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- uses: taiki-e/install-action@7a79fe8c3a13344501c80d99cae481c1c9085912 # v2.81.10
with:
tool: cargo-generate,cargo-deny
- name: Generate a project from the template
run: |
mkdir -p "$RUNNER_TEMP/gen"
cargo generate --path . --name deck-ci --silent --vcs none --destination "$RUNNER_TEMP/gen"
- name: cargo-deny check
working-directory: ${{ runner.temp }}/gen/deck-ci
run: cargo deny check advisories bans sources licenses