diff --git a/.github/workflows/lint_and_test.yml b/.github/workflows/lint_and_test.yml index f29d561..f668f75 100644 --- a/.github/workflows/lint_and_test.yml +++ b/.github/workflows/lint_and_test.yml @@ -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: @@ -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 . + +