-
Notifications
You must be signed in to change notification settings - Fork 0
288 lines (252 loc) · 10.1 KB
/
ci.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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
name: Dev build CI
on:
push:
paths-ignore:
- 'README**'
branches:
- '**'
tags:
- 'v*'
pull_request:
branches:
- '*'
paths-ignore:
- 'README**'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
permissions:
id-token: write
contents: write
checks: write
packages: write
env:
PREFERED_PYTHON_VERSION: '3.12'
WEBPODA_AUTH_CODE: ${{ secrets.WEBPODA_AUTH_CODE }}
jobs:
qa:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pre-commit/[email protected]
build:
strategy:
matrix:
python-versions: ['3.10', '3.11', '3.12']
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
# map step outputs to job outputs so they can be share among jobs
outputs:
package_version: ${{ env.PACKAGE_VERSION }}
package_name: ${{ env.PACKAGE_NAME }}
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-versions }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
- name: Declare version variables for dev builds
id: variables_step_dev
run: |
# Override the version with a dev suffix because we are not on a tag. Tag builds pull version directly from pyproject.toml
poetry version $(poetry version --short)-dev.$GITHUB_RUN_NUMBER
echo "Using version from pyproject.toml file with dev suffix (because not on a tag): $(poetry version --short)"
echo "PACKAGE_NAME=$(poetry version | awk '{print $1}')" >> $GITHUB_ENV
echo "PACKAGE_VERSION=$(poetry version --short)" >> $GITHUB_ENV
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
shell: bash
- name: Declare variables PACKAGE_NAME and PACKAGE_VERSION
id: variables_step
run: |
echo "Version used by poetry: $(poetry version --short)"
echo "PACKAGE_NAME=$(poetry version | awk '{print $1}')" >> $GITHUB_ENV
echo "PACKAGE_VERSION=$(poetry version --short)" >> $GITHUB_ENV
shell: bash
- name: build
run: ./build.sh
- name: Build wheels and source tarball
run: ./pack.sh
- name: Create Version file
run: echo "Version ${{ env.PACKAGE_VERSION }}, SHA ${{ github.sha }}, Ref ${{ github.ref_name }}" > dist/python${{matrix.python-versions}}/version.txt
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
if: matrix.python-versions == env.PREFERED_PYTHON_VERSION
- name: Login to GitHub Container registry ghcr.io
uses: docker/login-action@v3
if: matrix.python-versions == env.PREFERED_PYTHON_VERSION
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get image metadata
id: meta
uses: docker/metadata-action@v5
if: matrix.python-versions == env.PREFERED_PYTHON_VERSION
with:
images: ghcr.io/${{ github.repository }}
tags: |
# minimal
type=semver,pattern={{version}}
# use custom value instead of git tag
type=semver,pattern={{version}},value=${{ env.PACKAGE_VERSION }}
# set latest tag for default branch
type=raw,value=latest
# branch event
type=ref,event=branch
# pull request event
type=ref,event=pr
- name: Build and push Docker image
uses: docker/build-push-action@v6
if: matrix.python-versions == env.PREFERED_PYTHON_VERSION
with:
context: .
file: deploy/Dockerfile
push: true
tags: |
${{ steps.meta.outputs.tags }}
- name: Zip up the folder
run: zip -r ${{ env.PACKAGE_NAME }}_python${{matrix.python-versions}}_${{ env.PACKAGE_VERSION }}.zip python${{matrix.python-versions}}
working-directory: dist
- name: Upload python wheel/tarball
uses: actions/upload-artifact@v4
with:
name: ${{ env.PACKAGE_NAME }}_python${{matrix.python-versions}}_${{ env.PACKAGE_VERSION }}.zip
path: dist/${{ env.PACKAGE_NAME }}_python${{matrix.python-versions}}_${{ env.PACKAGE_VERSION }}.zip
if-no-files-found: error
- name: Upload Coverage report
uses: actions/upload-artifact@v4
if: matrix.python-versions == env.PREFERED_PYTHON_VERSION
with:
name: CoverageReport_python${{matrix.python-versions}}_${{ env.PACKAGE_VERSION }}
path: htmlcov
if-no-files-found: error
- name: Test Report
uses: dorny/test-reporter@v1
if: success() || failure()
with:
name: Test Results (${{ matrix.python-versions }})
path: 'test-results.xml'
reporter: java-junit
- name: Create Release ${{github.ref_name}} & upload artifacts
uses: softprops/action-gh-release@v2
if: ${{ startsWith(github.ref, 'refs/tags/') }}
with:
draft: false
prerelease: false
fail_on_unmatched_files: true
files: |
dist/${{ env.PACKAGE_NAME }}_python${{matrix.python-versions}}_${{ env.PACKAGE_VERSION }}.zip
test_on_windows:
strategy:
matrix:
python-versions: ['3.10', '3.11', '3.12']
os: [windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-versions }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
poetry install
- name: Run tests
run: poetry run pytest -s --cov-config=.coveragerc --cov=src --cov-append --cov-report=xml --cov-report term-missing --cov-report=html --junitxml=test-results.xml tests
- name: Upload Coverage report
uses: actions/upload-artifact@v4
if: matrix.python-versions == env.PREFERED_PYTHON_VERSION
with:
name: CoverageReport_${{ matrix.os }}_python${{matrix.python-versions}}_${{ env.PACKAGE_VERSION }}
path: htmlcov
if-no-files-found: error
- name: Test Report
uses: dorny/test-reporter@v1
if: success() || failure()
with:
name: Test Results (${{ matrix.os }}) (${{ matrix.python-versions }})
path: 'test-results.xml'
reporter: java-junit
build_single_file_binary:
strategy:
matrix:
os: [linux, windows]
include:
- os: linux
image: batonogov/pyinstaller-linux:latest
executable: imap-mag
folder: manylinux_2_36_x86_64
- os: windows
image: batonogov/pyinstaller-windows:latest
executable: imap-mag.exe
folder: win_amd64
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PREFERED_PYTHON_VERSION }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
- name: Set REVISION
run: echo "REVISION=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: Declare version variables for dev builds
id: variables_step_dev
run: |
# Override the version with a dev suffix because we are not on a tag. Tag builds pull version directly from pyproject.toml
poetry version $(poetry version --short)-dev.$GITHUB_RUN_NUMBER
echo "Using version from pyproject.toml file with dev suffix (because not on a tag): $(poetry version --short)"
echo "PACKAGE_NAME=$(poetry version | awk '{print $1}')" >> $GITHUB_ENV
echo "PACKAGE_VERSION=$(poetry version --short)" >> $GITHUB_ENV
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
shell: bash
- name: Declare variables PACKAGE_NAME and PACKAGE_VERSION
id: variables_step
run: |
echo "Version used by poetry: $(poetry version --short)"
echo "PACKAGE_NAME=$(poetry version | awk '{print $1}')" >> $GITHUB_ENV
echo "PACKAGE_VERSION=$(poetry version --short)" >> $GITHUB_ENV
shell: bash
- uses: addnab/docker-run-action@v3
with:
registry: gcr.io
image: ${{ matrix.image }}
options: -v ${{ github.workspace }}:/src/
run: |
python -m pip install poetry
python -m poetry self add poetry-pyinstaller-plugin
python -m poetry install
python -m poetry build
if [ ! -f dist/pyinstaller/${{ matrix.folder }}/${{ matrix.executable }} ]
then
echo "Cannot find dist/pyinstaller/${{ matrix.folder }}/${{ matrix.executable }}"
exit 1
fi
- name: Zip up the binary
run: |
sudo chown -R $(whoami):$(whoami) .
cp pyinstaller/${{ matrix.folder }}/${{ matrix.executable}} .
zip -r ${{ env.PACKAGE_NAME }}_${{ matrix.executable }}_v${{ env.PACKAGE_VERSION }}.zip ${{ matrix.executable }}
echo "PACKAGE_ZIP=${{ env.PACKAGE_NAME }}_${{ matrix.executable }}_v${{ env.PACKAGE_VERSION }}.zip" >> $GITHUB_ENV
working-directory: dist
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ env.PACKAGE_ZIP }}
path: dist/${{ env.PACKAGE_ZIP }}
if-no-files-found: error
- name: Upload artifacts to release (tagged only))
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
draft: false
prerelease: false
fail_on_unmatched_files: true
files: |
dist/${{ env.PACKAGE_ZIP }}