[Enhencement] - Add Ruff to GitHub Actions #7
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Lint | |
| on: | |
| pull_request: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| - master | |
| permissions: | |
| contents: read | |
| jobs: | |
| mypy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v2 | |
| - uses: actions/setup-python@v3 | |
| with: | |
| python-version: '3.x' | |
| - run: pip install mypy # you can pin your preferred version | |
| - name: Get Python changed files | |
| id: changed-py-files | |
| uses: tj-actions/changed-files@v23 | |
| with: | |
| files: | | |
| *.py | |
| **/*.py | |
| - name: Run if any of the listed files above is changed | |
| if: steps.changed-py-files.outputs.any_changed == 'true' | |
| run: mypy $(git diff --name-only --cached -- '*.py') --ignore-missing-imports | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install Ruff | |
| run: pip install ruff | |
| - name: Run Ruff | |
| run: ruff check $(git diff --name-only --cached -- '*.py') |