mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-06 07:51:47 +00:00
bd4b80bdc2
Previously it was using Python 3.12 for everything, therefore syntax errors from Python 3.9 (e.g. `match` statement in ifcopenshell-python) went under the radar.
66 lines
1.9 KiB
YAML
66 lines
1.9 KiB
YAML
name: ci-black-formatting
|
|
|
|
on:
|
|
push:
|
|
pull_request:
|
|
|
|
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: "3.9"
|
|
|
|
- name: Action - install python
|
|
uses: actions/setup-python@v5.3.0
|
|
with:
|
|
python-version: "3.11"
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
python3 -m pip install --upgrade pip
|
|
python3 -m pip install 'black>=24.10.0'
|
|
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
uv tool install ruff
|
|
|
|
# black doesn't catch all syntax errors, so we check them explicitly.
|
|
- name: Check syntax errors
|
|
id: syntax-errors
|
|
run: |
|
|
ERROR=0
|
|
python3.9 -W error -m compileall -q src/ifcopenshell-python || ERROR=1
|
|
python3.11 -W error -m compileall -q src/bonsai || ERROR=1
|
|
exit $ERROR
|
|
continue-on-error: true
|
|
|
|
- name: Black formatter
|
|
id: black
|
|
run: |
|
|
python3 -m black --diff --check .
|
|
continue-on-error: true
|
|
|
|
- name: Ruff check
|
|
id: ruff
|
|
run: |
|
|
uvx ruff 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.black.outcome }}" != "success" ]; then
|
|
echo "::error::Black formatting check failed, see 'black' step for the details." && ERROR=1
|
|
fi
|
|
if [ "${{ steps.ruff.outcome }}" != "success" ]; then
|
|
echo "::error::Ruff check failed, see 'ruff' step for the details." && ERROR=1
|
|
fi
|
|
exit $ERROR
|