44 push :
55 pull_request :
66
7- env :
8- PYTHON_VERSION : " 3.12"
9-
107jobs :
118 lint-formatting :
129 runs-on : ubuntu-latest
@@ -17,57 +14,51 @@ jobs:
1714 - name : Action - install python
1815 uses : actions/setup-python@v5.3.0
1916 with :
20- python-version : " ${{ env.PYTHON_VERSION }} "
17+ python-version : " 3.9 "
2118
22- - name : Step 1 - install dependencies
23- shell : bash
24- run : |
25- python3 -m pip install --upgrade pip
26- python3 -m pip install 'black>=24.10.0'
19+ - name : Action - install python
20+ uses : actions/setup-python@v5.3.0
21+ with :
22+ python-version : " 3.11"
2723
28- # NOTE: This would suffice, however it is less informative in terms of the 3 possible outcomes
29- # - name: QA Step - check linting
30- # shell: bash
31- # id: linting
32- # run: |
33- # python3 -m black .
24+ - name : Install dependencies
25+ run : |
26+ curl -LsSf https://astral.sh/uv/install.sh | sh
27+ uv tool install ruff
28+ uv tool install black
3429
35- # QA STEP
36- - name : QA Step - check linting
37- shell : bash
38- id : linting
30+ # black doesn't catch all syntax errors, so we check them explicitly.
31+ - name : Check syntax errors
32+ id : syntax-errors
3933 run : |
40- python3 -m black --check . \
41- && exit 0 \
42- || (echo "exit_code=$?" >> "$GITHUB_OUTPUT" && exit 1);
34+ ERROR=0
35+ python3.9 -W error -m compileall -q src/ifcopenshell-python || ERROR=1
36+ python3.11 -W error -m compileall -q src/bonsai || ERROR=1
37+ exit $ERROR
4338 continue-on-error : true
4439
45- # OUTCOME 1 of QA STEP
46- - name : QA Step - no linting errors
47- if : steps.linting.outcome == 'success'
48- shell : bash
49- run : |-
50- echo "::notice::QA step linting succeeded"
51- exit 0;
40+ - name : Black formatter
41+ id : black
42+ run : |
43+ uvx black --diff --check .
44+ continue-on-error : true
5245
53- # OUTCOME 2i of QA STEP
54- - name : QA Step - unprettified code with no syntax errors
55- if : steps.linting.outputs.exit_code == 1
56- shell : bash
57- run : |-
58- echo "::group::QA step succeeded with warnings"
59- echo "::warning::one or more files contains unformatted code but no syntax errors";
60- echo "::notice::please run the linter before pushing!";
61- echo "::endgroup::"
62- exit 0;
46+ - name : Ruff check
47+ id : ruff
48+ run : |
49+ uvx ruff check
50+ continue-on-error : true
6351
64- # OUTCOME 2ii of QA STEP
65- - name : QA Step - code contains syntax errors
66- if : steps.linting.outputs.exit_code == 123
67- shell : bash
68- run : |-
69- echo "::group::QA step failed"
70- echo "::error::one or more files contains syntax errors";
71- echo "::notice::please run the linter and fix syntax errors before pushing!";
72- echo "::endgroup::"
73- exit 1;
52+ - name : Final check
53+ run : |
54+ ERROR=0
55+ if [ "${{ steps.syntax-errors.outcome }}" != "success" ]; then
56+ echo "::error::Syntax errors check failed, see 'syntax-errors' step for the details." && ERROR=1
57+ fi
58+ if [ "${{ steps.black.outcome }}" != "success" ]; then
59+ echo "::error::Black formatting check failed, see 'black' step for the details." && ERROR=1
60+ fi
61+ if [ "${{ steps.ruff.outcome }}" != "success" ]; then
62+ echo "::error::Ruff check failed, see 'ruff' step for the details." && ERROR=1
63+ fi
64+ exit $ERROR
0 commit comments