Skip to content

Fix wavecal/freq_comb trace data flow and continuum trace mismatch #155

Fix wavecal/freq_comb trace data flow and continuum trace mismatch

Fix wavecal/freq_comb trace data flow and continuum trace mismatch #155

name: PyReduce CI/CD
on:
push:
branches: [ master ]
tags: [ 'v*' ]
workflow_dispatch:
pull_request:
branches: [ master ]
jobs:
# Run tests on PRs, manual triggers, and tag pushes
test:
name: Test on Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/v')
strategy:
fail-fast: false
matrix:
python-version: ['3.13']
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Install dependencies
run: uv sync --all-extras
- name: Run pre-commit hooks
run: uv run pre-commit run --all-files
- name: Test with pytest (unit tests)
run: uv run pytest -m unit --cov=pyreduce --cov-report=xml --cov-report=term
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
if: matrix.python-version == '3.13'
with:
file: ./coverage.xml
fail_ci_if_error: false
# Build platform-specific wheels using cibuildwheel
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs: [test]
if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/v')
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- name: Build wheels
uses: pypa/cibuildwheel@v3.2.0
env:
CIBW_BUILD_VERBOSITY: 1
- uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}
path: ./wheelhouse/*.whl
# Build source distribution
build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
needs: [test]
if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Set up Python
run: uv python install 3.13
- name: Build sdist
run: uv build --sdist
- uses: actions/upload-artifact@v4
with:
name: sdist
path: dist/*.tar.gz
# Upload to PyPI when a tag is pushed
upload_pypi:
name: Upload to PyPI
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
environment:
name: pypi
url: https://pypi.org/p/pyreduce-astro
permissions:
id-token: write # Required for trusted publishing
steps:
- name: Download all wheels
uses: actions/download-artifact@v4
with:
pattern: wheels-*
merge-multiple: true
path: dist/
- name: Download sdist
uses: actions/download-artifact@v4
with:
name: sdist
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
# Create GitHub Release with CHANGELOG
create_release:
name: Create GitHub Release
needs: [upload_pypi]
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write # Required to create releases
steps:
- uses: actions/checkout@v4
- name: Create GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: |
# Extract tag name
TAG_NAME=${GITHUB_REF#refs/tags/}
# Create release with CHANGELOG as notes
gh release create "$TAG_NAME" \
--title "Release $TAG_NAME" \
--notes-file CHANGELOG.md