|
1 | 1 | name: Tests
|
2 | 2 |
|
3 |
| -on: [push, pull_request] |
| 3 | +on: |
| 4 | + - push |
| 5 | + - pull_request |
4 | 6 |
|
5 | 7 | jobs:
|
6 | 8 | tests:
|
7 |
| - name: Tests (${{ matrix.python-version }}, ${{ matrix.os }}) |
| 9 | + name: ${{ matrix.session }} ${{ matrix.python-version }} / ${{ matrix.os }} |
8 | 10 | runs-on: ${{ matrix.os }}
|
9 | 11 | strategy:
|
10 | 12 | fail-fast: false
|
11 | 13 | matrix:
|
12 | 14 | include:
|
13 |
| - - { python-version: 3.8, os: ubuntu-latest } |
14 |
| - # - { python-version: 3.8, os: windows-latest } |
15 |
| - - { python-version: 3.8, os: macos-latest } |
16 |
| - - { python-version: 3.7, os: ubuntu-latest } |
| 15 | + - { python-version: 3.8, os: ubuntu-latest, session: "pre-commit" } |
| 16 | + - { python-version: 3.8, os: ubuntu-latest, session: "safety" } |
| 17 | + - { python-version: 3.8, os: ubuntu-latest, session: "mypy-3.8" } |
| 18 | + - { python-version: 3.7, os: ubuntu-latest, session: "mypy-3.7" } |
| 19 | + - { python-version: 3.8, os: ubuntu-latest, session: "tests-3.8" } |
| 20 | + - { python-version: 3.7, os: ubuntu-latest, session: "tests-3.7" } |
| 21 | + # - { python-version: 3.8, os: windows-latest, session: "tests-3.8" } |
| 22 | + - { python-version: 3.8, os: macos-latest, session: "tests-3.8" } |
| 23 | + # - { python-version: 3.8, os: ubuntu-latest, session: "docs" } |
| 24 | + |
| 25 | + env: |
| 26 | + NOXSESSION: ${{ matrix.session }} |
| 27 | + |
17 | 28 | steps:
|
18 | 29 | - name: Check out the repository
|
19 |
| - |
| 30 | + |
20 | 31 |
|
21 | 32 | - name: Set up Python ${{ matrix.python-version }}
|
22 | 33 | uses: actions/setup-python@v2
|
|
38 | 49 | pip install --constraint=.github/workflows/constraints.txt nox
|
39 | 50 | nox --version
|
40 | 51 |
|
| 52 | + - name: Compute pre-commit cache key |
| 53 | + if: matrix.session == 'pre-commit' |
| 54 | + id: pre-commit-cache |
| 55 | + shell: python |
| 56 | + run: | |
| 57 | + import hashlib |
| 58 | + import sys |
| 59 | +
|
| 60 | + python = "py{}.{}".format(*sys.version_info[:2]) |
| 61 | + payload = sys.version.encode() + sys.executable.encode() |
| 62 | + digest = hashlib.sha256(payload).hexdigest() |
| 63 | + result = "${{ runner.os }}-{}-{}-pre-commit".format(python, digest[:8]) |
| 64 | +
|
| 65 | + print("::set-output name=result::{}".format(result)) |
| 66 | +
|
| 67 | + - name: Restore pre-commit cache |
| 68 | + |
| 69 | + if: matrix.session == 'pre-commit' |
| 70 | + with: |
| 71 | + path: ~/.cache/pre-commit |
| 72 | + key: ${{ steps.pre-commit-cache.outputs.result }}-${{ hashFiles('.pre-commit-config.yaml') }} |
| 73 | + restore-keys: | |
| 74 | + ${{ steps.pre-commit-cache.outputs.result }}- |
| 75 | +
|
41 | 76 | - name: Run Nox
|
42 | 77 | run: |
|
43 | 78 | nox --force-color
|
| 79 | +
|
| 80 | + # - name: Upload documentation |
| 81 | + # if: matrix.session == 'docs' |
| 82 | + # uses: actions/upload-artifact@v2 |
| 83 | + # with: |
| 84 | + # name: docs |
| 85 | + # path: docs/_build |
| 86 | + |
| 87 | + - name: Create coverage report |
| 88 | + if: always() && matrix.session == 'tests' |
| 89 | + run: | |
| 90 | + nox --force-color --session=coverage -- xml |
| 91 | +
|
| 92 | + - name: Upload coverage report |
| 93 | + if: always() && matrix.session == 'tests' |
| 94 | + |
0 commit comments