Update test.yml #246
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: Unit Tests | |
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] | |
workflow_dispatch: | |
concurrency: | |
group: pages | |
cancel-in-progress: false | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
environment: test | |
continue-on-error: ${{ contains(matrix.python-version, 'pypy') }} | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12", "pypy3.9", "pypy3.10" ] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
python3 -m pip install --upgrade pip | |
pip install pipenv | |
pipenv install --python "${{ matrix.python-version }}" --dev --system --skip-lock | |
- name: Write karate_club.tsv | |
run: python3 -c 'import networkx as nx; nx.write_weighted_edgelist(nx.karate_club_graph(), "karate_club.tsv", delimiter="\t")' | |
- name: Lint with Mypy | |
run: mypy chinese_whispers | |
- name: Lint with Ruff | |
uses: chartboost/ruff-action@v1 | |
- name: Test with unittest | |
run: python3 -m unittest discover | |
- name: Run Module | |
run: python3 -m chinese_whispers karate_club.tsv | |
- name: Run CLI | |
run: chinese-whispers karate_club.tsv | |
- name: Lint Jupyter with Mypy | |
run: nbqa mypy *.ipynb | |
- name: Lint Jupyter with Ruff | |
run: nbqa ruff *.ipynb | |
- name: Run Jupyter | |
run: | | |
mkdir jupyter | |
jupyter nbconvert --to html --output jupyter/index.html --execute example.ipynb | |
- name: Run MkDocs | |
run: mkdocs build --strict | |
- name: Build | |
run: | | |
python3 -m build --sdist --wheel . | |
twine check --strict dist/* | |
- name: Validate CITATION.cff | |
uses: citation-file-format/[email protected] | |
with: | |
args: "--validate" | |
- name: Upload Jupyter | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: "./jupyter" | |
if: matrix.python-version == '3.12' && github.ref == 'refs/heads/master' | |
- name: Upload packages | |
uses: actions/upload-artifact@v4 | |
with: | |
name: python-package-distributions | |
path: dist/ | |
if: matrix.python-version == '3.12' && github.ref == 'refs/heads/master' | |
pypi: | |
if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' | |
environment: | |
name: pypi | |
url: https://test.pypi.org/p/chinese-whispers | |
permissions: | |
id-token: write | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Download packages | |
uses: actions/download-artifact@v4 | |
with: | |
name: packages | |
path: dist/ | |
- name: Publish to TestPyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
pages: | |
if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
permissions: | |
actions: read | |
id-token: write | |
pages: write | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 |