Update README.md #20
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: CI | |
on: | |
push: | |
branches: [main] | |
tags: [v*] | |
pull_request: | |
jobs: | |
lint-test: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.12"] | |
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 Poetry | |
run: pipx install poetry==1.8.2 | |
- name: Configure Poetry | |
run: poetry config virtualenvs.in-project true | |
- name: Cache dependencies | |
uses: actions/cache@v3 | |
with: | |
path: | | |
.venv | |
~/.cache/pypoetry | |
key: ${{ runner.os }}-poetry-${{ hashFiles('pyproject.toml') }} | |
- name: Install dependencies | |
run: poetry install --with dev --no-interaction | |
- name: Validate project | |
run: poetry check | |
- name: Check formatting | |
run: poetry run black --check . | |
- name: Lint with flake8 | |
run: poetry run flake8 timemesh tests | |
- name: Static type checking | |
run: poetry run mypy timemesh | |
- name: Run tests | |
run: | | |
poetry run pytest -v \ | |
--cov=timemesh \ | |
--cov-report=xml:coverage.xml \ | |
--cov-fail-under=80 | |
- name: Upload coverage | |
uses: codecov/codecov-action@v3 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
files: coverage.xml | |
deploy: | |
runs-on: ubuntu-latest | |
needs: lint-test | |
if: startsWith(github.ref, 'refs/tags/v') | |
environment: production | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12" | |
- name: Install Poetry | |
run: pipx install poetry==1.8.2 | |
- name: Verify version | |
run: | | |
poetry_version=$(poetry version -s) | |
git_tag_version=${GITHUB_REF#refs/tags/v} | |
[ "$poetry_version" = "$git_tag_version" ] || exit 1 | |
- name: Build package | |
run: poetry build | |
- name: Publish to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 |