Skip to content

Commit cb4662f

Browse files
authored
enable pre-commit job (#1683)
Signed-off-by: chensuyue <[email protected]>
1 parent 9389cf4 commit cb4662f

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

.github/workflows/pr-io-build.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ concurrency:
1616
jobs:
1717
build-on-pr:
1818
runs-on: ${{ contains(github.repository, 'intel-innersource') && 'self-hosted' || 'ubuntu-latest' }}
19+
permissions:
20+
pull-requests: write
21+
contents: write
1922
steps:
2023
- name: Clean Up Working Directory
2124
run: sudo rm -rf ${{github.workspace}}/*
@@ -29,4 +32,4 @@ jobs:
2932
run: |
3033
git config --local --get remote.origin.url
3134
cd docs/build_docs
32-
bash build.sh latest
35+
bash build.sh latest

.github/workflows/pr-pre-commit.yml.draft renamed to .github/workflows/pr-pre-commit.yml

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,38 +33,35 @@ jobs:
3333
env:
3434
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3535
run: |
36+
3637
# Create a virtual environment
3738
python -m venv venv
3839
source venv/bin/activate
39-
40+
4041
# Upgrade pip and install pre-commit
4142
pip install --upgrade pip
4243
pip install -U pre-commit
43-
44+
4445
# Run pre-commit hooks to fix auto-fixable issues
4546
pre-commit install
46-
pre-commit run --all-files --show-diff-on-failure > pre-commit.log 2>&1
47-
exit_code=$?
48-
cat pre-commit.log
49-
47+
pre-commit run --all-files | tee pre-commit.log 2>&1 || true
48+
5049
# Check if there are changes after pre-commit run
5150
if [ -n "$(git status --porcelain)" ]; then
5251
# Commit and push the changes if there are any
5352
git config user.name "GitHub Action"
5453
git config user.email "[email protected]"
5554
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git
5655
git add -A
57-
git commit -m -s "chore: apply pre-commit auto-fixes"
56+
git commit -n -s -m "chore: apply pre-commit auto-fixes"
5857
git push origin HEAD:${{ github.head_ref }}
5958
else
6059
# If no changes are made, print a message
6160
echo "No auto-fixable changes were made by pre-commit."
6261
fi
63-
64-
# Exit with the original exit code from pre-commit
65-
if [ $exit_code -ne 0 ]; then
66-
echo "Pre-commit found issues. See pre-commit.log for details."
67-
exit $exit_code
62+
63+
sleep 1s
64+
if [ $(grep -c "Failed" pre-commit.log) != 0 ]; then
65+
echo "Some checks failed that require manual intervention. Please review the pre-commit.log for details."
66+
exit 1
6867
fi
69-
70-

0 commit comments

Comments
 (0)