Skip to content

Commit 7b5532b

Browse files
committed
Fix pre-commit workflow for push events
1 parent 2e3c912 commit 7b5532b

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

.github/workflows/main.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@ concurrency:
1616
!startsWith(github.ref, 'refs/heads/gh-readonly-queue') }}
1717
1818
jobs:
19-
cpp-lint:
20-
uses: ./.github/workflows/cpp-lint.yml
19+
pre-commit:
20+
uses: ./.github/workflows/pre-commit.yml
2121
ubuntu:
2222
needs:
23-
- cpp-lint
23+
- pre-commit
2424
uses: ./.github/workflows/ubuntu.yml
2525
mac:
2626
needs:
27-
- cpp-lint
27+
- pre-commit
2828
uses: ./.github/workflows/mac.yml
2929
windows:
3030
needs:
31-
- cpp-lint
31+
- pre-commit
3232
uses: ./.github/workflows/windows.yml
3333
perf:
3434
needs:

.github/workflows/pre-commit.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: Pre-commit checks
33
on:
44
push:
55
pull_request:
6+
workflow_call:
67

78
jobs:
89
pre-commit:
@@ -23,5 +24,6 @@ jobs:
2324
python3 -m pip install -r requirements.txt
2425
- name: Run pre-commit checks
2526
run: |
26-
git fetch origin ${{ github.base_ref }}:${{ github.base_ref }}
27-
pre-commit run --from-ref ${{ github.base_ref }} --to-ref HEAD
27+
FROM_REF="${{ github.base_ref || 'HEAD~1' }}"
28+
git fetch origin $FROM_REF:$FROM_REF || true
29+
pre-commit run --from-ref $FROM_REF --to-ref HEAD

0 commit comments

Comments
 (0)