Skip to content

Commit

Permalink
adding a Python code-formatting check for CI
Browse files Browse the repository at this point in the history
Signed-off-by: Karl W Schulz <[email protected]>
  • Loading branch information
koomie committed Jul 8, 2024
1 parent 0f745aa commit 91d21d2
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/formatting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Formatting

on:
push:
branches: [ main, dev ]
pull_request:
branches: [ main, dev ]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
python:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [3.9]

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install black
if [ -f requirements.txt ]; then python -m pip install -r requirements.txt; fi
- name: black format
run: |
black --diff --check .
python-bytecode:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v4
- name: find-bytecode
run: |
set +e
FILES=$(find . -type f | egrep '__pycache__|\.pyc$')
if [ -n "${FILES}" ]; then
echo -e "\nError! Python bytecode included in commit\n"
echo -e "### FILES: ###"
echo -e "${FILES}"
echo -e "##############"
exit 1
fi

0 comments on commit 91d21d2

Please sign in to comment.