Skip to content

Commit 25ca560

Browse files
gibbz00seffradev
authored andcommitted
ci: copy over pre-commit config and github action from basic things
- Adds `cargo-udeps`, `typos`, `cocogitto` and `lychee` integration - Respective pre-commit steps are also checked for in CI
1 parent 3822ec3 commit 25ca560

File tree

6 files changed

+212
-32
lines changed

6 files changed

+212
-32
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Build Setup
2+
description: Install build dependencies and levarage caching.
3+
runs:
4+
using: composite
5+
steps:
6+
- name: Leverage caching
7+
uses: Swatinem/rust-cache@v2
8+
with:
9+
key: x86_64-unknown-linux-gnu
10+
- name: Install toolchain - nightly
11+
uses: dtolnay/rust-toolchain@stable
12+
with:
13+
toolchain: nightly
14+
components: rustfmt, clippy, rust-docs

.github/workflows/ci.yaml

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
name: CI
2+
on:
3+
push:
4+
branches: [main]
5+
pull_request:
6+
branches: [main]
7+
env:
8+
CARGO_TERM_COLOR: always
9+
RUST_BACKTRACE: full
10+
jobs:
11+
pre-commit:
12+
name: Validate `pre-commit` Hooks
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout sources
16+
uses: actions/checkout@v3
17+
- name: Get python
18+
uses: actions/setup-python@v3
19+
- name: Run pre-commit check
20+
uses: pre-commit/[email protected]
21+
with:
22+
extra_args: run --all-files --hook-stage manual
23+
conventional-commits-check:
24+
name: Conventional Commit Checking
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@main
28+
with:
29+
fetch-depth: 0
30+
- name: Assert conventional commit usage
31+
uses: oknozor/cocogitto-action@v3
32+
spell-check:
33+
name: Spell Checking
34+
runs-on: ubuntu-latest
35+
steps:
36+
- name: Checkout sources
37+
uses: actions/checkout@v4
38+
- name: typos
39+
uses: crate-ci/typos@master
40+
broken-url-check:
41+
name: Broken URL Checking
42+
runs-on: ubuntu-latest
43+
steps:
44+
- name: Checkout sources
45+
uses: actions/checkout@v4
46+
- name: Run lychee
47+
uses: lycheeverse/[email protected]
48+
with:
49+
fail: true
50+
toml-lint-check:
51+
name: TOML Lint Checking
52+
runs-on: ubuntu-latest
53+
container:
54+
image: tamasfe/taplo:0.8.0
55+
steps:
56+
- name: Checkout sources
57+
uses: actions/checkout@v4
58+
- name: taplo lint
59+
run: taplo lint
60+
toml-format-check:
61+
name: TOML Format Checking
62+
runs-on: ubuntu-latest
63+
container:
64+
image: tamasfe/taplo:0.8.0
65+
steps:
66+
- name: Checkout sources
67+
uses: actions/checkout@v4
68+
- name: taplo fmt
69+
run: taplo fmt --check --diff
70+
rust-format-check:
71+
name: Rust Code Format Checking
72+
runs-on: ubuntu-latest
73+
steps:
74+
- name: Checkout sources
75+
uses: actions/checkout@v4
76+
- name: Build setup
77+
uses: ./.github/actions/build-setup
78+
- name: cargo fmt
79+
run: cargo fmt --all -- --check
80+
rust-lint-check:
81+
name: Lint Checking
82+
runs-on: ubuntu-latest
83+
steps:
84+
- name: Checkout sources
85+
uses: actions/checkout@v4
86+
- name: Build setup
87+
uses: ./.github/actions/build-setup
88+
- name: Run clippy
89+
run: cargo clippy --all-features --tests -- -D warnings
90+
rust-docs-check:
91+
name: Developer Documentation Validation
92+
runs-on: ubuntu-latest
93+
steps:
94+
- name: Checkout sources
95+
uses: actions/checkout@v4
96+
- name: Build setup
97+
uses: ./.github/actions/build-setup
98+
- name: Run cargo doc
99+
env:
100+
RUSTDOCFLAGS: "-D warnings"
101+
run: cargo doc --no-deps --all-features
102+
audit:
103+
name: Dependency Auditing
104+
runs-on: ubuntu-latest
105+
steps:
106+
- uses: actions/checkout@v4
107+
- uses: taiki-e/install-action@cargo-deny
108+
- name: Vulnerability scanning
109+
run: cargo deny check advisories
110+
unused:
111+
name: Unused Dependencies Checking
112+
runs-on: ubuntu-latest
113+
steps:
114+
- name: Checkout sources
115+
uses: actions/checkout@v4
116+
- name: Build setup
117+
uses: ./.github/actions/build-setup
118+
- name: Run cargo-udeps
119+
uses: aig787/cargo-udeps-action@v1
120+
with:
121+
args: --all-features
122+
rust-test:
123+
name: Execute Tests
124+
runs-on: ubuntu-latest
125+
steps:
126+
- name: Checkout sources
127+
uses: actions/checkout@v4
128+
- name: Build setup
129+
uses: ./.github/actions/build-setup
130+
- name: Run tests
131+
run: cargo test --all-features -- --include-ignored --nocapture
132+
user-docs-check:
133+
name: User Documentation Validation
134+
runs-on: ubuntu-latest
135+
steps:
136+
- name: Checkout sources
137+
uses: actions/checkout@v4
138+
- name: Build setup
139+
uses: ./.github/actions/build-setup
140+
- name: mdBook setup
141+
uses: peaceiris/actions-mdbook@v1
142+
with:
143+
mdbook-version: 'latest'
144+
- name: Run mdbook test
145+
run: mdbook test

.github/workflows/test.yml

Lines changed: 0 additions & 11 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 50 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,51 @@
1+
# manual staged used to selectively run pre-commit jobs which don't have a dedicated CI job.
2+
3+
default_stages: ["pre-commit"]
4+
15
repos:
2-
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.6.0
4-
hooks:
5-
- id: check-yaml
6-
- id: end-of-file-fixer
7-
- id: trailing-whitespace
8-
- repo: https://github.com/FeryET/pre-commit-rust
9-
rev: v1.1.0
10-
hooks:
11-
- id: fmt
12-
- id: cargo-check
13-
- repo: https://github.com/ComPWA/mirrors-taplo
14-
rev: "v0.8.1"
15-
hooks:
16-
- id: taplo
17-
- repo: https://github.com/pre-commit/mirrors-prettier
18-
rev: v2.5.1
19-
hooks:
20-
- id: prettier
21-
files: \.(js|ts|jsx|tsx|css|less|html|json|markdown|md|yaml|yml)$
6+
- repo: local
7+
hooks:
8+
- id: cargo-fmt
9+
name: cargo fmt
10+
language: rust
11+
files: \.rs$
12+
pass_filenames: false
13+
entry: cargo fmt
14+
args: ["--all", "--", "--check"]
15+
- id: cargo-clippy
16+
name: cargo clippy
17+
language: rust
18+
files: \.rs$
19+
pass_filenames: false
20+
entry: cargo clippy
21+
args: ["--all-features", "--tests", "--", "-D", "warnings"]
22+
- id: cargo-doc
23+
name: cargo doc
24+
language: rust
25+
files: \.rs$
26+
pass_filenames: false
27+
entry: sh -c "RUSTDOCFLAGS='-D warnings' cargo doc"
28+
args: ["--no-deps", "--all-features", "--workspace"]
29+
- repo: https://github.com/pre-commit/pre-commit-hooks
30+
rev: v4.6.0
31+
hooks:
32+
- id: check-yaml
33+
stages: ["pre-commit", "manual"]
34+
- id: check-json
35+
stages: ["pre-commit", "manual"]
36+
- id: check-xml
37+
stages: ["pre-commit", "manual"]
38+
- id: check-toml
39+
stages: ["pre-commit", "manual"]
40+
- id: check-merge-conflict
41+
stages: ["pre-commit", "manual"]
42+
- id: check-executables-have-shebangs
43+
stages: ["pre-commit", "manual"]
44+
- id: trailing-whitespace
45+
stages: ["pre-commit", "manual"]
46+
- id: end-of-file-fixer
47+
stages: ["pre-commit", "manual"]
48+
- id: forbid-submodules
49+
stages: ["pre-commit", "manual"]
50+
- id: forbid-new-submodules
51+
stages: ["pre-commit", "manual"]

arirs/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub enum AriError {
2929
ReqwestError(#[from] reqwest::Error),
3030
#[error("Join Error")]
3131
JoinError(#[from] JoinError),
32-
#[error("Unknown error occured: {0}")]
32+
#[error("Unknown error occurred: {0}")]
3333
Unknown(String),
3434
}
3535

typos.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[type.rust]
2+
extend-ignore-identifiers-re = ["exten"]

0 commit comments

Comments
 (0)