Skip to content

Commit 14baf7e

Browse files
akramiamemilio
authored andcommitted
fix: Improve pre-commit workflow error handling and feedback (llamastack#3400)
# What does this PR do? <!-- Provide a short summary of what this PR does and why. Link to relevant issues if applicable. --> fix: Improve pre-commit workflow error handling and feedback - Add explicit step to check pre-commit results and provide clear error messages - Improve verification steps with better error messages and file listings - Use GitHub Actions annotations (::error:: and ::warning::) for better visibility - Maintain continue-on-error for pre-commit step but add proper failure handling This addresses the issue where pre-commit failures were silent but still caused workflow failures later, making it difficult to understand what needed to be fixed. <!-- If resolving an issue, uncomment and update the line below --> <!-- Closes #[issue-number] --> ## Test Plan <!-- Describe the tests you ran to verify your changes with result summaries. *Provide clear instructions so the plan can be easily re-executed.* --> Signed-off-by: Akram Ben Aissi <[email protected]>
1 parent aeddc61 commit 14baf7e

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

.github/workflows/pre-commit.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,21 @@ jobs:
4747
run: npm ci
4848
working-directory: llama_stack/ui
4949

50-
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
50+
- name: Run pre-commit
51+
id: precommit
52+
uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
53+
continue-on-error: true
5154
env:
5255
SKIP: no-commit-to-branch
5356
RUFF_OUTPUT_FORMAT: github
5457

58+
- name: Check pre-commit results
59+
if: steps.precommit.outcome == 'failure'
60+
run: |
61+
echo "::error::Pre-commit hooks failed. Please run 'pre-commit run --all-files' locally and commit the fixes."
62+
echo "::warning::Some pre-commit hooks failed. Check the output above for details."
63+
exit 1
64+
5565
- name: Debug
5666
run: |
5767
echo "github.ref: ${{ github.ref }}"
@@ -79,17 +89,23 @@ jobs:
7989
echo "No changes to commit"
8090
fi
8191
82-
- name: Verify if there are any diff files after pre-commit
92+
- name: Verify no uncommitted changes
8393
if: github.actor != 'dependabot[bot]'
8494
run: |
85-
git diff --exit-code || (echo "There are uncommitted changes, run pre-commit locally and commit again" && exit 1)
95+
if ! git diff --exit-code; then
96+
echo "::error::There are uncommitted changes after pre-commit. Please run 'pre-commit run --all-files' locally and commit the fixes."
97+
echo "::warning::Files with changes:"
98+
git diff --name-status
99+
exit 1
100+
fi
86101
87102
- name: Verify if there are any new files after pre-commit
88103
if: github.actor != 'dependabot[bot]'
89104
run: |
90105
unstaged_files=$(git ls-files --others --exclude-standard)
91106
if [ -n "$unstaged_files" ]; then
92-
echo "There are uncommitted new files, run pre-commit locally and commit again"
107+
echo "::error::There are new untracked files after pre-commit. Please run 'pre-commit run --all-files' locally and commit the fixes."
108+
echo "::warning::New files:"
93109
echo "$unstaged_files"
94110
exit 1
95111
fi

0 commit comments

Comments
 (0)