11name : Tests
22
3- on : [push, pull_request]
3+ on :
4+ - push
5+ - pull_request
46
57jobs :
68 tests :
7- name : Tests ( ${{ matrix.python-version }}, ${{ matrix.os }})
9+ name : ${{ matrix.session }} ${{ matrix.python-version }} / ${{ matrix.os }}
810 runs-on : ${{ matrix.os }}
911 strategy :
1012 fail-fast : false
1113 matrix :
1214 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" }
18+ - { python-version: 3.7, os: ubuntu-latest, session: "mypy" }
19+ - { python-version: 3.8, os: ubuntu-latest, session: "tests" }
20+ - { python-version: 3.7, os: ubuntu-latest, session: "tests" }
21+ # - { python-version: 3.8, os: windows-latest, session: "tests" }
22+ - { python-version: 3.8, os: macos-latest, session: "tests" }
23+ # - { python-version: 3.8, os: ubuntu-latest, session: "docs" }
24+
25+ env :
26+ NOXSESSION : ${{ matrix.session }}
27+
1728 steps :
1829 - name : Check out the repository
19- uses : actions/checkout@v2.1.0
30+ uses : actions/checkout@v2.1.1
2031
2132 - name : Set up Python ${{ matrix.python-version }}
2233 uses : actions/setup-python@v2
@@ -38,10 +49,41 @@ jobs:
3849 pip install --constraint=.github/workflows/constraints.txt nox
3950 nox --version
4051
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+ uses : actions/cache@v1.2.0
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+
4176 - name : Run Nox
4277 run : |
4378 nox --force-color
4479
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+
4587 - name : Create coverage report
4688 if : always() && matrix.session == 'tests'
4789 run : |
0 commit comments