Add Linting Infrastructure with CI workflow #3
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: {} | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| lint: | |
| name: lint | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| pull-requests: read | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.10" | |
| - name: Install Python tooling | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install black pydocstyle yamllint | |
| - name: Set up Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| - name: Install markdownlint-cli | |
| run: npm install -g markdownlint-cli | |
| - name: Determine changed files | |
| id: changed-files | |
| uses: tj-actions/changed-files@v44 | |
| with: | |
| files_yaml: | | |
| python: | |
| - "**/*.py" | |
| markdown: | |
| - "**/*.md" | |
| yaml: | |
| - "**/*.yml" | |
| - "**/*.yaml" | |
| - name: Run Black (changed files) | |
| if: steps.changed-files.outputs.python_any_changed == 'true' | |
| run: | | |
| black --config pyproject.toml --check ${{ steps.changed-files.outputs.python_all_changed_files }} | |
| - name: Run pydocstyle (changed files) | |
| if: steps.changed-files.outputs.python_any_changed == 'true' | |
| run: | | |
| pydocstyle --config=pyproject.toml ${{ steps.changed-files.outputs.python_all_changed_files }} | |
| - name: Run custom import guard | |
| if: steps.changed-files.outputs.python_any_changed == 'true' | |
| run: | | |
| python scripts/check_imports.py \ | |
| --config scripts/import_exceptions.json \ | |
| ${{ steps.changed-files.outputs.python_all_changed_files }} | |
| - name: Run markdownlint (changed files) | |
| if: steps.changed-files.outputs.markdown_any_changed == 'true' | |
| run: | | |
| markdownlint -c .markdownlint.json ${{ steps.changed-files.outputs.markdown_all_changed_files }} | |
| - name: Run yamllint (changed files) | |
| if: steps.changed-files.outputs.yaml_any_changed == 'true' | |
| run: | | |
| yamllint -c .yamllint.yml ${{ steps.changed-files.outputs.yaml_all_changed_files }} |