Skip to content

Commit

Permalink
Created a Github Workflow that checks files with black upon pushing t…
Browse files Browse the repository at this point in the history
…hem to the repo
  • Loading branch information
EC2 Default User committed Nov 29, 2023
1 parent 41da5bc commit e13c60a
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/presubmit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Presubmit
on: [push]
jobs:
Presubmit:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v4
with:
python-version: '3.11'
- uses: actions/checkout@v3
- run: python3 -m pip install -r requirements-dev.txt
- run: ./check.sh
27 changes: 27 additions & 0 deletions check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash

CHANGED=0
if [[ $# = 1 ]] && [[ "$1" = "--fix" ]]; then
if ! black --check . &> /dev/null; then
black . || exit 1
CHANGED=1
fi

if ! isort --check . &> /dev/null; then
isort . || exit 1
CHANGED=1
fi
elif [[ $# -gt 0 ]]; then
echo "Usage: $0 [--fix]" > /dev/stderr
exit 1
fi

# if this fails with "black: command not found" you need to install black
# python3 -m pip install black
echo Running black to check formatting...
if ! black --check --diff --quiet .; then
echo "FAIL: formatting"
exit 1
fi


1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
black

0 comments on commit e13c60a

Please sign in to comment.