|
| 1 | +name: Tests |
| 2 | + |
| 3 | +on: |
| 4 | + - push |
| 5 | + - pull_request |
| 6 | + |
| 7 | +jobs: |
| 8 | + tests: |
| 9 | + name: ${{ matrix.session }} ${{ matrix.python-version }} / ${{ matrix.os }} |
| 10 | + runs-on: ${{ matrix.os }} |
| 11 | + strategy: |
| 12 | + fail-fast: false |
| 13 | + matrix: |
| 14 | + include: |
| 15 | + - { python-version: 3.9, os: ubuntu-latest, session: "pre-commit" } |
| 16 | + - { python-version: 3.9, os: ubuntu-latest, session: "safety" } |
| 17 | + - { python-version: 3.9, os: ubuntu-latest, session: "mypy" } |
| 18 | + - { python-version: 3.8, os: ubuntu-latest, session: "mypy" } |
| 19 | + - { python-version: 3.7, os: ubuntu-latest, session: "mypy" } |
| 20 | + - { python-version: 3.6, os: ubuntu-latest, session: "mypy" } |
| 21 | + - { python-version: 3.9, os: ubuntu-latest, session: "tests" } |
| 22 | + - { python-version: 3.8, os: ubuntu-latest, session: "tests" } |
| 23 | + - { python-version: 3.7, os: ubuntu-latest, session: "tests" } |
| 24 | + - { python-version: 3.6, os: ubuntu-latest, session: "tests" } |
| 25 | + - { python-version: 3.9, os: windows-latest, session: "tests" } |
| 26 | + - { python-version: 3.9, os: macos-latest, session: "tests" } |
| 27 | + - { python-version: 3.9, os: ubuntu-latest, session: "typeguard" } |
| 28 | + - { python-version: 3.9, os: ubuntu-latest, session: "xdoctest" } |
| 29 | + - { python-version: 3.8, os: ubuntu-latest, session: "docs-build" } |
| 30 | + |
| 31 | + env: |
| 32 | + NOXSESSION: ${{ matrix.session }} |
| 33 | + |
| 34 | + steps: |
| 35 | + - name: Check out the repository |
| 36 | + uses: actions/checkout@v2.3.4 |
| 37 | + |
| 38 | + - name: Set up Python ${{ matrix.python-version }} |
| 39 | + uses: actions/setup-python@v2.2.1 |
| 40 | + with: |
| 41 | + python-version: ${{ matrix.python-version }} |
| 42 | + |
| 43 | + - name: Upgrade pip |
| 44 | + run: | |
| 45 | + pip install --constraint=.github/workflows/constraints.txt pip |
| 46 | + pip --version |
| 47 | +
|
| 48 | + - name: Install Poetry |
| 49 | + run: | |
| 50 | + pip install --constraint=.github/workflows/constraints.txt poetry |
| 51 | + poetry --version |
| 52 | +
|
| 53 | + - name: Install Nox |
| 54 | + run: | |
| 55 | + pip install --constraint=.github/workflows/constraints.txt nox nox-poetry |
| 56 | + nox --version |
| 57 | +
|
| 58 | + - name: Compute pre-commit cache key |
| 59 | + if: matrix.session == 'pre-commit' |
| 60 | + id: pre-commit-cache |
| 61 | + shell: python |
| 62 | + run: | |
| 63 | + import hashlib |
| 64 | + import sys |
| 65 | +
|
| 66 | + python = "py{}.{}".format(*sys.version_info[:2]) |
| 67 | + payload = sys.version.encode() + sys.executable.encode() |
| 68 | + digest = hashlib.sha256(payload).hexdigest() |
| 69 | + result = "${{ runner.os }}-{}-{}-pre-commit".format(python, digest[:8]) |
| 70 | +
|
| 71 | + print("::set-output name=result::{}".format(result)) |
| 72 | +
|
| 73 | + - name: Restore pre-commit cache |
| 74 | + uses: actions/cache@v2.1.3 |
| 75 | + if: matrix.session == 'pre-commit' |
| 76 | + with: |
| 77 | + path: ~/.cache/pre-commit |
| 78 | + key: ${{ steps.pre-commit-cache.outputs.result }}-${{ hashFiles('.pre-commit-config.yaml') }} |
| 79 | + restore-keys: | |
| 80 | + ${{ steps.pre-commit-cache.outputs.result }}- |
| 81 | +
|
| 82 | + - name: Run Nox |
| 83 | + run: | |
| 84 | + nox --force-color --python=${{ matrix.python-version }} |
| 85 | +
|
| 86 | + - name: Upload coverage data |
| 87 | + if: always() && matrix.session == 'tests' |
| 88 | + uses: "actions/upload-artifact@v2.2.2" |
| 89 | + with: |
| 90 | + name: coverage-data |
| 91 | + path: ".coverage.*" |
| 92 | + |
| 93 | + - name: Upload documentation |
| 94 | + if: matrix.session == 'docs-build' |
| 95 | + uses: actions/upload-artifact@v2.2.2 |
| 96 | + with: |
| 97 | + name: docs |
| 98 | + path: docs/_build |
| 99 | + |
| 100 | + coverage: |
| 101 | + runs-on: ubuntu-latest |
| 102 | + needs: tests |
| 103 | + steps: |
| 104 | + - name: Check out the repository |
| 105 | + uses: actions/checkout@v2.3.4 |
| 106 | + |
| 107 | + - name: Set up Python 3.9 |
| 108 | + uses: actions/setup-python@v2.2.1 |
| 109 | + with: |
| 110 | + python-version: 3.9 |
| 111 | + |
| 112 | + - name: Upgrade pip |
| 113 | + run: | |
| 114 | + pip install --constraint=.github/workflows/constraints.txt pip |
| 115 | + pip --version |
| 116 | +
|
| 117 | + - name: Install Poetry |
| 118 | + run: | |
| 119 | + pip install --constraint=.github/workflows/constraints.txt poetry |
| 120 | + poetry --version |
| 121 | +
|
| 122 | + - name: Install Nox |
| 123 | + run: | |
| 124 | + pip install --constraint=.github/workflows/constraints.txt nox nox-poetry |
| 125 | + nox --version |
| 126 | +
|
| 127 | + - name: Download coverage data |
| 128 | + uses: actions/download-artifact@v2.0.8 |
| 129 | + with: |
| 130 | + name: coverage-data |
| 131 | + |
| 132 | + - name: Combine coverage data and display human readable report |
| 133 | + run: | |
| 134 | + nox --force-color --session=coverage |
| 135 | +
|
| 136 | + - name: Create coverage report |
| 137 | + run: | |
| 138 | + nox --force-color --session=coverage -- xml |
| 139 | +
|
| 140 | + - name: Upload coverage report |
| 141 | + uses: codecov/codecov-action@v1.2.1 |
0 commit comments