Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ci(pre-commit): Add label if manual fixes are required #11776

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

Merged
me-no-dev merged 2 commits into espressif:master from lucasssvaz:ci/pre-commit-tag
Sep 4, 2025
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
23 changes: 21 additions & 2 deletions .github/workflows/pre-commit.yml
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ concurrency:
cancel-in-progress: true

permissions:
contents: write
pull-requests: read
contents: read
pull-requests: write

jobs:
lint:
Expand All @@ -34,6 +34,7 @@ jobs:
- name: Remove Label
if: contains(github.event.pull_request.labels.*.name, 'Re-trigger Pre-commit Hooks')
run: gh pr edit ${{ github.event.number }} --remove-label 'Re-trigger Pre-commit Hooks'
continue-on-error: true
env:
GH_TOKEN: ${{ github.token }}

Expand Down Expand Up @@ -65,6 +66,7 @@ jobs:
uses: tj-actions/changed-files@2f7c5bfce28377bc069a65ba478de0a74aa0ca32 # v46.0.1

- name: Run pre-commit hooks in changed files
id: pre-commit
run: pre-commit run --color=always --show-diff-on-failure --files ${{ steps.changed-files.outputs.all_changed_files }}

- name: Save pre-commit cache
Expand All @@ -82,3 +84,20 @@ jobs:
if: ${{ always() && github.event_name == 'pull_request' }}
with:
msg: "ci(pre-commit): Apply automatic fixes"

- name: Add label if no commits are pending
if: ${{ failure() && steps.pre-commit.outcome == 'failure' && steps.pre-commit.outputs.pending_commit == '0' && github.event_name == 'pull_request' }}
continue-on-error: true
run: |
gh pr edit ${{ github.event.number }} --add-label 'Status: Pre-commit fixes required ⚠️'
env:
GH_TOKEN: ${{ github.token }}

- name: Remove label if everything was fixed
if: ${{ success() && github.event_name == 'pull_request' }}
continue-on-error: true
run: |
gh pr edit ${{ github.event.number }} --remove-label 'Status: Pre-commit fixes required ⚠️'
env:
GH_TOKEN: ${{ github.token }}

17 changes: 17 additions & 0 deletions .pre-commit-config.yaml
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,20 @@ repos:
- id: vale
language_version: "1.23.2"
types_or: [markdown, rst]

# Always leave this last to ensure that all hooks have already run
- repo: local
hooks:
- id: git-diff
name: git diff
entry: |
bash -c '
if [ "$CI" = "true" ]; then
if git diff --exit-code; then
echo "pending_commit=0" >> $GITHUB_OUTPUT
else
echo "pending_commit=1" >> $GITHUB_OUTPUT
fi
fi
'
language: system
Loading

AltStyle によって変換されたページ (->オリジナル) /