|
23 | 23 |
|
24 | 24 | - uses: pre-commit/action@v3.0.0
|
25 | 25 |
|
26 |
| - test: |
| 26 | + test-non-ase: |
| 27 | + # prevent this action from running on forks |
| 28 | + if: github.repository == 'materialsproject/atomate2' |
| 29 | + |
27 | 30 | services:
|
28 | 31 | local_mongodb:
|
29 | 32 | image: mongo:4.0
|
|
37 | 40 | strategy:
|
38 | 41 | matrix:
|
39 | 42 | python-version: ["3.10", "3.11", "3.12"]
|
| 43 | + split: [1, 2, 3] |
40 | 44 |
|
41 | 45 | steps:
|
42 | 46 | - name: Check out repo
|
@@ -72,20 +76,30 @@ jobs:
|
72 | 76 | micromamba activate a2
|
73 | 77 | uv pip install --upgrade 'git+https://github.com/materialsproject/pymatgen@${{ github.event.client_payload.pymatgen_ref }}'
|
74 | 78 |
|
75 |
| - - name: Test |
| 79 | + - name: Test split ${{ matrix.split }} |
76 | 80 | env:
|
77 | 81 | MP_API_KEY: ${{ secrets.MP_API_KEY }}
|
| 82 | + |
| 83 | + # regenerate durations file with `pytest --store-durations --durations-path tests/.pytest-split-durations` |
| 84 | + # Note the use of `--splitting-algorithm least_duration`. |
| 85 | + # This helps prevent a test split having no tests to run, and then the GH action failing, see: |
| 86 | + # https://github.com/jerry-git/pytest-split/issues/95 |
| 87 | + # However this `splitting-algorithm` means that tests cannot depend sensitively on the order they're executed in. |
78 | 88 | run: |
|
79 | 89 | micromamba activate a2
|
80 |
| - pytest --ignore=tests/ase --cov=atomate2 --cov-report=xml |
| 90 | + pytest --splits 3 --group ${{ matrix.split }} --durations-path tests/.pytest-split-durations --splitting-algorithm least_duration --ignore=tests/ase --cov=atomate2 --cov-report=xml |
81 | 91 |
|
82 | 92 | - uses: codecov/codecov-action@v1
|
83 | 93 | if: matrix.python-version == '3.10' && github.repository == 'materialsproject/atomate2'
|
84 | 94 | with:
|
85 | 95 | token: ${{ secrets.CODECOV_TOKEN }}
|
| 96 | + name: coverage${{ matrix.split }} |
86 | 97 | file: ./coverage.xml
|
87 | 98 |
|
88 | 99 | test-notebooks-and-ase:
|
| 100 | + # prevent this action from running on forks |
| 101 | + if: github.repository == 'materialsproject/atomate2' |
| 102 | + |
89 | 103 | # It seems like anything torch-dependent and tblite can't be installed in the same environment
|
90 | 104 | # without the tblite tests failing in CI, see, e.g.:
|
91 | 105 | # https://github.com/tblite/tblite/issues/116
|
@@ -143,7 +157,7 @@ jobs:
|
143 | 157 | MP_API_KEY: ${{ secrets.MP_API_KEY }}
|
144 | 158 | run: |
|
145 | 159 | micromamba activate a2
|
146 |
| - pytest --cov=atomate2 --cov-report=xml tests/ase |
| 160 | + pytest --splits 1 --group 1 --cov=atomate2 --cov-report=xml tests/ase |
147 | 161 |
|
148 | 162 | - uses: codecov/codecov-action@v1
|
149 | 163 | if: matrix.python-version == '3.10' && github.repository == 'materialsproject/atomate2'
|
@@ -172,7 +186,7 @@ jobs:
|
172 | 186 | run: sphinx-build docs docs_build
|
173 | 187 |
|
174 | 188 | automerge:
|
175 |
| - needs: [lint, test, docs] |
| 189 | + needs: [lint, test-non-ase, test-notebooks-and-ase, docs] |
176 | 190 | runs-on: ubuntu-latest
|
177 | 191 |
|
178 | 192 | permissions:
|
|
0 commit comments