Update CI workflow to use actions/upload-artifact@v4 for archiving te… #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: CI/CD Pipeline | |
on: | |
push: | |
branches: [ main, develop ] | |
paths-ignore: | |
- '**/*.md' | |
- '**/*.rst' | |
pull_request: | |
branches: [ main, develop ] | |
paths-ignore: | |
- '**/*.md' | |
- '**/*.rst' | |
workflow_dispatch: | |
jobs: | |
formatting: | |
name: Code Formatting & Linting | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12" | |
- name: Install formatting tools | |
run: | | |
python -m pip install --upgrade pip | |
pip install ruff | |
- name: Lint with Ruff | |
run: | | |
ruff check | |
ruff format --check | |
test: | |
name: Tests | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | |
exclude: | |
# Reduce matrix size for faster builds | |
- os: windows-latest | |
python-version: "3.8" | |
- os: macos-latest | |
python-version: "3.8" | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Cache pip packages | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements-test.txt | |
- name: Run tests with coverage | |
run: | | |
python -m pytest tests/ --cov=py_spoo_url --cov-report=xml --cov-report=html --cov-fail-under=80 | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v3 | |
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11' | |
with: | |
file: ./coverage.xml | |
flags: unittests | |
name: codecov-umbrella | |
fail_ci_if_error: false | |
- name: Archive test results | |
uses: actions/upload-artifact@v4 | |
if: failure() | |
with: | |
name: test-results-${{ matrix.os }}-${{ matrix.python-version }} | |
path: | | |
htmlcov/ | |
coverage.xml | |
.coverage | |
type-check: | |
name: Type Checking | |
runs-on: ubuntu-latest | |
needs: formatting | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11" | |
- name: Install type checking tools | |
run: | | |
python -m pip install --upgrade pip | |
pip install mypy types-requests | |
pip install -r requirements.txt | |
- name: Type checking with mypy | |
run: | | |
mypy py_spoo_url/ --ignore-missing-imports | |
continue-on-error: true |