-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created a Github Workflow that checks files with black upon pushing t…
…hem to the repo
- Loading branch information
EC2 Default User
committed
Nov 29, 2023
1 parent
41da5bc
commit e13c60a
Showing
3 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
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
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 |
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
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 | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
black |