Skip to content

Commit 0d88e65

Browse files
committed
fix(ci): bump to 0.3.2, add environment for secrets, fix yamllint
- Bump Cargo.toml version to 0.3.2 (was still 0.3.1) - Add environment: copilot to jobs using CARGO_REGISTRY_TOKEN, HOMEBREW_TAP_TOKEN, and CODECOV_TOKEN secrets - Fix all yamllint warnings in ci.yml and coverage.yml: add document start, quote truthy on, yamllint disable-line for SHA-pinned uses, remove trailing spaces, wrap long lines - Move expression interpolations to env vars in coverage.yml to prevent command injection
1 parent 28079d1 commit 0d88e65

File tree

4 files changed

+98
-44
lines changed

4 files changed

+98
-44
lines changed

.github/workflows/ci.yml

Lines changed: 48 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
---
12
name: CI
23

3-
on:
4+
"on":
45
push:
56
branches: [main, master]
67
pull_request:
@@ -25,9 +26,11 @@ jobs:
2526
runs-on: ubuntu-latest
2627
steps:
2728
- name: Checkout repository
28-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
29+
# yamllint disable-line rule:line-length
30+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2931

3032
- name: Install Rust toolchain
33+
# yamllint disable-line rule:line-length
3134
uses: dtolnay/rust-toolchain@f7ccc83f9ed1e5b9c81d8a67d7ad1a747e22a561 # master
3235
with:
3336
toolchain: stable
@@ -41,16 +44,19 @@ jobs:
4144
runs-on: ubuntu-latest
4245
steps:
4346
- name: Checkout repository
44-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
47+
# yamllint disable-line rule:line-length
48+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
4549

4650
- name: Install Rust toolchain
51+
# yamllint disable-line rule:line-length
4752
uses: dtolnay/rust-toolchain@f7ccc83f9ed1e5b9c81d8a67d7ad1a747e22a561 # master
4853
with:
4954
toolchain: stable
5055
components: clippy
5156

5257
- name: Cache cargo registry
53-
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
58+
# yamllint disable-line rule:line-length
59+
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
5460
with:
5561
path: |
5662
~/.cargo/registry
@@ -61,7 +67,9 @@ jobs:
6167
${{ runner.os }}-cargo-clippy-
6268
6369
- name: Run clippy
64-
run: cargo clippy --all-targets --all-features -- -D warnings
70+
run: >-
71+
cargo clippy --all-targets --all-features
72+
-- -D warnings
6573
6674
test:
6775
name: Test (${{ matrix.os }})
@@ -72,15 +80,18 @@ jobs:
7280
os: [ubuntu-latest, macos-latest, windows-latest]
7381
steps:
7482
- name: Checkout repository
75-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
83+
# yamllint disable-line rule:line-length
84+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
7685

7786
- name: Install Rust toolchain
87+
# yamllint disable-line rule:line-length
7888
uses: dtolnay/rust-toolchain@f7ccc83f9ed1e5b9c81d8a67d7ad1a747e22a561 # master
7989
with:
8090
toolchain: stable
8191

8292
- name: Cache cargo registry
83-
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
93+
# yamllint disable-line rule:line-length
94+
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
8495
with:
8596
path: |
8697
~/.cargo/registry
@@ -100,15 +111,18 @@ jobs:
100111
RUSTDOCFLAGS: "-D warnings"
101112
steps:
102113
- name: Checkout repository
103-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
114+
# yamllint disable-line rule:line-length
115+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
104116

105117
- name: Install Rust toolchain
118+
# yamllint disable-line rule:line-length
106119
uses: dtolnay/rust-toolchain@f7ccc83f9ed1e5b9c81d8a67d7ad1a747e22a561 # master
107120
with:
108121
toolchain: stable
109122

110123
- name: Cache cargo registry
111-
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
124+
# yamllint disable-line rule:line-length
125+
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
112126
with:
113127
path: |
114128
~/.cargo/registry
@@ -126,10 +140,12 @@ jobs:
126140
runs-on: ubuntu-latest
127141
steps:
128142
- name: Checkout repository
129-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
143+
# yamllint disable-line rule:line-length
144+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
130145

131146
- name: Install cargo-deny
132-
uses: taiki-e/install-action@f176c07a0a40cbfdd08ee9aa8bf1655701d11e69 # v2.67.25
147+
# yamllint disable-line rule:line-length
148+
uses: taiki-e/install-action@f176c07a0a40cbfdd08ee9aa8bf1655701d11e69 # v2.67.25
133149
with:
134150
tool: cargo-deny
135151

@@ -141,15 +157,18 @@ jobs:
141157
runs-on: ubuntu-latest
142158
steps:
143159
- name: Checkout repository
144-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
160+
# yamllint disable-line rule:line-length
161+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
145162

146163
- name: Install Rust toolchain
164+
# yamllint disable-line rule:line-length
147165
uses: dtolnay/rust-toolchain@f7ccc83f9ed1e5b9c81d8a67d7ad1a747e22a561 # master
148166
with:
149167
toolchain: "1.92"
150168

151169
- name: Cache cargo registry
152-
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
170+
# yamllint disable-line rule:line-length
171+
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
153172
with:
154173
path: |
155174
~/.cargo/registry
@@ -165,23 +184,28 @@ jobs:
165184
coverage:
166185
name: Coverage
167186
runs-on: ubuntu-latest
187+
environment: copilot
168188
steps:
169189
- name: Checkout repository
170-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
190+
# yamllint disable-line rule:line-length
191+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
171192

172193
- name: Install Rust toolchain
194+
# yamllint disable-line rule:line-length
173195
uses: dtolnay/rust-toolchain@f7ccc83f9ed1e5b9c81d8a67d7ad1a747e22a561 # master
174196
with:
175197
toolchain: stable
176198
components: llvm-tools-preview
177199

178200
- name: Install cargo-llvm-cov
179-
uses: taiki-e/install-action@f176c07a0a40cbfdd08ee9aa8bf1655701d11e69 # v2.67.25
201+
# yamllint disable-line rule:line-length
202+
uses: taiki-e/install-action@f176c07a0a40cbfdd08ee9aa8bf1655701d11e69 # v2.67.25
180203
with:
181204
tool: cargo-llvm-cov
182205

183206
- name: Cache cargo registry
184-
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
207+
# yamllint disable-line rule:line-length
208+
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
185209
with:
186210
path: |
187211
~/.cargo/registry
@@ -192,13 +216,18 @@ jobs:
192216
${{ runner.os }}-cargo-cov-
193217
194218
- name: Generate coverage report
195-
run: cargo llvm-cov --all-features --lcov --output-path lcov.info
219+
run: >-
220+
cargo llvm-cov --all-features
221+
--lcov --output-path lcov.info
196222
197223
- name: Enforce 90% line coverage
198-
run: cargo llvm-cov --all-features --fail-under-lines 90
224+
run: >-
225+
cargo llvm-cov --all-features
226+
--fail-under-lines 90
199227
200228
- name: Upload coverage to Codecov
201-
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
229+
# yamllint disable-line rule:line-length
230+
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
202231
with:
203232
files: lcov.info
204233
fail_ci_if_error: false

.github/workflows/coverage.yml

Lines changed: 48 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
---
12
name: Code Coverage
23

3-
on:
4+
"on":
45
pull_request:
56
# schedule:
67
# - cron: '0 0 * * 1' # Weekly on Monday
@@ -14,68 +15,87 @@ jobs:
1415
coverage:
1516
name: Generate Coverage Report
1617
runs-on: ubuntu-latest
18+
environment: copilot
1719
timeout-minutes: 30
18-
20+
1921
steps:
2022
- name: Checkout code
21-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
23+
# yamllint disable-line rule:line-length
24+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2225

2326
- name: Setup Rust
24-
uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # master
27+
# yamllint disable-line rule:line-length
28+
uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # master
2529
with:
2630
toolchain: stable
2731
components: llvm-tools-preview
2832

2933
- name: Cache dependencies
30-
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
34+
# yamllint disable-line rule:line-length
35+
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
3136
with:
3237
path: |
3338
~/.cargo/registry
3439
~/.cargo/git
3540
target
41+
# yamllint disable-line rule:line-length
3642
key: ${{ runner.os }}-cargo-coverage-${{ hashFiles('**/Cargo.lock') }}
3743

3844
- name: Install cargo-llvm-cov
39-
uses: taiki-e/install-action@f176c07a0a40cbfdd08ee9aa8bf1655701d11e69 # v2.67.25
45+
# yamllint disable-line rule:line-length
46+
uses: taiki-e/install-action@f176c07a0a40cbfdd08ee9aa8bf1655701d11e69 # v2.67.25
4047
with:
4148
tool: cargo-llvm-cov@0.6.14
4249

4350
- name: Generate coverage
4451
run: |
45-
cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info
46-
cargo llvm-cov --all-features --workspace --html --output-dir coverage-html
47-
cargo llvm-cov --all-features --workspace --json --output-path coverage.json
52+
cargo llvm-cov --all-features --workspace \
53+
--lcov --output-path lcov.info
54+
cargo llvm-cov --all-features --workspace \
55+
--html --output-dir coverage-html
56+
cargo llvm-cov --all-features --workspace \
57+
--json --output-path coverage.json
4858
4959
- name: Parse coverage percentage
5060
id: coverage
5161
run: |
52-
COVERAGE=$(cargo llvm-cov --all-features --workspace --summary-only | grep -oP 'TOTAL\s+\d+\.\d+%' | grep -oP '\d+\.\d+' || echo "0")
53-
echo "percentage=$COVERAGE" >> $GITHUB_OUTPUT
62+
COVERAGE=$(cargo llvm-cov \
63+
--all-features --workspace --summary-only \
64+
| grep -oP 'TOTAL\s+\d+\.\d+%' \
65+
| grep -oP '\d+\.\d+' || echo "0")
66+
echo "percentage=$COVERAGE" >> "$GITHUB_OUTPUT"
5467
echo "Coverage: ${COVERAGE}%"
5568
5669
- name: Generate coverage report
70+
env:
71+
PERCENTAGE: ${{ steps.coverage.outputs.percentage }}
5772
run: |
5873
echo "# Code Coverage Report" > coverage-report.md
5974
echo "" >> coverage-report.md
60-
echo "**Overall Coverage:** ${{ steps.coverage.outputs.percentage }}%" >> coverage-report.md
75+
echo "**Overall Coverage:** ${PERCENTAGE}%" \
76+
>> coverage-report.md
6177
echo "" >> coverage-report.md
6278
echo "## Summary" >> coverage-report.md
6379
echo "" >> coverage-report.md
6480
echo "\`\`\`" >> coverage-report.md
65-
cargo llvm-cov --all-features --workspace --summary-only >> coverage-report.md
81+
cargo llvm-cov --all-features --workspace \
82+
--summary-only >> coverage-report.md
6683
echo "\`\`\`" >> coverage-report.md
6784
echo "" >> coverage-report.md
68-
echo "Full HTML report available in CI artifacts." >> coverage-report.md
85+
echo "Full HTML report available in CI artifacts." \
86+
>> coverage-report.md
6987
7088
- name: Upload coverage to Codecov
71-
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.1.2
89+
# yamllint disable-line rule:line-length
90+
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.1.2
7291
with:
7392
files: lcov.info
7493
fail_ci_if_error: false
7594
token: ${{ secrets.CODECOV_TOKEN }}
7695

7796
- name: Upload coverage artifacts
78-
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
97+
# yamllint disable-line rule:line-length
98+
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
7999
with:
80100
name: coverage-report
81101
path: |
@@ -87,12 +107,14 @@ jobs:
87107

88108
- name: Comment PR with coverage
89109
if: github.event_name == 'pull_request'
90-
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
110+
# yamllint disable-line rule:line-length
111+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
91112
with:
92113
script: |
93114
const fs = require('fs');
94-
const report = fs.readFileSync('coverage-report.md', 'utf8');
95-
115+
const report = fs.readFileSync(
116+
'coverage-report.md', 'utf8'
117+
);
96118
github.rest.issues.createComment({
97119
issue_number: context.issue.number,
98120
owner: context.repo.owner,
@@ -101,13 +123,14 @@ jobs:
101123
});
102124
103125
- name: Check coverage threshold
126+
env:
127+
COVERAGE: ${{ steps.coverage.outputs.percentage }}
104128
run: |
105-
COVERAGE=${{ steps.coverage.outputs.percentage }}
106129
THRESHOLD=80
107-
108-
if (( $(echo "$COVERAGE < $THRESHOLD" | bc -l) )); then
109-
echo "⚠️ Coverage ${COVERAGE}% is below threshold ${THRESHOLD}%"
110-
echo "Consider adding more tests to improve coverage."
130+
if (( $(echo "$COVERAGE < $THRESHOLD" \
131+
| bc -l) )); then
132+
echo "Coverage ${COVERAGE}% is below ${THRESHOLD}%"
133+
echo "Consider adding more tests."
111134
else
112-
echo "Coverage ${COVERAGE}% meets threshold ${THRESHOLD}%"
135+
echo "Coverage ${COVERAGE}% meets ${THRESHOLD}%"
113136
fi

.github/workflows/package-homebrew.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
homebrew:
2222
name: Update Homebrew Formula
2323
runs-on: macos-latest
24+
environment: copilot
2425

2526
steps:
2627
- name: Checkout homebrew tap

.github/workflows/publish.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
publish:
1818
name: Publish to crates.io
1919
runs-on: ubuntu-latest
20+
environment: copilot
2021
steps:
2122
- name: Checkout repository
2223
# yamllint disable-line rule:line-length

0 commit comments

Comments
 (0)