Skip to content

Test and Build

Test and Build #86

Workflow file for this run

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: 'ubuntu-latest'
strategy:
fail-fast: false
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- 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@v4
with:
python-version: ${{ env.python-version }}
- name: pre-commit cache
uses: actions/cache@v3
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@v3
with:
fetch-depth: 0
- run: python -m pip install --upgrade pip
- run: python -m pip install hatch hatch-vcs packaging
- run: hatch build
- uses: actions/upload-artifact@v3
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"