Merge pull request #21 from tom65536/11-add-code-coverage #37
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"] | |
pull_request: | |
branches: ["main"] | |
jobs: | |
Static-Analysis: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.12 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install tox | |
- name: Run static checks with tox | |
run: tox run -e flake8,pre-commit,mypy,bandit,vermin | |
Unit-Tests: | |
strategy: | |
matrix: | |
python-version: ["3.11", "3.12", "3.13.0-beta.2"] | |
os: [ubuntu-latest, windows-latest] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install tox | |
- name: Run unit tests with tox | |
run: tox run -e pytest | |
- name: Codacy Coverage Reporter | |
uses: codacy/codacy-coverage-reporter-action@89d6c85cfafaec52c72b6c5e8b2878d33104c699 | |
if: matrix.python-version == '3.12' && matrix.os == 'ubuntu-latest' | |
with: | |
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} | |
coverage-reports: coverage.xml | |
Release: | |
needs: | |
- Static-Analysis | |
- Unit-Tests | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, 'chore(release):') | |
runs-on: ubuntu-latest | |
concurrency: release | |
environment: | |
name: pypi | |
url: https://pypi.org/project/annual | |
permissions: | |
id-token: write | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Python Semantic Release | |
uses: python-semantic-release/python-semantic-release@3ba53469e72452e7597dd5c61851e6fbf294420b # v9.8.3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Publish package distributions to PyPI | |
id: pypi-publish | |
if: steps.release.outputs.released == 'true' | |
uses: pypa/gh-action-pypi-publish@ec4db0b4ddc65acdf4bff5fa45ac92d78b56bdf0 # release/v1 | |
with: | |
verbose: true | |
- name: Publish package distributions to GitHub Releases | |
id: github-release | |
if: steps.release.outputs.released == 'true' | |
uses: python-semantic-release/upload-to-gh-release@fe6cc89b43d8cbf0f9ce3285df3f77ff69c9b5d4 # v9.8.3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
tag: ${{ steps.release.outputs.tag }} |