|
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
|
|
45 | 49 | pip install -r requirements-ci.txt
|
46 | 50 | pip install .[complete]
|
47 | 51 |
|
48 |
| - - name: pytest |
| 52 | + - name: Get durations from cache |
| 53 | + uses: actions/cache@v2 |
| 54 | + with: |
| 55 | + path: test_durations |
| 56 | + # the key must never match, even when restarting workflows, as that |
| 57 | + # will cause durations to get out of sync between groups, the |
| 58 | + # combined durations will be loaded if available |
| 59 | + key: test-durations-split-${{ github.run_id }}-${{ github.run_number}}-${{ matrix.group }} |
| 60 | + restore-keys: | |
| 61 | + test-durations-combined-${{ github.sha }} |
| 62 | + test-durations-combined |
| 63 | +
|
| 64 | + - name: Run tests |
49 | 65 | run: |
|
50 |
| - pytest --ignore=atomate/qchem/test_files --cov=atomate --cov-report html:coverage_reports atomate |
| 66 | + pytest --splits 5 --group ${{ matrix.group }} --store-durations \ |
| 67 | + --cov=atomate --cov-report html:coverage_reports atomate |
| 68 | +
|
| 69 | + - name: Upload partial durations |
| 70 | + uses: actions/upload-artifact@v2 |
| 71 | + with: |
| 72 | + name: split-${{ matrix.group }} |
| 73 | + path: .test_durations |
| 74 | + |
| 75 | + update_durations: |
| 76 | + name: Combine and update test durations |
| 77 | + runs-on: ubuntu-latest |
| 78 | + needs: test |
| 79 | + steps: |
| 80 | + - name: Checkout repo |
| 81 | + uses: actions/checkout@v2 |
| 82 | + |
| 83 | + - name: Get durations from cache |
| 84 | + uses: actions/cache@v2 |
| 85 | + with: |
| 86 | + path: .test_durations |
| 87 | + # key won't match during the first run for the given commit, but |
| 88 | + # restore-key will if there's a previous stored durations file, |
| 89 | + # so cache will both be loaded and stored |
| 90 | + key: test-durations-combined-${{ github.sha }} |
| 91 | + restore-keys: test-durations-combined |
| 92 | + |
| 93 | + - name: Download artifacts |
| 94 | + uses: actions/download-artifact@v2 |
| 95 | + |
| 96 | + - name: Combine test durations |
| 97 | + run: python3 .github/workflows/combine_durations.py |
0 commit comments