| 1 |
name: CI |
| 2 |
|
| 3 |
on: |
| 4 |
push: |
| 5 |
branches: |
| 6 |
- main |
| 7 |
pull_request: |
| 8 |
|
| 9 |
concurrency: |
| 10 |
group: ${{ github.head_ref || github.run_id }} |
| 11 |
cancel-in-progress: true |
| 12 |
|
| 13 |
jobs: |
| 14 |
lint: |
| 15 |
runs-on: ubuntu-latest |
| 16 |
steps: |
| 17 |
- uses: actions/checkout@v4 |
| 18 |
- uses: actions/setup-python@v5 |
| 19 |
with: |
| 20 |
python-version: 3.x |
| 21 |
- uses: pre-commit/[email protected] |
| 22 |
|
| 23 |
# Make sure commit messages follow the conventional commits convention: |
| 24 |
# https://www.conventionalcommits.org |
| 25 |
commitlint: |
| 26 |
name: Lint Commit Messages |
| 27 |
runs-on: ubuntu-latest |
| 28 |
steps: |
| 29 |
- uses: actions/checkout@v4 |
| 30 |
with: |
| 31 |
fetch-depth: 0 |
| 32 |
- uses: wagoid/[email protected] |
| 33 |
|
| 34 |
test: |
| 35 |
strategy: |
| 36 |
fail-fast: false |
| 37 |
matrix: |
| 38 |
python-version: |
| 39 |
- "3.8" |
| 40 |
- "3.9" |
| 41 |
- "3.10" |
| 42 |
- "3.11" |
| 43 |
- "3.12" |
| 44 |
os: |
| 45 |
- ubuntu-latest |
| 46 |
runs-on: ${{ matrix.os }} |
| 47 |
steps: |
| 48 |
- uses: actions/checkout@v4 |
| 49 |
- name: Install poetry |
| 50 |
run: pipx install poetry |
| 51 |
- name: Set up Python |
| 52 |
uses: actions/setup-python@v5 |
| 53 |
id: setup-python |
| 54 |
with: |
| 55 |
python-version: ${{ matrix.python-version }} |
| 56 |
cache: poetry |
| 57 |
- name: Install Dependencies |
| 58 |
run: | |
| 59 |
if [ "${{ matrix.extension }}" = "skip_cython" ]; then |
| 60 |
SKIP_CYTHON=1 poetry install --only=main,dev |
| 61 |
else |
| 62 |
REQUIRE_CYTHON=1 poetry install --only=main,dev |
| 63 |
fi |
| 64 |
- name: Test with Pytest |
| 65 |
run: poetry run pytest |
| 66 |
shell: bash |
| 67 |
- name: Upload coverage to Codecov |
| 68 |
uses: codecov/codecov-action@v4 |
| 69 |
with: |
| 70 |
token: ${{ secrets.CODECOV_TOKEN }} |
| 71 |
|
| 72 |
release: |
| 73 |
needs: |
| 74 |
- test |
| 75 |
- lint |
| 76 |
- commitlint |
| 77 |
|
| 78 |
runs-on: ubuntu-latest |
| 79 |
environment: release |
| 80 |
concurrency: release |
| 81 |
permissions: |
| 82 |
id-token: write |
| 83 |
contents: write |
| 84 |
|
| 85 |
steps: |
| 86 |
- uses: actions/checkout@v4 |
| 87 |
with: |
| 88 |
fetch-depth: 0 |
| 89 |
ref: ${{ github.head_ref || github.ref_name }} |
| 90 |
|
| 91 |
# Do a dry run of PSR |
| 92 |
- name: Test release |
| 93 |
uses: python-semantic-release/[email protected] |
| 94 |
if: github.ref_name != 'main' |
| 95 |
with: |
| 96 |
root_options: --noop |
| 97 |
|
| 98 |
# On main branch: actual PSR + upload to PyPI & GitHub |
| 99 |
- name: Release |
| 100 |
uses: python-semantic-release/[email protected] |
| 101 |
id: release |
| 102 |
if: github.ref_name == 'main' |
| 103 |
with: |
| 104 |
github_token: ${{ secrets.GITHUB_TOKEN }} |
| 105 |
|
| 106 |
- name: Publish package distributions to PyPI |
| 107 |
uses: pypa/gh-action-pypi-publish@release/v1 |
| 108 |
if: steps.release.outputs.released == 'true' |
| 109 |
|
| 110 |
- name: Publish package distributions to GitHub Releases |
| 111 |
uses: python-semantic-release/upload-to-gh-release@main |
| 112 |
if: steps.release.outputs.released == 'true' |
| 113 |
with: |
| 114 |
github_token: ${{ secrets.GITHUB_TOKEN }} |