Skip to content

Commit f738c98

Browse files
committed
merge changes
2 parents 72dc72b + 35843f4 commit f738c98

16 files changed

Lines changed: 1296 additions & 20 deletions

File tree

.github/workflows/ci.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
on: [push, pull_request]
2+
3+
name: Basic CI
4+
5+
env:
6+
CARGO_TERM_COLOR: always
7+
8+
permissions:
9+
contents: read
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
14+
15+
jobs:
16+
check:
17+
name: cargo check
18+
runs-on: ${{ matrix.os }}
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
os: [ubuntu-latest, macOS-latest]
23+
steps:
24+
- uses: actions/checkout@v6
25+
- uses: dtolnay/rust-toolchain@nightly
26+
- uses: Swatinem/rust-cache@v2
27+
- run: cargo check --workspace
28+
29+
build:
30+
name: cargo build
31+
runs-on: ${{ matrix.os }}
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
os: [ubuntu-latest, macOS-latest]
36+
steps:
37+
- uses: actions/checkout@v6
38+
- uses: dtolnay/rust-toolchain@nightly
39+
- uses: Swatinem/rust-cache@v2
40+
- run: cargo build --workspace
41+
42+
test:
43+
name: cargo test
44+
runs-on: ${{ matrix.os }}
45+
strategy:
46+
fail-fast: false
47+
matrix:
48+
os: [ubuntu-latest, macOS-latest]
49+
steps:
50+
- uses: actions/checkout@v6
51+
- uses: dtolnay/rust-toolchain@nightly
52+
- uses: Swatinem/rust-cache@v2
53+
- run: cargo test --workspace

.github/workflows/code-quality.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Code Quality
2+
3+
# spell-checker:ignore Swatinem dtolnay sccache rustfmt
4+
5+
on:
6+
pull_request:
7+
push:
8+
branches:
9+
- main
10+
11+
env:
12+
STYLE_FAIL_ON_FAULT: true
13+
14+
permissions:
15+
contents: read
16+
17+
concurrency:
18+
group: ${{ github.workflow }}-${{ github.ref }}
19+
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
20+
21+
jobs:
22+
fmt:
23+
name: cargo fmt --all -- --check
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v6
27+
- uses: dtolnay/rust-toolchain@nightly
28+
with:
29+
components: rustfmt
30+
- run: cargo fmt --all -- --check
31+
32+
clippy:
33+
name: cargo clippy
34+
runs-on: ${{ matrix.job.os }}
35+
env:
36+
SCCACHE_GHA_ENABLED: "true"
37+
RUSTC_WRAPPER: "sccache"
38+
strategy:
39+
fail-fast: false
40+
matrix:
41+
job:
42+
- { os: ubuntu-latest }
43+
- { os: macos-latest }
44+
steps:
45+
- uses: actions/checkout@v6
46+
- uses: dtolnay/rust-toolchain@nightly
47+
with:
48+
components: clippy
49+
- uses: Swatinem/rust-cache@v2
50+
- name: Run sccache-cache
51+
uses: mozilla-actions/sccache-action@v0.0.10
52+
- name: Initialize workflow variables
53+
id: vars
54+
shell: bash
55+
run: |
56+
## VARs setup
57+
outputs() { step_id="${{ github.action }}"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo "${var}=${!var}" >> $GITHUB_OUTPUT; done; }
58+
# failure mode
59+
unset FAIL_ON_FAULT ; case '${{ env.STYLE_FAIL_ON_FAULT }}' in
60+
''|0|f|false|n|no|off) FAULT_TYPE=warning ;;
61+
*) FAIL_ON_FAULT=true ; FAULT_TYPE=error ;;
62+
esac;
63+
outputs FAIL_ON_FAULT FAULT_TYPE
64+
- name: "`cargo clippy` lint testing"
65+
shell: bash
66+
run: |
67+
## `cargo clippy` lint testing
68+
unset fault
69+
fault_type="${{ steps.vars.outputs.FAULT_TYPE }}"
70+
fault_prefix=$(echo "$fault_type" | tr '[:lower:]' '[:upper:]')
71+
S=$(cargo clippy --workspace -- -D warnings 2>&1) && printf "%s\n" "$S" || { printf "%s\n" "$S" ; printf "%s" "$S" | sed -E -n -e '/^error:/{' -e "N; s/^error:[[:space:]]+(.*)\\n[[:space:]]+-->[[:space:]]+(.*):([0-9]+):([0-9]+).*$/::${fault_type} file=\2,line=\3,col=\4::${fault_prefix}: \`cargo clippy\`: \1 (file:'\2', line:\3)/p;" -e '}' ; fault=true ; }
72+
if [ -n "${{ steps.vars.outputs.FAIL_ON_FAULT }}" ] && [ -n "$fault" ]; then exit 1 ; fi

.pre-commit-config.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
exclude: ^tests/fixtures/
4+
repos:
5+
- repo: https://github.com/pre-commit/pre-commit-hooks
6+
rev: v6.0.0
7+
hooks:
8+
- id: check-added-large-files
9+
- id: check-executables-have-shebangs
10+
- id: check-json
11+
exclude: '\.vscode/(cSpell|extensions)\.json' # cSpell.json and extensions.json use comments
12+
- id: check-shebang-scripts-are-executable
13+
exclude: '.+\.rs' # would be triggered by #![some_attribute]
14+
- id: check-symlinks
15+
- id: check-toml
16+
- id: check-yaml
17+
args: [ --allow-multiple-documents ]
18+
- id: destroyed-symlinks
19+
- id: end-of-file-fixer
20+
- id: mixed-line-ending
21+
args: [ --fix=lf ]
22+
- id: trailing-whitespace
23+
24+
- repo: local
25+
hooks:
26+
- id: rust-linting
27+
name: Rust linting
28+
description: Run cargo fmt on files included in the commit.
29+
entry: cargo +nightly fmt --
30+
pass_filenames: true
31+
types: [file, rust]
32+
language: system
33+
- id: rust-clippy
34+
name: Rust clippy
35+
description: Run cargo clippy on files included in the commit.
36+
entry: cargo +nightly clippy --workspace --all-targets --all-features -- -D warnings
37+
pass_filenames: false
38+
types: [file, rust]
39+
language: system
40+
- id: cspell
41+
name: Code spell checker (cspell)
42+
description: Run cspell to check for spelling errors (if available).
43+
entry: bash -c 'if command -v cspell >/dev/null 2>&1; then cspell --no-must-find-files -- "$@"; else echo "cspell not found, skipping spell check"; exit 0; fi' --
44+
pass_filenames: true
45+
language: system
46+
47+
ci:
48+
skip: [rust-linting, rust-clippy, cargo-lock-check, cspell]

0 commit comments

Comments
 (0)