Skip to content

Commit

Permalink
mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
fboundy committed Dec 22, 2024
1 parent cbf36a3 commit 0aa3f48
Showing 1 changed file with 54 additions and 18 deletions.
72 changes: 54 additions & 18 deletions .github/workflows/black-check.yaml
Original file line number Diff line number Diff line change
@@ -1,35 +1,71 @@
name: Black Formatter Check
name: Auto-format Code with Debugging and Type Checking

on:
push:
branches:
- main # Specify the branches you want to check (e.g., main)
patch
dev
pull_request:
branches:
- main # Run checks for pull requests targeting main
patch
dev
push: # Run on pushes to all branches
pull_request: # Run on pull requests for all branches

jobs:
black:
name: Run Black Formatter
auto-format:
name: Auto-format, Type Check, and Push Changes
runs-on: ubuntu-latest

steps:
- name: Checkout repository
# Step 1: Checkout the repository
- name: Checkout Repository
uses: actions/checkout@v3

# Step 2: Set up Python environment
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Install Black
# Step 3: Install tools (black, isort, mypy)
- name: Install Tools
run: |
echo "Installing tools..."
python -m pip install --upgrade pip
pip install black
pip install black isort mypy
- name: Run Black Formatter
run: black --linelength=119
# Step 4: Run black and isort to format the code
- name: Run Black and isort
run: |
echo "Running black..."
black .
echo "Running isort..."
isort .
# Step 5: Run mypy for type checking
- name: Run mypy
run: |
echo "Running mypy for type checking..."
mypy .
# Step 6: Commit and push changes if any files were modified
- name: Commit and Push Changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Configuring git user..."
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
echo "Checking for changes..."
git status
if [ -n "$(git status --porcelain)" ]; then
echo "Changes detected. Inspecting changes..."
git diff
echo "Staging files..."
git add .
echo "Committing changes..."
git commit -m "Auto-format code with Black and isort"
echo "Pushing changes to branch..."
git push
echo "Push completed successfully."
else
echo "No changes detected. Nothing to commit or push."
fi

0 comments on commit 0aa3f48

Please sign in to comment.