Skip to content

Commit de81c9f

Browse files
authored
[CI] Add pre-commit job (learning-process#499)
1 parent 9c4ff82 commit de81c9f

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

.github/workflows/ubuntu.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,32 @@ on:
22
workflow_call:
33

44
jobs:
5+
pre-commit:
6+
runs-on: ubuntu-24.04
7+
steps:
8+
- uses: actions/checkout@v4
9+
with:
10+
submodules: recursive
11+
fetch-depth: 0
12+
- name: Setup environment
13+
run: |
14+
sudo apt-get update
15+
sudo apt-get install --no-install-recommends -y \
16+
gcc-14 g++-14 ninja-build python3-pip clang-format-16
17+
python3 -m pip install -r requirements.txt
18+
- name: Run pre-commit checks
19+
run: |
20+
# For push events, compare with previous commit
21+
if [ "${{ github.event_name }}" = "push" ]; then
22+
pre-commit run --from-ref HEAD~1 --to-ref HEAD
23+
else
24+
# For PRs, compare with base branch
25+
git fetch origin ${{ github.base_ref }}:${{ github.base_ref }}
26+
pre-commit run --from-ref ${{ github.base_ref }} --to-ref HEAD
27+
fi
528
gcc-build:
29+
needs:
30+
- pre-commit
631
runs-on: ${{ matrix.os }}
732
strategy:
833
matrix:
@@ -110,6 +135,8 @@ jobs:
110135
env:
111136
PPC_NUM_PROC: 1
112137
clang-build:
138+
needs:
139+
- pre-commit
113140
runs-on: ${{ matrix.os }}
114141
strategy:
115142
matrix:

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
numpy==2.2.3
22
XlsxWriter==3.2.5
33
PyYAML==6.0.2
4+
pre-commit==3.4.0

0 commit comments

Comments
 (0)