forked from dmlc/xgboost
-
Notifications
You must be signed in to change notification settings - Fork 1
36 lines (31 loc) · 1.03 KB
/
pre-commit.yml
File metadata and controls
36 lines (31 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
name: XGBoost CI (Pre-commit)
on: [push, pull_request]
permissions:
contents: read
jobs:
pre-commit:
name: Run pre-commit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install pre-commit
run: python -m pip install pre-commit
- name: Run pre-commit on updated files
shell: bash
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
FROM_REF="${{ github.event.pull_request.base.sha }}"
TO_REF="${{ github.event.pull_request.head.sha }}"
else
FROM_REF="${{ github.event.before }}"
TO_REF="${{ github.sha }}"
fi
if [ "${FROM_REF}" = "0000000000000000000000000000000000000000" ]; then
FROM_REF="$(git hash-object -t tree /dev/null)"
fi
pre-commit run --from-ref "${FROM_REF}" --to-ref "${TO_REF}" --show-diff-on-failure