refactor: remove test_notebook_snapshots.py #17
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: 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 ruff formatting check | |
| run: ruff format --check spectral_connectivity/ tests/ | |
| - name: Run ruff linting | |
| run: ruff check spectral_connectivity/ tests/ --output-format=github | |
| - name: Run mypy type checking | |
| run: mypy spectral_connectivity/ | |
| test: | |
| name: Test Python ${{ matrix.python-version }} | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| 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=spectral_connectivity --cov-report=xml --cov-report=term-missing tests/ --ignore=tests/test_notebooks.py | |
| - 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 jupyter nbconvert | |
| for nb in examples/Tutorial_On_Simulated_Examples.ipynb examples/Tutorial_Using_Paper_Examples.ipynb; do | |
| echo "Executing $nb" | |
| jupyter nbconvert --to notebook --ExecutePreprocessor.kernel_name=python3 --ExecutePreprocessor.timeout=1800 --execute "$nb" | |
| done | |
| 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 spectral_connectivity; print('Version:', spectral_connectivity.__version__)" | |
| - name: Install test dependencies | |
| run: pip install pytest pytest-cov nitime | |
| - name: Run package tests | |
| run: pytest --pyargs spectral_connectivity -v || echo "No tests found in package" | |
| 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/spectral-connectivity/ | |
| 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 | |
| sed -n '/## \[${{ steps.get_version.outputs.VERSION }}\]/,/## \[/p' CHANGELOG.md | sed '$d' > release_notes.md | |
| # If extraction failed, 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 [CHANGELOG.md](CHANGELOG.md) for details." >> release_notes.md | |
| fi | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| body_path: release_notes.md | |
| draft: false | |
| prerelease: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |