[pull] main from yeonholee50:main #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Pre-Commit Linting | |
on: | |
push: | |
branches: ['**'] # Runs on all branches when pushing | |
pull_request: | |
branches: ['**'] # Runs on all PRs | |
types: [opened, synchronize] | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Get full history for better diffs | |
- name: Set up Python 3.x | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.12' | |
- name: Install pre-commit and dependencies | |
run: | | |
pip install pre-commit black==25.1.0 isort==6.0.1 flake8==7.1.2 | |
- name: Run pre-commit hooks | |
run: | | |
# Run pre-commit and capture the output | |
OUTPUT=$(pre-commit run --all-files) || true | |
# Check if any files were modified | |
if [[ $OUTPUT == *"Fixing"* ]]; then | |
echo "::warning::Pre-commit would make changes to some files. Please run pre-commit locally and commit the changes." | |
echo "$OUTPUT" | |
# Don't fail the workflow, just warn | |
else | |
echo "No files need formatting changes." | |
fi |