name: ci-lint on: push: pull_request: jobs: lint-formatting: runs-on: ubuntu-latest env: MIN_IOS_PY_VERSION: "3.10" MIN_BLENDER_PY_VERSION: "3.11" steps: - name: Action - checkout repository uses: actions/checkout@v6 - name: Action - install python uses: actions/setup-python@v6 with: python-version: ${{ env.MIN_IOS_PY_VERSION }} - name: Action - install python uses: actions/setup-python@v6 with: python-version: ${{ env.MIN_BLENDER_PY_VERSION }} - name: Install dependencies run: | curl -LsSf https://astral.sh/uv/install.sh | sh uv tool install ruff uv tool install black uv tool install poethepoet uv tool install ty==0.0.59 # black doesn't catch all syntax errors, so we check them explicitly. - name: Check syntax errors id: syntax-errors run: | ERROR=0 # Using 2 Python versions - one minimum required for IfcOpenShell # and other that's used by Blender currently. python${{ env.MIN_IOS_PY_VERSION }} -W error -m compileall -q src/ifcopenshell-python || ERROR=1 python${{ env.MIN_BLENDER_PY_VERSION }} -W error -m compileall -q src/bonsai || ERROR=1 exit $ERROR continue-on-error: true - name: Black formatter id: black uses: psf/black@stable continue-on-error: true # Same check as above, but just for creating github annotations. - name: Black formatter annotations id: black-annotations run: | uv tool install black-codeclimate pip install github_action_utils black --diff --check . | black-codeclimate | python .github/workflows/black_to_github_annotations.py continue-on-error: true - name: ty check id: ty run: | poe ty-venv poe ty continue-on-error: true - name: Ruff check id: ruff run: | # Ensure execution continues, since we need to cache the output. set +e ERROR=0 # Keep colored output inside action logs, strip it from color codes for summary. uv tool install ansi2txt # `ruff` disables color output in CI by default. export FORCE_COLOR="1" run_check() { local out out="$("$@" 2>&1)" local exit_code=$? if [ "$exit_code" -ne 0 ]; then ERROR=1 fi # Rerun just for GitHub annotations. "$@" --output-format=github || true echo "$out" echo "\`\`\`python" >> $GITHUB_STEP_SUMMARY echo "$out" | ansi2txt >> $GITHUB_STEP_SUMMARY echo "\`\`\`" >> $GITHUB_STEP_SUMMARY } run_check poe ruff exit $ERROR 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 Summary or 'black' step for the details." && ERROR=1 fi if [ "${{ steps.ruff.outcome }}" != "success" ]; then echo "::error::Ruff check failed, see Summary or 'ruff' step for the details." && ERROR=1 fi if [ "${{ steps.ty.outcome }}" != "success" ]; then echo "::error::ty check failed, see 'ty check' step for the details." && ERROR=1 fi exit $ERROR