Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 29 additions & 34 deletions .github/workflows/python-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,16 @@ jobs:
echo "::endgroup::"
fi

python-check:
ruff-check:
needs: [pre-check, detect-changes]
if: >
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'workflow_call' && inputs.skip-relevance-check == 'true') ||
needs.pre-check.outputs.is_act == 'true' ||
(needs.detect-changes.result == 'success' && needs.detect-changes.outputs.has_changes == 'true')
runs-on: ubuntu-latest
container:
image: ghcr.io/astral-sh/ruff:alpine
permissions:
contents: read

Expand All @@ -97,45 +99,38 @@ jobs:
with:
path: ${{ env.local_checkout_path }}

- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.x'

- name: Install Python dependencies
run: |
pip install ruff mypy

- name: Run ruff and mypy checks
- name: Run ruff check
working-directory: ${{ env.local_checkout_path }}
env:
FORCE_COLOR: 1 # `ruff`/`colored` crate
FORCE_COLOR: 1
run: |
failed=0

echo "➡️ Checking Python code with ruff..."
echo "::group::Running ruff check"
if ! ruff check; then
failed=1
echo "::endgroup::"
echo "::error:: Ruff check failed."
else
echo "::endgroup::"
echo "✅ Ruff check passed."
fi
ruff check

echo "➡️ Checking Python code with mypy..."
echo "::group::Running mypy"
if ! mypy --color-output .; then
failed=1
echo "::endgroup::"
echo "::error:: MyPy check failed."
else
echo "::endgroup::"
echo "✅ MyPy check passed."
fi
mypy-check:
needs: [pre-check, detect-changes]
if: >
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'workflow_call' && inputs.skip-relevance-check == 'true') ||
needs.pre-check.outputs.is_act == 'true' ||
(needs.detect-changes.result == 'success' && needs.detect-changes.outputs.has_changes == 'true')
runs-on: ubuntu-latest
container:
image: mypy/mypy:latest
permissions:
contents: read

steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
path: ${{ env.local_checkout_path }}

exit $failed
- name: Run mypy check
working-directory: ${{ env.local_checkout_path }}
run: |
echo "➡️ Checking Python code with mypy..."
mypy --color-output .

python-check-skipped:
needs: [pre-check, detect-changes]
Expand Down
14 changes: 5 additions & 9 deletions .github/workflows/python-fix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,20 @@ jobs:
runs-on: ubuntu-latest
name: Apply fixes
needs: parse-command
container:
image: ghcr.io/astral-sh/ruff:alpine
if: github.event_name == 'workflow_call' || needs.parse-command.result == 'success'
steps:
- name: Install git
run: apk add --no-cache git

- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
path: ${{ env.local_checkout_path }}
ref: ${{ (github.event_name == 'workflow_call' && inputs.ref) || needs.parse-command.outputs.ref }}
repository: ${{ (github.event_name == 'workflow_call' && inputs.repo) || needs.parse-command.outputs.repo }}
token: ${{ secrets.WORKFLOW_PAT }}

- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.x'

- name: Install Python dependencies
run: |
pip install ruff

- name: Run ruff format and fix
working-directory: ${{ env.local_checkout_path }}
env:
Expand Down
Loading