Skip to content

Commit ea13dd8

Browse files
Add cargo-husky pre-commit hook
1 parent 837ba00 commit ea13dd8

File tree

6 files changed

+364
-99
lines changed

6 files changed

+364
-99
lines changed

.cargo-husky/hooks/pre-commit

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
cargo install --git https://github.com/facet-rs/facet-dev
2+
facet-dev generate

.github/workflows/test.yml

Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
merge_group:
9+
10+
jobs:
11+
test:
12+
runs-on: depot-ubuntu-24.04-32
13+
14+
container:
15+
image: ghcr.io/facet-rs/facet-ci:latest-amd64
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- uses: Swatinem/rust-cache@v2
20+
21+
- name: ✨ Run tests
22+
shell: bash
23+
run: |
24+
just test-ci
25+
26+
nostd:
27+
runs-on: depot-ubuntu-24.04-32
28+
29+
container:
30+
image: ghcr.io/facet-rs/facet-ci:latest-amd64
31+
steps:
32+
- uses: actions/checkout@v4
33+
34+
- uses: Swatinem/rust-cache@v2
35+
36+
- name: ✨ Run nostd tests
37+
shell: bash
38+
run: |
39+
just nostd-ci
40+
41+
doc-tests:
42+
runs-on: depot-ubuntu-24.04-32
43+
44+
container:
45+
image: ghcr.io/facet-rs/facet-ci:latest-amd64
46+
steps:
47+
- uses: actions/checkout@v4
48+
49+
- uses: Swatinem/rust-cache@v2
50+
51+
- name: ✨ Run doc tests
52+
shell: bash
53+
run: |
54+
just doc-tests-ci
55+
56+
miri:
57+
runs-on: depot-ubuntu-24.04-64
58+
59+
container:
60+
image: ghcr.io/facet-rs/facet-ci:latest-miri-amd64
61+
steps:
62+
- uses: actions/checkout@v4
63+
64+
- uses: Swatinem/rust-cache@v2
65+
66+
- name: ✨ Run miri
67+
shell: bash
68+
run: |
69+
export CI=true
70+
just miri
71+
72+
msrv:
73+
runs-on: depot-ubuntu-24.04-32
74+
75+
container:
76+
image: ghcr.io/facet-rs/facet-ci:latest-amd64
77+
steps:
78+
- uses: actions/checkout@v4
79+
80+
- uses: Swatinem/rust-cache@v2
81+
82+
- uses: taiki-e/install-action@cargo-hack
83+
84+
- name: ✨ Check MSRV
85+
shell: bash
86+
run: |
87+
just msrv
88+
89+
minimal-versions:
90+
runs-on: depot-ubuntu-24.04-32
91+
92+
container:
93+
image: ghcr.io/facet-rs/facet-ci:latest-amd64
94+
steps:
95+
- uses: actions/checkout@v4
96+
97+
- uses: Swatinem/rust-cache@v2
98+
99+
- name: ✨ Check minimal versions
100+
shell: bash
101+
run: |
102+
# Install nightly for minimal-versions feature
103+
rustup toolchain install nightly
104+
# Generate lockfile with minimal versions
105+
cargo +nightly generate-lockfile -Z minimal-versions
106+
# Check with stable using minimal versions
107+
cargo check --workspace --all-features --locked --keep-going
108+
109+
docs:
110+
runs-on: depot-ubuntu-24.04-32
111+
112+
container:
113+
image: ghcr.io/facet-rs/facet-ci:latest-amd64
114+
steps:
115+
- uses: actions/checkout@v4
116+
117+
- uses: Swatinem/rust-cache@v2
118+
119+
- name: ✨ Check documentation
120+
shell: bash
121+
env:
122+
RUSTDOCFLAGS: -D warnings
123+
run: |
124+
just docs
125+
126+
lockfile:
127+
runs-on: depot-ubuntu-24.04-4
128+
129+
container:
130+
image: ghcr.io/facet-rs/facet-ci:latest-amd64
131+
steps:
132+
- uses: actions/checkout@v4
133+
134+
- uses: Swatinem/rust-cache@v2
135+
136+
- name: ✨ Check lockfile is updated
137+
shell: bash
138+
run: |
139+
cargo update --workspace --locked
140+
141+
clippy:
142+
runs-on: depot-ubuntu-24.04-16
143+
144+
container:
145+
image: ghcr.io/facet-rs/facet-ci:latest-amd64
146+
permissions:
147+
security-events: write # to upload sarif results
148+
steps:
149+
- uses: actions/checkout@v4
150+
151+
- uses: Swatinem/rust-cache@v2
152+
153+
- name: Install SARIF tools
154+
shell: bash
155+
run: |
156+
cargo install clippy-sarif --locked
157+
cargo install sarif-fmt --locked
158+
159+
- name: ✨ Run clippy with SARIF output
160+
shell: bash
161+
run: |
162+
cargo clippy --workspace --all-features --all-targets --message-format=json | clippy-sarif | tee clippy-results.sarif | sarif-fmt
163+
continue-on-error: true
164+
165+
- name: Upload SARIF results
166+
uses: github/codeql-action/upload-sarif@v3
167+
with:
168+
sarif_file: clippy-results.sarif
169+
wait-for-processing: true
170+
171+
- name: Report status
172+
shell: bash
173+
run: |
174+
cargo clippy --workspace --all-features --all-targets --keep-going -- -D warnings --allow deprecated
175+
176+
test-macos:
177+
runs-on: depot-macos-latest
178+
steps:
179+
- uses: actions/checkout@v4
180+
181+
- uses: Swatinem/rust-cache@v2
182+
183+
- uses: taiki-e/install-action@v2
184+
with:
185+
tool: cargo-nextest
186+
187+
- name: ✨ Run nextest tests (macOS)
188+
shell: bash
189+
run: |
190+
cargo nextest run --all-features
191+
192+
test-windows:
193+
runs-on: depot-windows-2022
194+
steps:
195+
- uses: actions/checkout@v4
196+
197+
- uses: taiki-e/install-action@v2
198+
with:
199+
tool: cargo-nextest
200+
201+
- name: ✨ Run nextest tests (Windows)
202+
shell: bash
203+
run: |
204+
cargo nextest run --all-features
205+
206+
coverage:
207+
runs-on: depot-ubuntu-24.04-32
208+
209+
container:
210+
image: ghcr.io/facet-rs/facet-ci:latest-miri-amd64
211+
steps:
212+
- uses: actions/checkout@v4
213+
214+
- uses: Swatinem/rust-cache@v2
215+
216+
- name: ✨ Gather coverage
217+
shell: bash
218+
run: |
219+
cargo llvm-cov --no-report nextest
220+
cargo llvm-cov --no-report --doc
221+
mkdir coverage
222+
cargo llvm-cov report --doctests --lcov --output-path coverage/lcov.info
223+
224+
- name: ✨ Publish to Coveralls
225+
uses: coverallsapp/github-action@master
226+
with:
227+
github-token: ${{ secrets.GITHUB_TOKEN }}

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ categories = ["development-tools"]
1111
fs-err = "3.1.0"
1212
log = { version = "0.4.27", features = ["std"] }
1313
owo-colors = "4.2.1"
14+
15+
[dev-dependencies]
16+
cargo-husky = { version = "1.5.0", default-features = false, features = ["user-hooks"] }

src/.cargo-husky/hooks/pre-commit

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
cargo install --git https://github.com/facet-rs/facet-dev
2+
facet-dev generate

0 commit comments

Comments
 (0)