-
Notifications
You must be signed in to change notification settings - Fork 0
181 lines (175 loc) · 7.46 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
---
name: build
defaults:
run:
shell: bash
env:
POETRY_HOME: ~/.poetry
# renovate: datasource=github-tags depName=python-poetry/poetry
POETRY_VERSION: '1.8.5'
POETRY_VIRTUALENVS_IN_PROJECT: true
on: [push, pull_request]
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
fetch-depth: 2
- name: Identify Python version
run: echo "PYTHON_VERSION=$(python -V | cut -d' ' -f2)" >> "$GITHUB_ENV"
- name: Cache Poetry
id: cache-poetry
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4
with:
path: ${{ env.POETRY_HOME }}
key: poetry-${{ runner.os }}-${{ env.PYTHON_VERSION }}-${{ env.POETRY_VERSION }}
- name: Install Poetry
if: steps.cache-poetry.outputs.cache-hit != 'true'
run: curl -sSL https://install.python-poetry.org | python
- name: Prepend Poetry to PATH
run: echo ${{ env.POETRY_HOME }}/bin >> "$GITHUB_PATH"
- name: Cache venv
id: cache-venv
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ env.PYTHON_VERSION }}-${{ hashFiles('poetry.lock') }}
restore-keys: venv-${{ runner.os }}-${{ env.PYTHON_VERSION }}-
- name: Install dependencies
if: steps.cache-venv.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root --sync -v
- name: Install root package
run: poetry install --no-interaction --only-root -v
- name: Cache pre-commit hooks
id: cache-pre-commit
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ runner.os }}-${{ env.PYTHON_VERSION }}-${{ hashFiles('.pre-commit-config.yaml') }}
restore-keys: |
pre-commit-${{ runner.os }}-${{ env.PYTHON_VERSION }}-
pre-commit-${{ runner.os }}-
- name: Prune pre-commit hooks
if: steps.cache-pre-commit.outputs.cache-hit != 'true'
run: poetry run pre-commit gc
- name: Cache mypy
id: cache-mypy
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4
with:
path: .mypy_cache
key: mypy-${{ runner.os }}-${{ env.PYTHON_VERSION }}-${{ hashFiles('poetry.lock') }}-${{ github.sha }}
restore-keys: mypy-${{ runner.os }}-${{ env.PYTHON_VERSION }}-${{ hashFiles('poetry.lock') }}-
- name: Run gitlint
run: poetry run pre-commit run --color=always --hook-stage manual gitlint-ci
- name: Run pre-commit
run: poetry run pre-commit run --all-files --color=always --show-diff-on-failure
pytest:
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Check out repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
fetch-depth: 0
- name: Set up Python
id: setup-python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5
with:
python-version: ${{ matrix.python-version }}
- name: Cache Poetry
id: cache-poetry
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4
with:
path: ${{ env.POETRY_HOME }}
key: poetry-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ env.POETRY_VERSION }}
- name: Install Poetry
if: steps.cache-poetry.outputs.cache-hit != 'true'
run: curl -sSL https://install.python-poetry.org | python
- name: Prepend Poetry to PATH
run: echo ${{ env.POETRY_HOME }}/bin >> "$GITHUB_PATH"
- name: Cache venv
id: cache-venv
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('poetry.lock') }}
restore-keys: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-
- name: Install dependencies
if: steps.cache-venv.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root --sync -v
- name: Install root package
run: poetry install --no-interaction --only-root -v
- name: Run pytest
run: poetry run pytest --color=yes --cov-config=pyproject.toml --numprocesses=8 --with-functional
- name: Upload coverage report
uses: codecov/codecov-action@1e68e06f1dbfde0e4cefc87efeba9e4643565303 # v5.1.2
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Run SonarQube scanner
uses: SonarSource/sonarqube-scan-action@bfd4e558cda28cda6b5defafb9232d191be8c203 # v4.2.1
if: matrix.os != 'macos-latest'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
release:
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
needs: [pre-commit, pytest]
runs-on: ubuntu-latest
concurrency: release
permissions:
contents: write
id-token: write
steps:
- name: Check out repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
fetch-depth: 0
- name: Identify Python version
run: echo "PYTHON_VERSION=$(python -V | cut -d' ' -f2)" >> "$GITHUB_ENV"
- name: Cache Poetry
id: cache-poetry
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4
with:
path: ${{ env.POETRY_HOME }}
key: poetry-${{ runner.os }}-${{ env.PYTHON_VERSION }}-${{ env.POETRY_VERSION }}
- name: Install Poetry
if: steps.cache-poetry.outputs.cache-hit != 'true'
run: curl -sSL https://install.python-poetry.org | python
- name: Prepend Poetry to PATH
run: echo ${{ env.POETRY_HOME }}/bin >> "$GITHUB_PATH"
- name: Cache venv
id: cache-venv
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ env.PYTHON_VERSION }}-${{ hashFiles('poetry.lock') }}
restore-keys: venv-${{ runner.os }}-${{ env.PYTHON_VERSION }}-
- name: Install dependencies
if: steps.cache-venv.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root --sync -v
- name: Set up Git signing
uses: crazy-max/ghaction-import-gpg@cb9bde2e2525e640591a934b1fd28eef1dcaf5e5 # v6.2.0
with:
gpg_private_key: ${{ secrets.GPG_SIGN_KEY }}
git_user_signingkey: true
git_commit_gpgsign: true
git_tag_gpgsign: true
- name: Bump version
id: bump-version
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: poetry run semantic-release version
- name: Publish package distributions to GitHub Releases
if: steps.bump-version.outputs.released == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: poetry run semantic-release publish
- name: Publish package distributions to PyPI
if: steps.bump-version.outputs.released == 'true'
uses: pypa/gh-action-pypi-publish@67339c736fd9354cd4f8cb0b744f2b82a74b5c70 # v1.12.3