Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(pre-commit): Enforce that the pre-commit checks are run before merge #9525

Merged
merged 2 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/pre-commit-status.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Report Pre-commit Check Status

on:
pull_request_target:
types: [opened, reopened, synchronize, labeled, unlabeled]

permissions:
statuses: write

jobs:
report-run:
name: Check if the PR has run the pre-commit checks
runs-on: ubuntu-latest
steps:
- name: Report pending
uses: conda/actions/set-commit-status@v24.2.0
with:
context: "Pre-commit checks"
state: pending
description: The pre-commit checks need to be successful before merging

- name: Wait for pre-commit checks to complete
uses: lucasssvaz/wait-on-workflow@v1
if: |
contains(github.event.pull_request.labels.*.name, 'Status: Pending Merge')
id: wait-on-workflow
with:
timeout: 10
interval: 30
workflow: pre-commit.yml
sha: ${{ github.event.pull_request.head.sha || github.sha }}

- name: Report success
uses: conda/actions/set-commit-status@v24.2.0
if: |
contains(github.event.pull_request.labels.*.name, 'Status: Pending Merge') &&
steps.wait-on-workflow.outputs.conclusion == 'success'
with:
context: "Pre-commit checks"
state: success
description: All pre-commit checks passed
6 changes: 3 additions & 3 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: Pre-commit check
name: Pre-commit hooks

on:
pull_request:
types: [opened, reopened, synchronize, labeled]
types: [opened, reopened, synchronize, labeled, unlabeled]

jobs:
lint:
if: |
contains(github.event.pull_request.labels.*.name, 'Status: Pending Merge')
name: Checking if any fixes are needed
name: Check if fixes are needed
runs-on: ubuntu-latest
steps:
- name: Checkout latest commit
Expand Down
Loading