@@ -10,20 +10,28 @@ jobs:
10
10
test :
11
11
if : github.repository_owner == 'hackingmaterials' # don't run on forks
12
12
runs-on : ubuntu-latest
13
+ strategy :
14
+ matrix :
15
+ # pytest-split groups for automatically equally split concurrent test runners
16
+ group : [1, 2, 3, 4, 5]
13
17
services :
14
18
mongodb :
15
19
image : mongo
16
20
ports :
17
21
- 27017:27017
18
22
19
23
steps :
20
- - name : Checkout repo
21
- uses : actions/checkout@v2
24
+ - name : Check out repo
25
+ uses : actions/checkout@v3
22
26
23
- - name : Setup Python
24
- uses : actions/setup-python@v2
27
+ - name : Set up python
28
+ uses : actions/setup-python@v3
25
29
with :
26
30
python-version : 3.8
31
+ cache : pip
32
+ cache-dependency-path : |
33
+ setup.py
34
+ requirements-ci.txt
27
35
28
36
- name : Install OpenBabel
29
37
run : |
@@ -32,19 +40,54 @@ jobs:
32
40
# https://github.com/openbabel/openbabel/issues/2408#issuecomment-1014466193
33
41
sudo ln -s /usr/include/openbabel3 /usr/local/include/openbabel3
34
42
35
- - name : Cache pip
36
- uses : actions/cache@v2
37
- with :
38
- path : ~/.cache/pip
39
- key : ${{ runner.os }}-pip-${{ hashFiles('requirements-ci.txt', 'setup.py') }}
40
- restore-keys : |
41
- ${{ runner.os }}-pip-
42
-
43
43
- name : Install dependencies
44
44
run : |
45
45
pip install -r requirements-ci.txt
46
46
pip install .[complete]
47
47
48
- - name : pytest
48
+ - name : Get durations from cache
49
+ uses : actions/cache@v2
50
+ with :
51
+ path : test_durations
52
+ # the key must never match, even when restarting workflows, as that
53
+ # will cause durations to get out of sync between groups, the
54
+ # combined durations will be loaded if available
55
+ key : test-durations-split-${{ github.run_id }}-${{ github.run_number}}-${{ matrix.group }}
56
+ restore-keys : |
57
+ test-durations-combined-${{ github.sha }}
58
+ test-durations-combined
59
+
60
+ - name : Run tests
49
61
run : |
50
- pytest --ignore=atomate/qchem/test_files --cov=atomate --cov-report html:coverage_reports atomate
62
+ pytest --splits 5 --group ${{ matrix.group }} --store-durations \
63
+ --cov=atomate --cov-report html:coverage_reports atomate
64
+
65
+ - name : Upload partial durations
66
+ uses : actions/upload-artifact@v2
67
+ with :
68
+ name : split-${{ matrix.group }}
69
+ path : .test_durations
70
+
71
+ update_durations :
72
+ name : Combine and update test durations
73
+ runs-on : ubuntu-latest
74
+ needs : test
75
+ steps :
76
+ - name : Check out repo
77
+ uses : actions/checkout@v2
78
+
79
+ - name : Get durations from cache
80
+ uses : actions/cache@v2
81
+ with :
82
+ path : .test_durations
83
+ # key won't match during the first run for the given commit, but
84
+ # restore-key will if there's a previous stored durations file,
85
+ # so cache will both be loaded and stored
86
+ key : test-durations-combined-${{ github.sha }}
87
+ restore-keys : test-durations-combined
88
+
89
+ - name : Download artifacts
90
+ uses : actions/download-artifact@v2
91
+
92
+ - name : Combine test durations
93
+ run : python3 .github/workflows/combine_durations.py
0 commit comments