@@ -2,109 +2,110 @@ name: Pre-commit
22
33on :
44 push :
5- branches : [ main ]
5+ branches : [main]
66 pull_request :
7- branches : [ main ]
8- workflow_dispatch : # Allow manual triggering
7+ branches : [main]
8+ workflow_dispatch : # Allow manual triggering
99
1010jobs :
1111 pre-commit :
1212 runs-on : ubuntu-latest
1313 name : Run pre-commit hooks check file lint
1414
1515 steps :
16- - name : Check out the repo
17- uses : actions/checkout@v4
18- with :
19- fetch-depth : 0 # Fetch full history for pre-commit
20-
21- - name : Set up Python
22- uses : actions/setup-python@v5
23- with :
24- python-version : ' 3.11'
25-
26- - name : Set up Go
27- uses : actions/setup-go@v5
28- with :
29- go-version : ' 1.24'
30-
31- - name : Set up Node
32- uses : actions/setup-node@v5
33- with :
34- node-version : 23
35-
36- - name : Set up Rust
37- uses : dtolnay/rust-toolchain@stable
38- with :
39- toolchain : 1.90
40- components : rustfmt, clippy
41-
42- - name : Install system dependencies
43- run : |
44- sudo apt-get update
45- sudo apt-get install -y \
46- make \
47- build-essential \
48- pkg-config
49- npm install -g markdownlint-cli
50- pip install --user yamllint codespell
51- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.5.0
52-
53- - name : Cache Rust dependencies
54- uses : actions/cache@v4
55- with :
56- path : |
57- ~/.cargo/bin/
58- ~/.cargo/registry/index/
59- ~/.cargo/registry/cache/
60- ~/.cargo/git/db/
61- candle-binding/target/
62- key : ${{ runner.os }}-cargo-precommit-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}
63- restore-keys : |
64- ${{ runner.os }}-cargo-precommit-
65-
66- - name : Cache Go dependencies
67- uses : actions/cache@v4
68- with :
69- path : |
70- ~/go/pkg/mod
71- key : ${{ runner.os }}-go-precommit-${{ hashFiles('**/go.sum') }}
72- restore-keys : |
73- ${{ runner.os }}-go-precommit-
74-
75- - name : Cache Node dependencies
76- uses : actions/cache@v4
77- with :
78- path : |
79- ~/.npm
80- key : ${{ runner.os }}-node-precommit-${{ hashFiles('website/package-lock.json') }}
81- restore-keys : |
82- ${{ runner.os }}-node-precommit-
83-
84- - name : Cache pre-commit environments
85- uses : actions/cache@v4
86- with :
87- path : ~/.cache/pre-commit
88- key : ${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
89- restore-keys : |
90- ${{ runner.os }}-precommit-
91-
92- - name : Install pre-commit
93- run : make precommit-install
94-
95- - name : Run Code Spell Check
96- run : make codespell
97-
98- - name : Run pre-commit check
99- run : make precommit-check
100- env :
101- CI : true
102-
103- - name : Show pre-commit results
104- if : failure()
105- run : |
106- echo "::error::Pre-commit hooks failed. Please fix the issues and commit again."
107- echo "To run pre-commit locally:"
108- echo " pip install pre-commit"
109- echo " pre-commit install"
110- echo " pre-commit run --all-files"
16+ - name : Check out the repo
17+ uses : actions/checkout@v4
18+ with :
19+ fetch-depth : 0 # Fetch full history for pre-commit
20+
21+ - name : Set up Python
22+ uses : actions/setup-python@v5
23+ with :
24+ python-version : " 3.11"
25+
26+ - name : Set up Go
27+ uses : actions/setup-go@v5
28+ with :
29+ go-version : " 1.24"
30+
31+ - name : Set up Node
32+ uses : actions/setup-node@v5
33+ with :
34+ node-version : 23
35+
36+ - name : Set up Rust
37+ uses : dtolnay/rust-toolchain@stable
38+ with :
39+ toolchain : 1.90
40+ components : rustfmt, clippy
41+
42+ - name : Install system dependencies
43+ run : |
44+ sudo apt-get update
45+ sudo apt-get install -y \
46+ make \
47+ build-essential \
48+ pkg-config \
49+ shellcheck
50+ npm install -g markdownlint-cli
51+ pip install --user yamllint codespell
52+ curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.5.0
53+
54+ - name : Cache Rust dependencies
55+ uses : actions/cache@v4
56+ with :
57+ path : |
58+ ~/.cargo/bin/
59+ ~/.cargo/registry/index/
60+ ~/.cargo/registry/cache/
61+ ~/.cargo/git/db/
62+ candle-binding/target/
63+ key : ${{ runner.os }}-cargo-precommit-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}
64+ restore-keys : |
65+ ${{ runner.os }}-cargo-precommit-
66+
67+ - name : Cache Go dependencies
68+ uses : actions/cache@v4
69+ with :
70+ path : |
71+ ~/go/pkg/mod
72+ key : ${{ runner.os }}-go-precommit-${{ hashFiles('**/go.sum') }}
73+ restore-keys : |
74+ ${{ runner.os }}-go-precommit-
75+
76+ - name : Cache Node dependencies
77+ uses : actions/cache@v4
78+ with :
79+ path : |
80+ ~/.npm
81+ key : ${{ runner.os }}-node-precommit-${{ hashFiles('website/package-lock.json') }}
82+ restore-keys : |
83+ ${{ runner.os }}-node-precommit-
84+
85+ - name : Cache pre-commit environments
86+ uses : actions/cache@v4
87+ with :
88+ path : ~/.cache/pre-commit
89+ key : ${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
90+ restore-keys : |
91+ ${{ runner.os }}-precommit-
92+
93+ - name : Install pre-commit
94+ run : make precommit-install
95+
96+ - name : Run Code Spell Check
97+ run : make codespell
98+
99+ - name : Run pre-commit check
100+ run : make precommit-check
101+ env :
102+ CI : true
103+
104+ - name : Show pre-commit results
105+ if : failure()
106+ run : |
107+ echo "::error::Pre-commit hooks failed. Please fix the issues and commit again."
108+ echo "To run pre-commit locally:"
109+ echo " pip install pre-commit"
110+ echo " pre-commit install"
111+ echo " pre-commit run --all-files"
0 commit comments