-
Notifications
You must be signed in to change notification settings - Fork 0
236 lines (188 loc) · 6.82 KB
/
01-python-package.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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: 01_ci-cd
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
name: build
runs-on: ubuntu-latest
needs: [ i18n ]
permissions:
checks: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pipenv
pipenv install --dev --ignore-pipfile
- name: Unit tests
run: |
pipenv run pytest -svv tests/ --junitxml=junit/unit-test-results-3.11.xml
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: unit-test-results-3.11
path: junit/unit-test-results-3.11.xml
- name: Publish Test Result
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: junit/unit-test-results-3.11.xml
check_name: Unit Tests
- uses: ./.github/actions/download-i18n
- name: build artifact
run: |
python -m pip install wheel
python setup.py sdist bdist_wheel
- uses: actions/upload-artifact@v4
with:
name: hexagon-${{ github.sha }}
path: dist/*.tar.gz
test:
name: test
runs-on: ${{ matrix.os }}
needs: [ i18n, build ]
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest ]
python-version: [ '3.9', '3.10', '3.11', '3.12' ]
permissions:
checks: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: actions/download-artifact@v4
with:
name: hexagon-${{ github.sha }}
path: dist
- name: Display structure of downloaded files
run: ls -R
working-directory: dist
- uses: ./.github/actions/download-i18n
- name: Setup e2e dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
artifact=$(ls dist/*.tar.gz)
python -m pip install $artifact
- name: e2e tests
uses: nick-fields/retry@v3
with:
timeout_minutes: 3
max_attempts: 3
retry_on: error
command: |
echo "Running e2e tests for Python ${{ matrix.python-version }}"
echo "COLUMNS: $COLUMNS, ROWS: $ROWS"
pytest -svv tests_e2e/ --junitxml=junit/e2e-test-results-${{ matrix.python-version }}.xml
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: e2e-test-results-${{ matrix.os }}-${{ matrix.python-version }}
path: junit/e2e-test-results-${{ matrix.python-version }}.xml
- name: Publish Test Result
uses: EnricoMi/publish-unit-test-result-action@v2
if: always() && matrix.os == 'ubuntu-latest'
continue-on-error: true
with:
files: junit/e2e-test-results-${{ matrix.python-version }}.xml
check_name: E2E Tests Python${{ matrix.python-version }}
- name: Publish Test Result MacOS
uses: EnricoMi/publish-unit-test-result-action/macos@v2
if: always() && matrix.os == 'macos-latest'
continue-on-error: true
with:
files: junit/e2e-test-results-${{ matrix.python-version }}.xml
check_name: E2E Tests Python${{ matrix.python-version }}
i18n:
name: i18n
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: install gettext
run: sudo apt-get install -y gettext
- name: add matcher
run: echo "::add-matcher::.github/i18n-problem-matcher.json"
- name: build locales
run: .github/scripts/i18n/build.sh
- name: validate translations
run: .github/scripts/i18n/check.sh
- name: upload artifact
uses: actions/upload-artifact@v4
with:
name: i18n
path: locales/**/*.mo
- name: remove matcher
run: echo "::remove-matcher owner=hexagon-i18n::"
release:
if: ${{ github.event_name != 'pull_request' && github.event_name != 'pull_request_target' }}
runs-on: ubuntu-latest
needs: [ build, test, i18n ]
environment:
name: pypi
url: https://pypi.org/project/hexagon/
permissions:
id-token: write
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.USER_TOKEN }}
- uses: ./.github/actions/download-i18n
- name: Python Semantic Release
id: release
uses: python-semantic-release/python-semantic-release@v9.8.8
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Publish package distributions to GitHub Releases
id: github-release
# 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'
uses: python-semantic-release/upload-to-gh-release@main
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.release.outputs.tag }}
# see https://docs.pypi.org/trusted-publishers/
- name: Publish package distributions to PyPI
id: pypi-publish
# 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'
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true
nightly:
if: ${{ github.event_name == 'pull_request' || github.event_name == 'pull_request_target' }}
runs-on: ubuntu-latest
needs: [ test ]
permissions:
pull-requests: write
steps:
- uses: marocchino/sticky-pull-request-comment@v2
with:
header: nightly
message: |
## Beta Available!
:rocket: see nightly build [details](https://nightly.link/${{ github.repository }}/actions/runs/${{ github.run_id }}/hexagon-${{ github.sha }})
Install locally with:
```bash
wget https://nightly.link/${{ github.repository }}/actions/runs/${{ github.run_id }}/hexagon-${{ github.sha }}.zip && unzip hexagon-${{ github.sha }}.zip && python3 -m pip install --find-links=. hexagon
```