Improved readability and consistency. #17
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 | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
workflow_dispatch: | |
jobs: | |
lint: | |
name: Code Quality Checks | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
# For performance and compatibility with linters, using the latest Python version | |
python-version: "3.12" | |
cache: 'pip' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install ".[lint]" | |
- name: Run linters | |
run: | | |
black --check --verbose . | |
isort --check --diff . | |
pylint src/ tests/ | |
test: | |
name: Run Tests | |
runs-on: ubuntu-latest | |
needs: lint | |
strategy: | |
fail-fast: true | |
# To avoid overwhelming the API with parallel requests. Mock API in the future. | |
max-parallel: 1 | |
matrix: | |
# For backwards compatibility | |
python-version: ["3.9", "3.10", "3.11", "3.12"] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: 'pip' | |
- name: Install dependencies | |
# Editable mode (-e) is required for coverage reporting | |
run: | | |
python -m pip install --upgrade pip | |
pip install -e ".[test]" | |
- name: Run tests with coverage | |
env: | |
TDM_API_TOKEN: ${{ secrets.TDM_API_TOKEN }} | |
run: pytest --cov=wiley_tdm --cov-report=xml --cov-report=html | |
- name: Upload HTML coverage report | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage-report-${{ matrix.python-version }} | |
path: htmlcov | |
retention-days: 7 | |
build: | |
name: Build Package | |
runs-on: ubuntu-latest | |
needs: [lint, test] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
# For performance reasons, using the latest Python version | |
python-version: "3.12" | |
cache: 'pip' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install ".[build]" | |
- name: Build package | |
run: python -m build | |
- name: Verify package integrity | |
run: twine check dist/* | |
- name: Upload build artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: python-dist | |
path: dist/ | |
retention-days: 7 |