Skip to content
Merged
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
68 changes: 32 additions & 36 deletions .github/workflows/lint_and_test.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
name: Test (lint and typehints)

on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
workflow_call:
inputs:
python-version:
required: false
type: string
default: '3.12' # Default Python version
requirements_path:
required: false
type: string
secrets:
repo_token:
required: true


jobs:
lint_and_typehints:
Expand All @@ -15,46 +23,34 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

# - name: Exit if not Pyceaas repository
# run: |
# if [ "${{ github.repository }}" != "PyCeas/Pyceas" ]; then
# echo "Not running in PyCeas repository. Exiting."
# exit 0
# fi

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install dependencies
- name: Install dependencies (if requirements.txt exists)
run: |
python -m pip install --upgrade pip
pip install ruff mypy pygame-ce pytmx
if [ - f requirements.txt ]; then
echo "requirements.txt found. Installing dependencies."
python -m pip install --upgrade pip
pip install -r requirements.txt
else
echo "No requirements.txt found. Installing ruff and mypy."
python -m pip install --upgrade pip
pip install ruff mypy
fi

- name: Check for Python files
id: check_files
run: |
git ls-files '*.py' > files.txt
if [ ! -s files.txt ]; then
echo "No Python files found. Skipping lint and type-check."
fi

run: |
if ! git ls-files '*.py' | grep -q '.'; then
echo "No Python files found. Exiting."
exit 0
fi
- name: Run ruff
if: success()
run: |
if [ -s files.txt ]; then
ruff check $(cat files.txt)
else
echo "Skipping ruff; no Python files found."
fi
run: ruff check .

- name: Run mypy
if: success()
run: |
if [ -s files.txt ]; then
mypy $(cat files.txt)
else
echo "Skipping mypy; no Python files found."
fi
run: mypy .