forked from mitmproxy/mitmproxy
-
Notifications
You must be signed in to change notification settings - Fork 0
328 lines (306 loc) · 10.8 KB
/
main.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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
name: CI
on:
push:
branches:
- '**'
- '!dependabot/**'
pull_request:
merge_group:
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
uses: mhils/workflows/.github/workflows/python-tox.yml@main
with:
cmd: tox -e lint
filename-matching:
uses: mhils/workflows/.github/workflows/python-tox.yml@main
with:
cmd: tox -e filename_matching
mypy:
uses: mhils/workflows/.github/workflows/python-tox.yml@main
with:
cmd: tox -e mypy
individual-coverage:
uses: mhils/workflows/.github/workflows/python-tox.yml@main
with:
cmd: tox -e individual_coverage
test:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
py: "3.12"
- os: windows-latest
py: "3.12"
- os: macos-latest
py: "3.12"
- os: ubuntu-latest
py: "3.11"
- os: ubuntu-latest
py: "3.10"
runs-on: ${{ matrix.os }}
steps:
- run: printenv
- uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.py }}
- run: pip install tox
- run: tox -e py
if: matrix.os != 'ubuntu-latest'
- name: Run tox -e py (without internet)
run: |
# install dependencies (requires internet connectivity)
tox -e py --notest
# run tests with loopback only. We need to sudo for unshare, which means we need an absolute path for tox.
sudo unshare --net -- sh -c "ip link set lo up; $(which tox) -e py"
if: matrix.os == 'ubuntu-latest'
- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
test-old-dependencies:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version-file: .github/python-version.txt
- run: pip install tox-uv
- run: tox -e old-dependencies
build:
strategy:
fail-fast: false
matrix:
include:
- image: macos-14
platform: macos-arm64
- image: macos-12
platform: macos-x86_64
- image: windows-2019
platform: windows
- image: ubuntu-20.04 # Oldest available version so we get oldest glibc possible.
platform: linux
runs-on: ${{ matrix.image }}
env:
CI_BUILD_KEY: ${{ secrets.CI_BUILD_KEY }}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version-file: .github/python-version.txt
- if: matrix.platform == 'windows'
uses: actions/cache@v4
with:
path: release/installbuilder/setup
key: installbuilder
- run: pip install .[dev] # pyinstaller 5.9 does not like pyproject.toml + editable installs.
- if: startsWith(matrix.platform, 'macos') && github.repository == 'mitmproxy/mitmproxy'
&& (startsWith(github.ref, 'refs/heads/') || startsWith(github.ref, 'refs/tags/'))
id: keychain
uses: apple-actions/import-codesign-certs@63fff01cd422d4b7b855d40ca1e9d34d2de9427d
with:
keychain: ${{ runner.temp }}/temp
p12-file-base64: ${{ secrets.APPLE_CERTIFICATE }}
p12-password: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
- if: startsWith(matrix.platform, 'macos') && github.repository == 'mitmproxy/mitmproxy'
&& (startsWith(github.ref, 'refs/heads/') || startsWith(github.ref, 'refs/tags/'))
run: |
python -u release/build.py macos-app \
--keychain "${{ runner.temp }}/temp.keychain" \
--team-id "S8XHQB96PW" \
--apple-id "${{ secrets.APPLE_ID }}" \
--password "${{ secrets.APPLE_APP_PASSWORD }}"
# Linux
- if: matrix.platform == 'linux'
run: python -u release/build.py standalone-binaries wheel
# Windows
- if: matrix.platform == 'windows'
run: python -u release/build.py standalone-binaries
- if: matrix.platform == 'windows' && github.repository == 'mitmproxy/mitmproxy' &&
(github.ref == 'refs/heads/citest' || startsWith(github.ref, 'refs/tags/'))
run: python -u release/build.py --dirty installbuilder-installer msix-installer
- uses: actions/upload-artifact@v4
with:
# artifacts must have different names, see https://github.com/actions/upload-artifact/issues/24
name: binaries.${{ matrix.platform }}
path: |
release/dist
test-web-ui:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-node@v4
with:
node-version-file: .github/node-version.txt
- name: Cache Node.js modules
uses: actions/cache@v4
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-
${{ runner.OS }}-
- working-directory: ./web
run: npm ci
- working-directory: ./web
run: npm test
- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./web/coverage/coverage-final.json
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-python@v5
with:
python-version-file: .github/python-version.txt
- run: |
wget -q https://github.com/gohugoio/hugo/releases/download/v0.92.1/hugo_extended_0.92.1_Linux-64bit.deb
echo "a9440adfd3ecce40089def287dee4e42ffae252ba08c77d1ac575b880a079ce6 hugo_extended_0.92.1_Linux-64bit.deb" | sha256sum -c
sudo dpkg -i hugo*.deb
- run: pip install -e .[dev]
- run: ./docs/build.py
- uses: actions/upload-artifact@v4
with:
name: docs
path: docs/public
# For releases, also build the archive version of the docs.
- if: startsWith(github.ref, 'refs/tags/')
run: ./docs/build.py
env:
DOCS_ARCHIVE: true
- if: startsWith(github.ref, 'refs/tags/')
uses: actions/upload-artifact@v4
with:
name: docs-archive
path: docs/public
check:
if: always()
needs:
- lint
- filename-matching
- mypy
- individual-coverage
- test
- test-old-dependencies
- test-web-ui
- build
- docs
uses: mhils/workflows/.github/workflows/alls-green.yml@main
with:
jobs: ${{ toJSON(needs) }}
# Separate from everything else because slow.
build-and-deploy-docker:
if: github.repository == 'mitmproxy/mitmproxy' && (
github.ref == 'refs/heads/main'
|| github.ref == 'refs/heads/citest'
|| startsWith(github.ref, 'refs/tags/')
)
environment: deploy-docker
needs: check
runs-on: ubuntu-latest
env:
DOCKER_USERNAME: mitmbot
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-python@v5
with:
python-version-file: .github/python-version.txt
- uses: actions/download-artifact@v4
with:
name: binaries.linux
path: release/dist
- uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0
- uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v1.6.0
- run: python release/build-and-deploy-docker.py
deploy:
# This action has access to our AWS keys, so we are extra careful here.
# In particular, we don't blindly `pip install` anything to minimize the risk of supply chain attacks.
if: github.repository == 'mitmproxy/mitmproxy' && (startsWith(github.ref, 'refs/heads/') || startsWith(github.ref, 'refs/tags/'))
environment: ${{ (github.ref == 'refs/heads/citest' || startsWith(github.ref, 'refs/tags/')) && 'deploy-release' || 'deploy-snapshot' }}
needs: check
runs-on: ubuntu-latest
permissions:
id-token: write
attestations: write
env:
# PyPI and MSFT keys are only available for the deploy-release environment
# The AWS access key for snapshots is scoped to branches/* as well.
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-west-2
MSFT_APP_ID: 9NWNDLQMNZD7
MSFT_TENANT_ID: ${{ secrets.MSFT_TENANT_ID }}
MSFT_CLIENT_ID: ${{ secrets.MSFT_CLIENT_ID }}
MSFT_CLIENT_SECRET: ${{ secrets.MSFT_CLIENT_SECRET }}
R2_ACCOUNT_ID: ${{ secrets.R2_ACCOUNT_ID }}
R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-python@v5
with:
python-version-file: .github/python-version.txt
- run: sudo apt-get update
- run: sudo apt-get install -y awscli
- if: startsWith(github.ref, 'refs/tags/')
run: sudo apt-get install -y twine
- uses: actions/download-artifact@v4
with:
name: docs
path: docs/public
- if: startsWith(github.ref, 'refs/tags/')
uses: actions/download-artifact@v4
with:
name: docs-archive
path: docs/archive
- uses: actions/download-artifact@v4
with:
pattern: binaries.*
merge-multiple: true
path: release/dist
- id: provenance
uses: actions/attest-build-provenance@v1
with:
subject-path: 'release/dist/*'
- run: mv ${{ steps.provenance.outputs.bundle-path }} release/dist/mitmproxy-${{ github.ref_name }}.sigstore
- run: ls docs/public
- run: ls release/dist
- run: ./release/deploy.py
- name: Deploy to Microsoft Store (test flight)
if: github.ref == 'refs/heads/citest'
run: ./release/deploy-microsoft-store.py release/dist/*.msix
env:
MSFT_APP_FLIGHT: 174ca570-8cae-4444-9858-c07293f1f13a
- name: Deploy to Microsoft Store
if: startsWith(github.ref, 'refs/tags/')
run: ./release/deploy-microsoft-store.py release/dist/*.msix