Skip to content

build and install distributions only if tests pass #197

build and install distributions only if tests pass

build and install distributions only if tests pass #197

Workflow file for this run

---
name: test
# yamllint disable-line rule:truthy
on:
push:
jobs:
run-tests:
name: Test on Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- 3.8
- 3.9
- "3.10"
- 3.11
defaults:
run:
shell: "bash -l {0}"
steps:
- uses: actions/checkout@v4
with:
# so versioningit can figure out the version
fetch-depth: 0
fetch-tags: true
- name: Set up Python ${{ matrix.python-version }} with conda
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: test
auto-activate-base: false
auto-update-conda: true
environment-file: devtools/conda-envs/test_env.yaml
miniforge-version: latest
python-version: ${{ matrix.python-version }}
show-channel-urls: true
- name: Print Python environment
run: python -m pip list
- name: Update installation infrastructure
run: python -m pip install -U setuptools pip
- name: Print conda environment
run: conda list
- name: Print conda info
run: conda info
- name: Print conda config
run: conda config --show
- name: Install
run: python -m pip install .
- name: Run tests
run: make test
- name: Build documentation
run: |
cd docs
make html
- name: GitHub Pages deploy
uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: docs/build/html
# yamllint disable-line rule:line-length
if: ${{ github.event_name == 'push' && matrix.python-version == '3.11' }}
- name: Install pypa/build and pypa/twine
run: |
python -m pip install build twine
- name: Build distribution packages (binary wheel and source tarball)
run: |
python -m build --outdir ./dist/${{ matrix.python-version }}
- name: Check packages with twine
run: |
python -m twine check ./dist/${{ matrix.python-version }}/*
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: ./dist/${{ matrix.python-version }}
check-installation:
name: Check installation of distribution 📦
needs:
- run-tests
runs-on: ubuntu-latest
strategy:
matrix:
install-method: [wheel, source]
python-version:
- 3.8
- 3.9
- "3.10"
- 3.11
steps:
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Download the distribution packages
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: ./dist/${{ matrix.python-version }}
- name: Update environment
run: |
python -m pip install -U setuptools pip
- name: Install from wheel
run: |
python -m pip install ./dist/${{ matrix.python-version }}/*.whl
if: matrix.install-method == 'wheel'
- name: Install from source
run: |
python -m pip install ./dist/${{ matrix.python-version }}/*.tar.gz
if: matrix.install-method == 'source'