Skip to content

Commit e33543c

Browse files
authored
ci(pre-commit): Enforce that the pre-commit checks are run before merge (#9525)
Fix
1 parent 66c96dd commit e33543c

File tree

2 files changed

+44
-3
lines changed

2 files changed

+44
-3
lines changed
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Report Pre-commit Check Status
2+
3+
on:
4+
pull_request_target:
5+
types: [opened, reopened, synchronize, labeled, unlabeled]
6+
7+
permissions:
8+
statuses: write
9+
10+
jobs:
11+
report-run:
12+
name: Check if the PR has run the pre-commit checks
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Report pending
16+
uses: conda/actions/[email protected]
17+
with:
18+
context: "Pre-commit checks"
19+
state: pending
20+
description: The pre-commit checks need to be successful before merging
21+
22+
- name: Wait for pre-commit checks to complete
23+
uses: lucasssvaz/wait-on-workflow@v1
24+
if: |
25+
contains(github.event.pull_request.labels.*.name, 'Status: Pending Merge')
26+
id: wait-on-workflow
27+
with:
28+
timeout: 10
29+
interval: 30
30+
workflow: pre-commit.yml
31+
sha: ${{ github.event.pull_request.head.sha || github.sha }}
32+
33+
- name: Report success
34+
uses: conda/actions/[email protected]
35+
if: |
36+
contains(github.event.pull_request.labels.*.name, 'Status: Pending Merge') &&
37+
steps.wait-on-workflow.outputs.conclusion == 'success'
38+
with:
39+
context: "Pre-commit checks"
40+
state: success
41+
description: All pre-commit checks passed

.github/workflows/pre-commit.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
name: Pre-commit check
1+
name: Pre-commit hooks
22

33
on:
44
pull_request:
5-
types: [opened, reopened, synchronize, labeled]
5+
types: [opened, reopened, synchronize, labeled, unlabeled]
66

77
jobs:
88
lint:
99
if: |
1010
contains(github.event.pull_request.labels.*.name, 'Status: Pending Merge')
11-
name: Checking if any fixes are needed
11+
name: Check if fixes are needed
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Checkout latest commit

0 commit comments

Comments
 (0)