Reenable black formatting workflow

Since 3b1e893 black 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, see 406962287c).

And we also have some docs on how to apply black formatter - https://docs.bonsaibim.org/guides/development/code_style.html
This commit is contained in:
Andrej730
2025-05-01 18:06:46 +05:00
parent 6961ca8ce7
commit cbf0fa88eb
+18 -52
View File
@@ -19,68 +19,34 @@ jobs:
with: with:
python-version: "${{ env.PYTHON_VERSION }}" python-version: "${{ env.PYTHON_VERSION }}"
- name: Step 1 - install dependencies - name: Install dependencies
shell: bash
run: | run: |
python3 -m pip install --upgrade pip python3 -m pip install --upgrade pip
python3 -m pip install 'black>=24.10.0' python3 -m pip install 'black>=24.10.0'
# NOTE: This would suffice, however it is less informative in terms of the 3 possible outcomes # black doesn't catch all syntax errors, so we check them explicitly.
# - name: QA Step - check linting
# shell: bash
# id: linting
# run: |
# python3 -m black .
# black doesn't catch all syntax erors, so we check them explicitly.
- name: Check syntax errors - name: Check syntax errors
shell: sh
id: syntax-errors id: syntax-errors
run: | run: |
ERROR=0 ERROR=0
python3 -W error -m compileall -q src/ifcopenshell-python || ERROR=1 python3 -W error -m compileall -q src/ifcopenshell-python || ERROR=1
python3 -W error -m compileall -q src/bonsai || ERROR=1 python3 -W error -m compileall -q src/bonsai || ERROR=1
if [ $ERROR -ne 0 ]; then \ exit $ERROR
echo "One or more tests failed"; \
exit 1; \
fi
# QA STEP
- name: QA Step - check linting
shell: bash
id: linting
run: |
python3 -m black --check . \
&& exit 0 \
|| (echo "exit_code=$?" >> "$GITHUB_OUTPUT" && exit 1);
continue-on-error: true continue-on-error: true
# OUTCOME 1 of QA STEP - name: Black formatter
- name: QA Step - no linting errors id: linting
if: steps.linting.outcome == 'success' run: |
shell: bash python3 -m black --check .
run: |- continue-on-error: true
echo "::notice::QA step linting succeeded"
exit 0;
# OUTCOME 2i of QA STEP - name: Final check
- name: QA Step - unprettified code with no syntax errors run: |
if: steps.linting.outputs.exit_code == 1 ERROR=0
shell: bash if [ "${{ steps.syntax-errors.outcome }}" != "success" ]; then
run: |- echo "::error::Syntax errors check failed, see 'syntax-errors' step for the details." && ERROR=1
echo "::group::QA step succeeded with warnings" fi
echo "::warning::one or more files contains unformatted code but no syntax errors"; if [ "${{ steps.linting.outcome }}" != "success" ]; then
echo "::notice::please run the linter before pushing!"; echo "::error::Black formatting check failed, see 'linting' step for the details." && ERROR=1
echo "::endgroup::" fi
exit 0; exit $ERROR
# OUTCOME 2ii of QA STEP
- name: QA Step - code contains syntax errors
if: steps.linting.outputs.exit_code == 123
shell: bash
run: |-
echo "::group::QA step failed"
echo "::error::one or more files contains syntax errors";
echo "::notice::please run the linter and fix syntax errors before pushing!";
echo "::endgroup::"
exit 1;