Skip to content

Refactor _build_track_from_state function signature #4

Refactor _build_track_from_state function signature

Refactor _build_track_from_state function signature #4

Workflow file for this run

name: Test, Build, and Publish
on:
push:
branches:
- master
tags:
- "v*"
pull_request:
branches:
- master
defaults:
run:
shell: bash
jobs:
quality:
name: Code Quality
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: pip install -e .[dev]
- name: Run black formatting check
run: black --check src/track_linearization/
- name: Run ruff linting
run: ruff check src/track_linearization/ --output-format=github
- name: Run mypy type checking
run: mypy src/track_linearization/
test:
name: Test Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- name: Install dependencies
run: pip install -e .[dev]
- name: Run tests with coverage
run: pytest --cov=track_linearization --cov-report=xml --cov-report=term-missing src/track_linearization/tests/
- name: Upload coverage to Codecov
if: matrix.python-version == '3.12'
uses: codecov/codecov-action@v5
continue-on-error: true
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Test notebooks
if: matrix.python-version == '3.12'
run: |
pip install -e .[opt]
jupyter nbconvert --to notebook --ExecutePreprocessor.kernel_name=python3 --ExecutePreprocessor.timeout=1800 --execute notebooks/test_linearization.ipynb
build:
name: Build distribution
runs-on: ubuntu-latest
needs: [quality, test]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Needed for hatch-vcs to determine version from git tags
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install build tools
run: pip install --upgrade build twine
- name: Build sdist and wheel
run: python -m build
- name: Check distribution
run: twine check dist/*
- name: Upload distribution artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
test-package:
name: Test ${{ matrix.package }} install
runs-on: ubuntu-latest
needs: [build]
strategy:
matrix:
package: ['wheel', 'sdist']
steps:
- name: Download distribution artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install wheel
if: matrix.package == 'wheel'
run: pip install dist/*.whl
- name: Install sdist
if: matrix.package == 'sdist'
run: pip install dist/*.tar.gz
- name: Check import
run: python -c "import track_linearization; print('Version:', track_linearization.__version__)"
- name: Install test dependencies
run: pip install pytest pytest-cov
- name: Run package tests
run: pytest --pyargs track_linearization -v
publish:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: [test-package]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
environment:
name: pypi
url: https://pypi.org/project/track-linearization/
permissions:
id-token: write # Required for trusted publishing
steps:
- name: Download distribution artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
create-release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: [publish]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract version from tag
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Extract release notes from CHANGELOG
id: extract_notes
run: |
# Extract section between this version and next version marker
if [ -f CHANGELOG.md ]; then
sed -n '/## \[${{ steps.get_version.outputs.VERSION }}\]/,/## \[/p' CHANGELOG.md | sed '$d' > release_notes.md
fi
# If extraction failed or no CHANGELOG, use a default message
if [ ! -s release_notes.md ]; then
echo "Release v${{ steps.get_version.outputs.VERSION }}" > release_notes.md
echo "" >> release_notes.md
echo "See commit history for details." >> release_notes.md
fi
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
body_path: release_notes.md
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}