Test and Build #103
This file contains 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: Test and Build | |
on: | |
workflow_call: | |
outputs: | |
version-type: | |
description: | | |
Type of version (from VCS version). This is one of 'local', 'dev', 'pre', or 'release'. | |
Note that unless a commit is tagged, the version type will always be 'local'. | |
value: ${{ jobs.build.outputs.version-type }} | |
workflow_dispatch: | |
schedule: | |
- cron: '43 3 * * 2' | |
jobs: | |
tests: | |
name: python ${{ matrix.python-version }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest] | |
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13'] | |
include: | |
- { python-version: '3.7', os: ubuntu-22.04 } | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
allow-prereleases: true | |
- name: Install hatch | |
run: | | |
python -m pip install --upgrade pip | |
pip install hatch hatch-vcs | |
- run: hatch run full | |
lint: | |
name: Lint | |
runs-on: 'ubuntu-latest' | |
env: | |
python-version: '3.11' | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.python-version }} | |
- name: pre-commit cache | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pre-commit | |
key: py-${{ env.python-version }}-${{ hashFiles('.pre-commit-config.yaml') }} | |
- name: Install hatch, pre-commit | |
run: | | |
python -m pip install --upgrade pip | |
pip install hatch hatch-vcs pre-commit | |
- name: Run mypy | |
run: hatch run dev:mypy hatch_zipped_directory | |
- run: pre-commit run -a | |
if: always() | |
build: | |
name: Build distribution | |
needs: [tests, lint] | |
runs-on: ubuntu-latest | |
outputs: | |
version-type: ${{ steps.classify-version.outputs.version-type }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: 3.x | |
- run: python -m pip install --upgrade pip | |
- run: python -m pip install hatch hatch-vcs packaging | |
- run: hatch build | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: dist | |
path: dist | |
retention-days: 1 | |
- name: Classify Version | |
id: classify-version | |
run: | | |
hatch version | python -c ' | |
import sys, packaging.version | |
version = packaging.version.parse(sys.stdin.read()) | |
if version.local: | |
version_type = "local" | |
elif version.is_devrelease: | |
version_type = "dev" | |
elif version.is_prerelease: | |
version_type = "pre" | |
else: | |
version_type = "release" | |
print(f"version-type={version_type}") | |
print(f"version-type={version_type}", file=sys.stderr) | |
' >> "$GITHUB_OUTPUT" |