Skip to content

Commit 7b57f15

Browse files
committed
try speeding up ci using caching and rearranging jobs
1 parent 8997cc5 commit 7b57f15

File tree

1 file changed

+53
-36
lines changed

1 file changed

+53
-36
lines changed

.github/workflows/ci.yml

Lines changed: 53 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ jobs:
5959
name: docs
6060
path: site
6161

62-
test-linux:
63-
name: test py${{ matrix.python-version }} on linux
62+
test-linux-compiled:
63+
name: test py${{ matrix.python-version }} on linux compiled
6464
runs-on: ubuntu-latest
6565
strategy:
6666
fail-fast: false
@@ -78,10 +78,20 @@ jobs:
7878
with:
7979
python-version: ${{ matrix.python-version }}
8080

81+
- uses: actions/cache@v2
82+
id: cache
83+
with:
84+
path: ${{ env.pythonLocation }}
85+
key: >
86+
${{ runner.os }}
87+
${{ env.pythonLocation }}
88+
${{ hashFiles('setup.py') }}
89+
${{ hashFiles('requirements.txt') }}
90+
${{ hashFiles('tests/requirements-testing.txt') }}
91+
8192
- name: install
82-
run: |
83-
make install-testing
84-
pip freeze
93+
if: steps.cache.outputs.cache-hit != 'true'
94+
run: make install-testing
8595

8696
- name: compile
8797
run: |
@@ -92,46 +102,29 @@ jobs:
92102
93103
- run: mkdir coverage
94104

95-
- name: test compiled and deps
96-
run: make test
97-
env:
98-
COVERAGE_FILE: coverage/.coverage.linux-py${{ matrix.python-version }}-cY-dY
99-
CONTEXT: linux-py${{ matrix.python-version }}-compiled-yes-deps-yes
100-
101-
- name: uninstall deps
102-
run: pip uninstall -y cython email-validator devtools python-dotenv
103-
104-
- name: test compiled without deps
105-
run: make test
106-
env:
107-
COVERAGE_FILE: coverage/.coverage.linux-py${{ matrix.python-version }}-cY-dN
108-
CONTEXT: linux-py${{ matrix.python-version }}-compiled-yes-deps-no
109-
110-
- name: remove compiled binaries
111-
run: |
112-
rm -r pydantic/*.so pydantic/*.c pydantic/__pycache__
113-
ls -alh
114-
ls -alh pydantic/
115-
116-
- name: test uncompiled without deps
105+
- name: test
117106
run: make test
118107
env:
119-
COVERAGE_FILE: coverage/.coverage.linux-py${{ matrix.python-version }}-cN-dN
120-
CONTEXT: linux-py${{ matrix.python-version }}-compiled-no-deps-no
108+
COVERAGE_FILE: coverage/.coverage.linux-py${{ matrix.python-version }}-compiled
109+
CONTEXT: linux-py${{ matrix.python-version }}-compiled
121110

122111
- name: store coverage files
123112
uses: actions/upload-artifact@v2
124113
with:
125114
name: coverage
126115
path: coverage
127116

128-
test-windows-mac:
129-
name: test py${{ matrix.python-version }} on ${{ matrix.os }}
117+
test-uncompiled:
118+
name: test py${{ matrix.python-version }} on ${{ matrix.platform || matrix.os }}
130119
strategy:
131120
fail-fast: false
132121
matrix:
133-
os: [macos, windows]
122+
os: [ubuntu, macos, windows]
134123
python-version: ['3.7', '3.8', '3.9', '3.10']
124+
include:
125+
- os: ubuntu
126+
platform: linux
127+
135128
env:
136129
PYTHON: ${{ matrix.python-version }}
137130
OS: ${{ matrix.os }}
@@ -147,16 +140,40 @@ jobs:
147140
with:
148141
python-version: ${{ matrix.python-version }}
149142

143+
- uses: actions/cache@v2
144+
id: cache
145+
with:
146+
path: ${{ env.pythonLocation }}
147+
key: >
148+
${{ runner.os }}
149+
${{ env.pythonLocation }}
150+
${{ hashFiles('setup.py') }}
151+
${{ hashFiles('requirements.txt') }}
152+
${{ hashFiles('tests/requirements-testing.txt') }}
153+
150154
- name: install
151155
run: make install-testing
156+
if: steps.cache.outputs.cache-hit != 'true'
157+
158+
- run: pip freeze
159+
if: steps.cache.outputs.cache-hit != 'true'
152160

153161
- run: mkdir coverage
154162

155-
- name: test
163+
- name: test with deps
164+
run: make test
165+
env:
166+
COVERAGE_FILE: coverage/.coverage.${{ matrix.platform || matrix.os }}-py${{ matrix.python-version }}-with-deps
167+
CONTEXT: ${{ matrix.platform || matrix.os }}-py${{ matrix.python-version }}-with-deps
168+
169+
- name: uninstall deps
170+
run: pip uninstall -y cython email-validator devtools python-dotenv
171+
172+
- name: test without deps
156173
run: make test
157174
env:
158-
COVERAGE_FILE: coverage/.coverage.${{ matrix.os }}-py${{ matrix.python-version }}
159-
CONTEXT: ${{ matrix.os }}-py${{ matrix.python-version }}
175+
COVERAGE_FILE: coverage/.coverage.${{ matrix.platform || matrix.os }}-py${{ matrix.python-version }}-without-deps
176+
CONTEXT: ${{ matrix.platform || matrix.os }}-py${{ matrix.python-version }}-without-deps
160177

161178
- name: store coverage files
162179
uses: actions/upload-artifact@v2
@@ -224,7 +241,7 @@ jobs:
224241

225242
- run: pip install coverage
226243

227-
- run: ls -la
244+
- run: ls -la coverage
228245
- run: coverage combine coverage
229246
- run: coverage report
230247
- run: coverage html --show-contexts

0 commit comments

Comments
 (0)