Skip to content

Commit c44695c

Browse files
authored
Python CI speedups (#13646)
* revive attempt at CI speedup around python deps * skip service startup if not needed for matrix type
1 parent 4e90dc1 commit c44695c

File tree

1 file changed

+40
-17
lines changed

1 file changed

+40
-17
lines changed

.github/workflows/ci.yml

+40-17
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,36 @@ concurrency:
1313
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
1414
cancel-in-progress: true
1515
jobs:
16+
deps:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Check out repository
20+
uses: actions/checkout@v3
21+
- name: Install platform dependencies
22+
run: |
23+
sudo apt -y update
24+
sudo apt -y install libcurl4-openssl-dev libssl-dev pkg-config libxml2-dev libxslt-dev
25+
- uses: actions/setup-python@v4
26+
with:
27+
python-version-file: '.python-version'
28+
- name: pip cache
29+
uses: actions/cache@v3
30+
with:
31+
path: ~/.cache/pip
32+
key: pip-${{ runner.os }}
33+
- name: Cache built Python environment
34+
uses: actions/cache@v3
35+
with:
36+
path: ${{ env.pythonLocation }}
37+
key: ${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('requirements.txt', 'requirements/*.txt') }}
38+
- name: Install Python dependencies
39+
run: |
40+
pip install -U setuptools wheel pip
41+
pip install -r requirements.txt --no-deps
42+
pip install -r requirements/dev.txt
43+
pip check
1644
test:
45+
needs: deps
1746
strategy:
1847
matrix:
1948
include:
@@ -34,15 +63,15 @@ jobs:
3463
runs-on: ubuntu-latest
3564
services:
3665
postgres:
37-
image: postgres:14.4
66+
image: ${{ (matrix.name == 'Tests') && 'postgres:14.4' || '' }}
3867
ports:
3968
- 5432:5432
4069
env:
4170
POSTGRES_HOST_AUTH_METHOD: trust # never do this in production!
4271
# Set health checks to wait until postgres has started
4372
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
4473
stripe:
45-
image: stripe/stripe-mock:v0.140.0
74+
image: ${{ (matrix.name == 'Tests') && 'stripe/stripe-mock:v0.140.0' || '' }}
4675
ports:
4776
- 12111:12111
4877
name: ${{ matrix.name }}
@@ -54,27 +83,21 @@ jobs:
5483
- name: Install platform dependencies
5584
run: |
5685
sudo apt -y update
57-
sudo apt -y install libcurl4-openssl-dev libssl-dev pkg-config
86+
sudo apt -y install libcurl4-openssl-dev libssl-dev pkg-config libxml2-dev libxslt-dev
5887
- uses: actions/setup-python@v4
5988
with:
6089
python-version-file: '.python-version'
61-
cache: 'pip'
62-
cache-dependency-path: |
63-
requirements.txt
64-
requirements/*.txt
65-
- name: Cache common Python cache paths
90+
- name: Cache mypy results
91+
if: ${{ (matrix.name == 'Lint') }}
6692
uses: actions/cache@v3
6793
with:
6894
path: |
69-
.cache
70-
.mypy_cache
71-
${{ env.pythonLocation }}
95+
.mypy_cache
96+
key: ${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('requirements.txt', 'requirements/*.txt') }}
97+
- name: Restore built Python environment from deps
98+
uses: actions/cache/restore@v3
99+
with:
100+
path: ${{ env.pythonLocation }}
72101
key: ${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('requirements.txt', 'requirements/*.txt') }}
73-
- name: Install Python dependencies
74-
run: |
75-
pip install -U pip setuptools wheel
76-
pip install -r requirements.txt --no-deps
77-
pip install -r requirements/dev.txt
78-
pip check
79102
- name: Run ${{ matrix.name }}
80103
run: ${{ matrix.command }}

0 commit comments

Comments
 (0)