Rye #125
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
# This workflow will install Python dependencies, run tests and lint with a single version of Python | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | |
name: CI | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
env: | |
POETRY_VERSION: 1.8.3 | |
jobs: | |
build: | |
name: poetry-build | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.10", "3.9"] | |
defaults: | |
run: | |
shell: bash -l {0} | |
permissions: | |
# Gives the action the necessary permissions for publishing new | |
# comments in pull requests. | |
pull-requests: write | |
# Gives the action the necessary permissions for pushing data to the | |
# python-coverage-comment-action branch, and for editing existing | |
# comments (to avoid publishing multiple comments in the same PR) | |
contents: write | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install the latest version of rye | |
uses: eifinger/setup-rye@v3 | |
- name: Install dependencies | |
run: | | |
rye sync --no-lock | |
- name: type check | |
run: | | |
rye run mypy src/ridgeplot | |
- name: format check | |
run: | | |
rye run pre-commit run --all-files --show-diff-on-failure | |
- name: Test with pytest | |
run: | | |
rye test -- -l -rPap -vvv -p no:warnings --cov | |
- uses: py-cov-action/python-coverage-comment-action@v3 | |
id: coverage_comment | |
if: ${{ matrix.python-version }} == "3.9" | |
with: | |
GITHUB_TOKEN: ${{ github.token }} | |
ANNOTATE_MISSING_LINES: true | |
- name: Store Pull Request comment to be posted | |
uses: actions/upload-artifact@v4 | |
if: steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true' | |
with: | |
name: python-coverage-comment-action | |
path: python-coverage-comment-action.txt | |
publish: | |
needs: build | |
if: github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Install poetry | |
uses: Gr1N/setup-poetry@v8 | |
with: | |
poetry-version: ${{ env.POETRY_VERSION }} | |
- name: publish to pypi | |
run: | | |
poetry self add poetry-dynamic-versioning | |
poetry publish --build --username __token__ --password ${{ secrets.PYPI_TOKEN }} | |
- name: push tag | |
run: | | |
gh release create $(poetry version --short) | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
deploy: | |
name: deploy doc | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/main' | |
needs: [publish, build] | |
steps: | |
- uses: actions/checkout@v2 | |
- name: setup | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.x | |
- name: build and deploy doc | |
run: | | |
pip install mkdocs-material mkdocstrings-python mkdocs | |
mkdocs gh-deploy --force |