-
Notifications
You must be signed in to change notification settings - Fork 1
196 lines (168 loc) · 6.17 KB
/
stable.yml
File metadata and controls
196 lines (168 loc) · 6.17 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
name: AutoControl Stable CI
on:
push:
branches: [ "main", "stable" ]
pull_request:
branches: [ "main", "stable" ]
schedule:
- cron: "0 1 * * *"
permissions:
contents: read
concurrency:
group: stable-publish-${{ github.ref }}
cancel-in-progress: false
jobs:
test:
runs-on: windows-2022
strategy:
fail-fast: false
matrix:
python-version: [ "3.10", "3.11", "3.12", "3.13", "3.14" ]
steps:
- uses: actions/checkout@v4
- name: Set up 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 wheel
pip install -r dev_requirements.txt
pip install -e .
# Screen tests
- name: Test Screen Size
run: python ./test/unit_test/screen/screen_test.py
- name: Test Screenshot
run: python ./test/unit_test/screen/screenshot_test.py
- name: Test Screen Get Pixel
run: python ./test/unit_test/screen/get_pixel_test.py
- name: Upload Screenshot Artifact
uses: actions/upload-artifact@v4
if: always()
with:
name: screenshot_png_${{ matrix.python-version }}
path: test.png
if-no-files-found: ignore
# Keyboard tests
- name: Test Keyboard Type
run: python ./test/unit_test/keyboard/keyboard_type_test.py
- name: Test Keyboard Write
run: python ./test/unit_test/keyboard/keyboard_write_test.py
- name: Test Keyboard Is Press
run: python ./test/unit_test/keyboard/keyboard_is_press_test.py
- name: Test Keyboard Hotkey
run: python ./test/unit_test/keyboard/hotkey_test.py
# Mouse tests
- name: Test Mouse Module
run: python ./test/unit_test/mouse/mouse_test.py
continue-on-error: true
# Exception tests
- name: Test Exceptions
run: python ./test/unit_test/exception/auto_control_exception_test.py
# Critical exit tests
- name: Test Critical Exit
run: python ./test/unit_test/critical_exit/critical_exit_test.py
continue-on-error: true
- name: Test Real Critical Situation
run: python ./test/unit_test/critical_exit/real_critical_test.py
continue-on-error: true
# Record tests
- name: Test Record Module
run: python ./test/unit_test/record/record_test.py
- name: Test Total Record
run: python ./test/unit_test/total_record/total_record_test.py
# Executor tests
- name: Test Execute Action
run: python ./test/unit_test/execute_action/execute_action_test.py
# JSON tests
- name: Test JSON Module
run: python ./test/unit_test/json/json_test.py
# Report generation tests
- name: Test Generate JSON Report
run: python ./test/unit_test/generate_report/json_report.py
- name: Test Generate HTML Report
run: python ./test/unit_test/generate_report/html_report_test.py
# Argparse test
- name: Test Argparse
run: python ./test/unit_test/argparse/argparse_test.py
# Callback test
- name: Test Callback Module
run: python ./test/unit_test/callback/callback_test.py
# Project creation test
- name: Test Create Project
run: python ./test/unit_test/create_project_file/create_project_test.py
# Info tests
- name: Test Get Mouse Info
run: python ./test/unit_test/get_info/mouse_info.py
- name: Test Get Keyboard Info
run: python ./test/unit_test/get_info/keyboard_info.py
publish:
needs: test
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install build tooling
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Bump patch version in pyproject.toml
id: bump
run: |
python <<'PY'
import os
import re
import pathlib
path = pathlib.Path("pyproject.toml")
text = path.read_text(encoding="utf-8")
match = re.search(r'^version\s*=\s*"(\d+)\.(\d+)\.(\d+)"', text, flags=re.M)
if not match:
raise SystemExit("version line not found in pyproject.toml")
major, minor, patch = (int(part) for part in match.groups())
new_version = f"{major}.{minor}.{patch + 1}"
text = re.sub(
r'^version\s*=\s*"\d+\.\d+\.\d+"',
f'version = "{new_version}"',
text,
count=1,
flags=re.M,
)
path.write_text(text, encoding="utf-8")
with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as fh:
fh.write(f"new_version={new_version}\n")
print(f"Bumped to {new_version}")
PY
- name: Build distribution
run: python -m build
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: twine upload --non-interactive dist/*
- name: Commit and push version bump
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add pyproject.toml
git commit -m "Bump version to ${{ steps.bump.outputs.new_version }} [skip ci]"
git tag "v${{ steps.bump.outputs.new_version }}"
git pull --rebase origin main
git push origin main
git push origin "v${{ steps.bump.outputs.new_version }}"
- name: Create GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "v${{ steps.bump.outputs.new_version }}" \
dist/* \
--title "v${{ steps.bump.outputs.new_version }}" \
--generate-notes