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