-
Notifications
You must be signed in to change notification settings - Fork 0
173 lines (141 loc) · 6.42 KB
/
Copy pathrust.yml
File metadata and controls
173 lines (141 loc) · 6.42 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
name: CI
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
permissions:
contents: read
security-events: write
env:
CARGO_TERM_COLOR: always
jobs:
# ─── Lint ────────────────────────────────────────────────────────────
lint:
name: Lint (clippy + fmt)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
with:
components: clippy, rustfmt
- name: Install system dependencies
run: |
sudo apt-get -o Acquire::Retries=3 update
sudo apt-get -o Acquire::Retries=3 install -y --no-install-recommends \
libpipewire-0.3-dev libwayland-dev pkg-config
- name: Cache cargo registry and build
uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
- name: Check formatting
run: cargo fmt -- --check
- name: Install SARIF tools
run: cargo install clippy-sarif sarif-fmt
- name: Run clippy (SARIF + gate)
shell: bash
run: |
set -o pipefail
cargo clippy --all-targets --all-features --message-format=json -- -D warnings \
| clippy-sarif \
| tee rust-clippy-results.sarif \
| sarif-fmt
- name: Upload clippy results to GitHub Code Scanning
uses: github/codeql-action/upload-sarif@9e0d7b8d25671d64c341c19c0152d693099fb5ba # v4.35.5
with:
sarif_file: rust-clippy-results.sarif
wait-for-processing: true
if: always()
# ─── Deny ────────────────────────────────────────────────────────────
deny:
name: Deny (licenses + advisories + bans)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
- name: Install cargo-deny
run: cargo install cargo-deny --version 0.19.4 --locked
- name: Run cargo deny
run: cargo deny check
# ─── Test ────────────────────────────────────────────────────────────
test:
name: Test (unit)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
- name: Install system dependencies
run: |
sudo apt-get -o Acquire::Retries=3 update
sudo apt-get -o Acquire::Retries=3 install -y --no-install-recommends \
libpipewire-0.3-dev libwayland-dev pkg-config
- name: Cache cargo registry and build
uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
# NOTE: PipeWire integration tests (tests/pipewire_integration.rs) require
# --features pipewire-test and a live PipeWire session. They are not run here.
# Run manually: cargo test --features pipewire-test
- name: Run unit tests
run: cargo test --verbose
# ─── Build ──────────────────────────────────────────────────────────
build:
name: Build (release)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
- name: Install system dependencies
run: |
sudo apt-get -o Acquire::Retries=3 update
sudo apt-get -o Acquire::Retries=3 install -y --no-install-recommends \
libpipewire-0.3-dev libwayland-dev pkg-config
- name: Cache cargo registry and build
uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
- name: Build release binary
run: cargo build --release
- name: Check binary size
run: |
BINARY="target/release/honkhonk"
SIZE=$(stat --format=%s "$BINARY")
SIZE_MB=$(echo "scale=2; $SIZE / 1048576" | bc)
echo "Binary size: ${SIZE_MB} MB"
# Fail if binary exceeds 30 MB
MAX_BYTES=$((30 * 1048576))
if [ "$SIZE" -gt "$MAX_BYTES" ]; then
echo "::error::Binary size ${SIZE_MB} MB exceeds 30 MB limit"
exit 1
fi
# ─── LOC Check ──────────────────────────────────────────────────────
# Only runs on pull requests — measures LOC delta vs base branch.
loc-check:
name: LOC delta check
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Compute LOC delta
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
# Count added+removed lines, excluding Cargo.lock, test fixtures, and generated files
DELTA=$(git diff --stat "$BASE_SHA"..."$HEAD_SHA" -- \
':!Cargo.lock' \
':!tests/fixtures/**' \
':!src/generated/**' \
| tail -1 \
| grep -oP '\d+ insertion' | grep -oP '^\d+' || echo 0)
DELETIONS=$(git diff --stat "$BASE_SHA"..."$HEAD_SHA" -- \
':!Cargo.lock' \
':!tests/fixtures/**' \
':!src/generated/**' \
| tail -1 \
| grep -oP '\d+ deletion' | grep -oP '^\d+' || echo 0)
TOTAL=$((DELTA + DELETIONS))
echo "LOC delta: +${DELTA} -${DELETIONS} (total churn: ${TOTAL})"
if [ "$TOTAL" -gt 500 ]; then
echo "::warning::LOC delta (${TOTAL}) exceeds 500-line limit. Consider splitting this PR."
fi