Restructured into jobs: lint, test and build. Aligned associated proj… #11
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 | |
- 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 out 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 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: 'pip' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install ".[test]" | |
- name: Run tests | |
env: | |
TDM_API_TOKEN: ${{ secrets.TDM_API_TOKEN }} | |
run: pytest --cov --cov-report=xml | |
build: | |
name: Build Package | |
runs-on: ubuntu-latest | |
needs: [lint, test] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v4 | |
with: | |
# For performance reasons, using the latest Python version | |
python-version: "3.12" | |
cache: 'pip' | |
- name: Install build tools | |
run: | | |
python -m pip install --upgrade pip | |
pip install ".[build]" | |
- name: Build distribution | |
run: python -m build | |
- name: Verify distribution with twine | |
run: twine check dist/* | |
- name: Upload distribution artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: python-dist | |
path: dist/ |