-
Notifications
You must be signed in to change notification settings - Fork 3
154 lines (147 loc) · 5.21 KB
/
Copy pathstable.yml
File metadata and controls
154 lines (147 loc) · 5.21 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
name: PyBreeze Stable
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
- cron: "0 2 * * *"
permissions:
contents: read
jobs:
unit-tests:
runs-on: windows-latest
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: Update pip wheel setuptools
run: python -m pip install --upgrade pip setuptools wheel
- name: Install dependencies
run: python -m pip install -r requirements.txt
- name: Install test tooling
run: python -m pip install pytest pytest-cov hypothesis
- name: Run unit tests (pytest)
run: python -m pytest test/test_utils/ -v --tb=short --cov=pybreeze --cov-branch --cov-report=xml
- name: Upload coverage for analysis
# One leg is enough; the scanner only consumes a single report.
if: matrix.python-version == '3.12'
uses: actions/upload-artifact@v4
with:
name: coverage-xml
path: coverage.xml
if-no-files-found: error
- name: Run AutomationEditor With Debug Mode
run: python ./test/unit_test/start_automation/start_automation_test.py
env:
PYTHONPATH: .
- name: Extend AutomationEditor
run: python ./test/unit_test/start_automation/extend_automation_test.py
env:
PYTHONPATH: .
sonarcloud:
# Automatic Analysis is off, so main-branch and pull-request analysis both
# come from here. Skipped on the nightly schedule, where re-scanning an
# unchanged commit adds nothing, and on fork pull requests, which cannot
# read the token.
if: >-
github.event_name != 'schedule' &&
(github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name == github.repository)
needs: unit-tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
# Sonar needs the full history to attribute new code to the right commits.
fetch-depth: 0
- name: Download coverage
uses: actions/download-artifact@v4
with:
name: coverage-xml
- name: Read package version
# Without a version, SonarCloud's "previous version" new-code baseline has
# nothing to anchor to and counts the whole history as new -- which is how
# new_lines came to exceed the project's total line count.
id: version
run: echo "value=$(grep -m1 '^version = ' pyproject.toml | cut -d'"' -f2)" >> "$GITHUB_OUTPUT"
- name: SonarQube Cloud scan
uses: SonarSource/sonarqube-scan-action@v8.2.1
with:
args: -Dsonar.projectVersion=${{ steps.version.outputs.value }}
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: https://sonarcloud.io
publish:
needs: unit-tests
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: Bump patch version
id: bump
run: |
python - <<'PY'
import os
import pathlib
import re
path = pathlib.Path("pyproject.toml")
text = path.read_text(encoding="utf-8")
match = re.search(r'^version = "(\d+)\.(\d+)\.(\d+)"', text, re.M)
if match is None:
raise SystemExit("version line not found in pyproject.toml")
major, minor, patch = map(int, match.groups())
new_version = f"{major}.{minor}.{patch + 1}"
new_text = re.sub(
r'^version = "\d+\.\d+\.\d+"',
f'version = "{new_version}"',
text,
count=1,
flags=re.M,
)
path.write_text(new_text, encoding="utf-8")
with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as fh:
fh.write(f"new_version={new_version}\n")
PY
- name: Install build tools
run: python -m pip install --upgrade pip build twine
- name: Build package
run: python -m build
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: python -m twine upload dist/*
- name: Commit and tag 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 stable version to ${{ steps.bump.outputs.new_version }}"
git tag "v${{ steps.bump.outputs.new_version }}"
git push origin HEAD: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 }}" \
--title "v${{ steps.bump.outputs.new_version }}" \
--generate-notes \
--latest \
dist/*