Repository navigation
202 lines (191 loc) · 6.33 KB
/
Copy pathci.yml
File metadata and controls
202 lines (191 loc) · 6.33 KB
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
name: CI
on:
push:
branches:
- main
pull_request:
concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
# Default Python version for tooling jobs (lint, build, test-release)
DEFAULT_PYTHON_VERSION: "3.11"
# Matrix Python version that collects branch coverage and uploads to Codecov
COVERAGE_PYTHON_VERSION: "3.14"
jobs:
# Make sure commit messages follow the conventional commits convention:
# https://www.conventionalcommits.org
commitlint:
name: Lint Commit Messages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: wagoid/commitlint-github-action@v6.2.1
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: ${{ env.DEFAULT_PYTHON_VERSION }}
- uses: pre-commit/action@v3.0.1
test:
strategy:
fail-fast: false
matrix:
# Keep COVERAGE_PYTHON_VERSION in sync with this matrix
python-version:
- "3.11" # Minimum supported Python version
- "3.14" # Latest supported Python version (coverage)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up uv
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}
activate-environment: true
enable-cache: true
- name: Test with Pytest
run: >-
uv run pytest -n auto
${{ matrix.python-version == env.COVERAGE_PYTHON_VERSION && '--cov --cov-branch --cov-report=xml' || '' }}
shell: bash
- name: Upload results to Codecov
if: matrix.python-version == env.COVERAGE_PYTHON_VERSION
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: Python-roborock/python-roborock
test-mqtt:
strategy:
fail-fast: false
matrix:
# Keep COVERAGE_PYTHON_VERSION in sync with this matrix
python-version:
- "3.11" # Minimum supported Python version
- "3.14" # Latest supported Python version (coverage)
runs-on: ubuntu-latest
services:
emqx:
image: emqx/emqx:6.2.3
ports:
- 1888:1883
options: >-
--health-cmd "/opt/emqx/bin/emqx ctl status"
--health-interval 1s
--health-timeout 25s
--health-retries 25
steps:
- uses: actions/checkout@v6
- name: Set up uv
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}
activate-environment: true
enable-cache: true
- name: Test MQTT with Pytest
run: >-
uv run pytest -m mqtt_broker
${{ matrix.python-version == env.COVERAGE_PYTHON_VERSION && '--cov --cov-branch --cov-report=xml' || '' }}
- name: Upload results to Codecov
if: matrix.python-version == env.COVERAGE_PYTHON_VERSION
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: Python-roborock/python-roborock
build:
name: Build Package
runs-on: ubuntu-latest
if: github.ref != 'refs/heads/main'
steps:
- uses: actions/checkout@v6
- name: Set up uv
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ env.DEFAULT_PYTHON_VERSION }}
activate-environment: true
enable-cache: true
- name: Build package
run: uv build
# Test semantic-release configuration on PR branches
test-release:
name: Test Semantic Release
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up uv
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ env.DEFAULT_PYTHON_VERSION }}
enable-cache: true
- name: Setup Git for Semantic Release Testing
run: |
# Setup a temp branch to test
git checkout -B temp-main-branch
git merge ${{ github.event.pull_request.head.sha }} --no-edit
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
- name: Test Semantic Release (Dry Run)
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Keep version in sync with python-semantic-release action in the release job
run: >-
uv tool run --from python-semantic-release==10.5.3
semantic-release version --changelog --no-commit --no-tag --no-push --no-vcs-release
release:
runs-on: ubuntu-latest
needs:
- test
- test-mqtt
concurrency: release
if: github.ref == 'refs/heads/main'
permissions:
contents: write
issues: write
pull-requests: write
id-token: write
actions: write
packages: write
environment:
name: release
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
persist-credentials: false
- name: Create release GitHub App token
id: release-token
uses: actions/create-github-app-token@v3
with:
client-id: ${{ vars.RELEASE_APP_CLIENT_ID }}
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
permission-contents: write
- name: Python Semantic Release
id: release
uses: python-semantic-release/python-semantic-release@v10.5.3
with:
# The release App is allowed to bypass the pull-request requirement so
# semantic-release can commit the version and changelog back to main.
github_token: ${{ steps.release-token.outputs.token }}
changelog: true
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@v1.14.2
# NOTE: DO NOT wrap the conditional in ${{ }} as it will always evaluate to true.
# See https://github.com/actions/runner/issues/1173
if: steps.release.outputs.released == 'true'
with:
packages-dir: dist
print-hash: true
verbose: true
- name: Publish package distributions to GitHub Releases
uses: python-semantic-release/publish-action@v10.5.3
if: steps.release.outputs.released == 'true'
with:
github_token: ${{ steps.release-token.outputs.token }}
tag: ${{ steps.release.outputs.tag }}