mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
cbf0fa88eb
Since3b1e893black formatter workflow basically had no use since it wasn't reporting any issues (no one checks workflow logs unless workflow failed) and wasn't reliable for catching syntax errors either (black formatter catches syntax errors only when they get in the way of it's formatting the code, but now we delegate to python itself to catch syntax errors, see406962287c). And we also have some docs on how to apply black formatter - https://docs.bonsaibim.org/guides/development/code_style.html
53 lines
1.5 KiB
YAML
53 lines
1.5 KiB
YAML
name: ci-black-formatting
|
|
|
|
on:
|
|
push:
|
|
pull_request:
|
|
|
|
env:
|
|
PYTHON_VERSION: "3.12"
|
|
|
|
jobs:
|
|
lint-formatting:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Action - checkout repository
|
|
uses: actions/checkout@v4.2.2
|
|
|
|
- name: Action - install python
|
|
uses: actions/setup-python@v5.3.0
|
|
with:
|
|
python-version: "${{ env.PYTHON_VERSION }}"
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
python3 -m pip install --upgrade pip
|
|
python3 -m pip install 'black>=24.10.0'
|
|
|
|
# black doesn't catch all syntax errors, so we check them explicitly.
|
|
- name: Check syntax errors
|
|
id: syntax-errors
|
|
run: |
|
|
ERROR=0
|
|
python3 -W error -m compileall -q src/ifcopenshell-python || ERROR=1
|
|
python3 -W error -m compileall -q src/bonsai || ERROR=1
|
|
exit $ERROR
|
|
continue-on-error: true
|
|
|
|
- name: Black formatter
|
|
id: linting
|
|
run: |
|
|
python3 -m black --check .
|
|
continue-on-error: true
|
|
|
|
- name: Final check
|
|
run: |
|
|
ERROR=0
|
|
if [ "${{ steps.syntax-errors.outcome }}" != "success" ]; then
|
|
echo "::error::Syntax errors check failed, see 'syntax-errors' step for the details." && ERROR=1
|
|
fi
|
|
if [ "${{ steps.linting.outcome }}" != "success" ]; then
|
|
echo "::error::Black formatting check failed, see 'linting' step for the details." && ERROR=1
|
|
fi
|
|
exit $ERROR
|