Changed job name #3
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_pull_request | |
on: [pull_request, push] | |
jobs: | |
lint_pull_request: | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # To get all history for git diff commands | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: 3.12 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements-dev.txt | |
- name: Get changed Python files | |
id: changed-files | |
run: | | |
if [ "${{ github.event_name }}" == "pull_request" ]; then | |
# For PRs, compare against base branch | |
CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRT origin/${{ github.base_ref }} HEAD | grep '\.py$' || echo "") | |
else | |
# For pushes, use the before/after SHAs | |
CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRT ${{ github.event.before }} ${{ github.event.after }} | grep '\.py$' || echo "") | |
fi | |
echo "files=$CHANGED_FILES" >> $GITHUB_OUTPUT | |
echo "Changed Python files: $CHANGED_FILES" | |
- name: Lint with flake8 | |
if: ${{ steps.changed-files.outputs.files != '' }} | |
run: | | |
echo "Linting files: ${{ steps.changed-files.outputs.files }}" | |
flake8 ${{ steps.changed-files.outputs.files }} --count --show-source --statistics | |
continue-on-error: true | |
- name: Format check with isort and black | |
if: ${{ steps.changed-files.outputs.files != '' }} | |
run: | | |
echo "Checking format with isort for: ${{ steps.changed-files.outputs.files }}" | |
isort --profile black --check ${{ steps.changed-files.outputs.files }} | |
echo "Checking format with black for: ${{ steps.changed-files.outputs.files }}" | |
black --check ${{ steps.changed-files.outputs.files }} | |
continue-on-error: true | |
- name: Type check with mypy | |
if: ${{ steps.changed-files.outputs.files != '' }} | |
run: | | |
echo "Type checking: ${{ steps.changed-files.outputs.files }}" | |
mypy --ignore-missing-imports ${{ steps.changed-files.outputs.files }} | |
continue-on-error: true | |
- name: Run tests with pytest | |
run: | | |
pytest ./patterns | |
pytest --doctest-modules ./patterns || true | |
continue-on-error: true | |
- name: Check Python version compatibility | |
if: ${{ steps.changed-files.outputs.files != '' }} | |
run: pyupgrade --py312-plus ${{ steps.changed-files.outputs.files }} | |
continue-on-error: true | |
- name: Run tox | |
run: tox | |
continue-on-error: true |