Update ci.yml #49
This file contains 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: Python Package Workflow | |
on: | |
release: | |
types: [published] | |
push: | |
branches: [ master ] | |
paths-ignore: [ '**.rst' ] | |
pull_request: | |
branches: [ master ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: [3.8] | |
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 dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.dev.txt | |
pip install -r requirements.txt | |
- name: Cache pip dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pip # This path is specific to Ubuntu | |
# Check for a cache hit for the corresponding dev requirements file | |
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.dev.txt') }}-${{ hashFiles('requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
${{ runner.os }}- | |
- name: Check code style | |
run: | | |
make check-style | |
- name: Install package | |
run: | | |
pip install . | |
- name: Run unit tests | |
run: | | |
make test | |
- name: Generate code coverage report | |
run: | | |
make coverage | |
- name: Generate docs | |
run: | | |
make docs | |
- name: Generate package | |
if: github.event_name == 'release' | |
run: | | |
make dist | |
- name: Upload docs | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
name: docs | |
path: docs | |
- name: Upload distribution package | |
if: github.event_name == 'release' | |
uses: actions/upload-artifact@master | |
with: | |
name: dist | |
path: dist | |
deploy-docs: | |
runs-on: ubuntu-latest | |
needs: build | |
permissions: | |
pages: write | |
id-token: write | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 | |
with: | |
name: docs | |
pypi-publish: | |
runs-on: ubuntu-latest | |
needs: build | |
permissions: | |
id-token: write | |
if: github.event_name == 'release' | |
steps: | |
- name: Download distribution package | |
uses: actions/download-artifact@master | |
with: | |
name: dist | |
path: dist | |
- name: Publish distribution to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 |