Debian Codegraph @

.github/workflows/ci.yml

raw
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.10"
40 - "3.11"
41 - "3.12"
42 - "3.13"
43 - "3.14"
44 os:
45 - ubuntu-latest
46 - windows-latest
47 - macOS-latest
48 runs-on: ${{ matrix.os }}
49 steps:
50 - uses: actions/checkout@v4
51 - name: Install poetry
52 run: pipx install poetry
53 - name: Set up Python
54 uses: actions/setup-python@v5
55 id: setup-python
56 with:
57 python-version: ${{ matrix.python-version }}
58 cache: poetry
59 - name: Install Dependencies
60 run: poetry install
61 shell: bash
62 - name: Test with Pytest
63 run: poetry run pytest
64 shell: bash
65 - name: Upload coverage to Codecov
66 uses: codecov/codecov-action@v4
67 with:
68 token: ${{ secrets.CODECOV_TOKEN }}
69
70 release:
71 needs:
72 - test
73 - lint
74 - commitlint
75
76 runs-on: ubuntu-latest
77 environment: release
78 concurrency: release
79 permissions:
80 id-token: write
81 attestations: write
82 contents: write
83
84 steps:
85 - uses: actions/checkout@v4
86 with:
87 fetch-depth: 0
88 ref: ${{ github.head_ref || github.ref_name }}
89
90 # Do a dry run of PSR
91 - name: Test release
92 uses: python-semantic-release/[email protected]
93 if: github.ref_name != 'main'
94 with:
95 root_options: --noop
96
97 # On main branch: actual PSR + upload to PyPI & GitHub
98 - name: Release
99 uses: python-semantic-release/[email protected]
100 id: release
101 if: github.ref_name == 'main'
102 with:
103 github_token: ${{ secrets.GITHUB_TOKEN }}
104
105 - name: Attest build provenance
106 uses: actions/attest-build-provenance@v1
107 if: steps.release.outputs.released == 'true'
108 with:
109 subject-path: "dist/*"
110
111 - name: Publish package distributions to PyPI
112 uses: pypa/gh-action-pypi-publish@release/v1
113 if: steps.release.outputs.released == 'true'
114
115 - name: Zip Chrome extension
116 if: steps.release.outputs.released == 'true'
117 run: zip -r chrome-extension.zip chrome-extension/
118
119 - name: Publish package distributions to GitHub Releases
120 uses: python-semantic-release/upload-to-gh-release@main
121 if: steps.release.outputs.released == 'true'
122 with:
123 github_token: ${{ secrets.GITHUB_TOKEN }}
124
125 - name: Upload Chrome extension to GitHub Release
126 if: steps.release.outputs.released == 'true'
127 env:
128 GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
129 run: gh release upload ${{ steps.release.outputs.tag }} chrome-extension.zip