WIP #203
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: lint | |
on: | |
push: | |
release: | |
pull_request: | |
env: | |
POETRY_HOME: /opt/poetry | |
POETRY_CACHE: /opt/poetry_cache | |
jobs: | |
lint_and_test: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] | |
steps: | |
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event. Selected python version is ${{ matrix.python-version }}." | |
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" | |
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." | |
- name: Check out repository code | |
uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Cache deps install | |
id: cache-deps | |
uses: actions/cache@v3 | |
with: | |
path: | | |
${{ env.POETRY_HOME }} | |
${{ env.POETRY_CACHE }} | |
key: cachepoetry-${{ hashFiles('poetry.lock', '.github/workflows/**') }}-${{ matrix.python-version }} | |
- name: Install poetry | |
if: steps.cache-deps.outputs.cache-hit != 'true' | |
run: | | |
python3 -m venv $POETRY_HOME | |
$POETRY_HOME/bin/pip install poetry | |
- name: Fix github path | |
run: | | |
echo "$POETRY_HOME/bin" >> "$GITHUB_PATH" | |
- name: Configure poetry | |
run: | | |
poetry config virtualenvs.create true | |
poetry config virtualenvs.in-project false | |
poetry config cache-dir $POETRY_CACHE | |
poetry config virtualenvs.path $POETRY_CACHE/venv | |
- name: Install requirements | |
if: steps.cache-deps.outputs.cache-hit != 'true' | |
run: | | |
poetry install | |
- name: Run lint | |
run: | | |
poetry run invoke lint --no-fix | |
- name: Run tests / coverage | |
run: | | |
poetry run invoke test --coverage | |
- name: Upload coverage reports to Codecov | |
uses: codecov/codecov-action@v3 | |
if: matrix.python-version == '3.7' | |
- name: Make docs | |
run: | | |
poetry run invoke docs | |
- name: Upload API doc as an artifact | |
if: matrix.python-version == '3.7' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: apidoc | |
path: apihtml/ | |
- name: Upload PUBLIC doc as an artifact | |
if: matrix.python-version == '3.7' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: publicdoc | |
path: html/ | |
- name: Upload COVERAGE as an artifact | |
if: matrix.python-version == '3.7' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: coverage | |
path: htmlcov/ | |
publish_pypi: | |
runs-on: ubuntu-latest | |
needs: lint_and_test | |
if: github.event_name == 'release' && github.event.action == 'created' | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v3 | |
- name: Install poetry | |
run: | | |
python3 -m venv $POETRY_HOME | |
$POETRY_HOME/bin/pip install poetry | |
- name: Fix github path | |
run: | | |
echo "$POETRY_HOME/bin" >> "$GITHUB_PATH" | |
- name: Install requirements | |
run: | | |
poetry install | |
- name: Publish on Pypi | |
run: | | |
poetry run invoke bump-version | |
poetry config pypi-token.pypi "${{ secrets.PYPI_TOKEN }}" | |
poetry build | |
poetry publish | |
githubpages: | |
runs-on: ubuntu-latest | |
needs: lint_and_test | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
concurrency: | |
group: "pages" | |
cancel-in-progress: true | |
environment: | |
name: github-pages | |
if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
steps: | |
- name: Download API doc artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: apidoc | |
- name: Download API doc artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: publicdoc | |
- name: Download COVERAGE artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: coverage | |
path: coverage | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v1 | |
with: | |
# Upload entire repository | |
path: '.' | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v1 |