linting workflow #2
This file contains hidden or 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: Format Check | |
on: | |
pull_request: | |
branches: [ main, master ] | |
paths: | |
- '**.py' | |
- 'evals/**' | |
- 'stagehand/**' | |
- 'format.sh' | |
- 'pyproject.toml' | |
jobs: | |
format-check: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Install formatting dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install black isort ruff | |
- name: Make format script executable | |
run: chmod +x ./format.sh | |
- name: Check current formatting status | |
run: | | |
echo "Checking current code formatting..." | |
# Create a backup of current state | |
git stash push -m "backup before format check" | |
- name: Run format script | |
run: ./format.sh | |
- name: Check for formatting changes | |
run: | | |
if git diff --quiet; then | |
echo "✅ Code is properly formatted!" | |
exit 0 | |
else | |
echo "❌ Code formatting issues detected!" | |
echo "" | |
echo "The following files need formatting:" | |
git diff --name-only | |
echo "" | |
echo "Please run './format.sh' locally and commit the changes." | |
echo "" | |
echo "Detailed changes:" | |
git diff | |
exit 1 | |
fi |