Skip to content

Commit 4d6df3b

Browse files
committed
github actions: run one job first to fill cache
1 parent 95af92a commit 4d6df3b

File tree

1 file changed

+80
-1
lines changed

1 file changed

+80
-1
lines changed

.github/workflows/tests.yaml

Lines changed: 80 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,83 @@
11
name: run tests
22
on: [push, pull_request]
33
jobs:
4+
setup-cache:
5+
runs-on: ubuntu-latest
6+
strategy:
7+
fail-fast: false
8+
matrix:
9+
python-version:
10+
- "3.13"
11+
deps:
12+
- httpx[http2]>=0.14.0
13+
exclude: []
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
- name: Setup Python ${{ matrix.python-version }}
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: ${{ matrix.python-version }}
21+
- name: Setup Cache
22+
uses: actions/cache@v4
23+
env:
24+
cache-name: cache-pip
25+
with:
26+
path: ~/.cache/pip
27+
key: ${{ runner.os }}-${{ env.cache-name }}-${{ matrix.deps }}-${{ hashFiles('pyproject.toml', 'setup.cfg') }}
28+
restore-keys: |
29+
${{ runner.os }}-${{ env.cache-name }}-${{ matrix.deps }}-
30+
${{ runner.os }}-${{ env.cache-name }}-
31+
32+
- name: Install pycurl deps
33+
if: ${{ contains(matrix.deps, 'pycurl') }}
34+
run: |
35+
sudo apt update
36+
sudo apt install -y libcurl4-openssl-dev
37+
# werkzeug is pinned for httpbin compatibility https://github.com/postmanlabs/httpbin/issues/673
38+
- name: Install Python deps
39+
env:
40+
# use env to avoid `>` being redirection
41+
deps: ${{ matrix.deps }}
42+
run: pip install -U $deps pytest 'pytest-asyncio>=0.24' pytest-httpbin pytest-rerunfailures structlog tomli platformdirs lxml jq 'werkzeug<2.1' awesomeversion
43+
# don't use binary distribution because:
44+
# hardcoded cacert path doesn't work on Ubuntu (should have been resolved?)
45+
# limited compression support (only deflate & gzip)
46+
- name: Install pycurl
47+
if: ${{ contains(matrix.deps, 'pycurl') }}
48+
run: |
49+
pip uninstall -y pycurl
50+
pip install -U pycurl --no-binary :all:
51+
- name: Decrypt keys
52+
env:
53+
KEY: ${{ secrets.KEY }}
54+
run: if [[ -n $KEY ]]; then openssl enc -d -aes-256-ctr -pbkdf2 -k $KEY -in keyfile.toml.enc -out keyfile.toml; fi
55+
56+
- name: Setup mitmproxy cache
57+
uses: actions/cache@v4
58+
env:
59+
cache-name: cache-mitm
60+
with:
61+
path: ~/.mitmproxy
62+
key: ${{ env.cache-name }}
63+
restore-keys: |
64+
${{ env.cache-name }}-
65+
- name: Install mitmproxy
66+
run: |
67+
/usr/bin/python -m venv --system-site-packages ~/.mitmproxy/venv
68+
. ~/.mitmproxy/venv/bin/activate
69+
pip install -U mitmproxy
70+
# https://github.com/DevToys-app/DevToys/issues/1373#issuecomment-2599820594
71+
sudo sysctl -w kernel.apparmor_restrict_unprivileged_unconfined=0
72+
sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
73+
74+
- name: Run pytest
75+
env:
76+
mitmdump: /home/runner/.mitmproxy/venv/bin/mitmdump
77+
run: scripts/run_cached_tests
78+
479
tests:
80+
needs: setup-cache
581
runs-on: ubuntu-latest
682
strategy:
783
fail-fast: false
@@ -24,7 +100,10 @@ jobs:
24100
# - aiohttp
25101
- tornado
26102
- httpx[http2]>=0.14.0
27-
exclude: []
103+
exclude:
104+
# this has been run as setup-cache
105+
- python-version: 3.13
106+
deps: httpx[http2]>=0.14.0
28107
steps:
29108
- name: Checkout code
30109
uses: actions/checkout@v4

0 commit comments

Comments
 (0)