summaryrefslogtreecommitdiff
path: root/.github/workflows/ci.yml
blob: c895466034c2699cc1ca74cb21b2b956e9b03568 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: CI

on: [push, pull_request]

permissions: "read-all"

defaults:
  run:
    shell: bash

jobs:
  package:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout Repository
        uses: actions/checkout@v2
      - name: Set up Python 3.7
        uses: actions/setup-python@v2
        with:
          python-version: "3.7"
      - name: Check packages
        run: |
          python3.7 -m pip install pip setuptools wheel twine rstcheck;
          python3.7 setup.py sdist bdist_wheel;
          rstcheck README.rst CHANGES.rst
          python3.7 -m twine check dist/*
  test:
    env:
      SETUPTOOLS_USE_DISTUTILS: stdlib
    strategy:
      fail-fast: false
      matrix:
        python-version: ["2.7", "3.6", "3.7", "3.8", "3.9", "3.10"]
        os: [macos-latest, windows-latest, ubuntu-latest]
        experimental: [false]
        nox-session: ['']
        include:
          - python-version: "pypy3"
            os: ubuntu-latest
            experimental: false
            nox-session: test-pypy
          - python-version: "pypy2"
            os: ubuntu-latest
            experimental: false
            nox-session: test-pypy
          - python-version: "2.7"
            os: ubuntu-latest
            experimental: false
            nox-session: google_brotli-2
          - python-version: "3.9"
            os: ubuntu-latest
            experimental: false
            nox-session: google_brotli-3
          - python-version: "2.7"
            os: ubuntu-latest
            experimental: false
            nox-session: app_engine
          - python-version: 3.11-dev
            os: ubuntu-latest
            experimental: true
            nox-session: test-3.11

    runs-on: ${{ matrix.os }}
    name: ${{ fromJson('{"macos-latest":"macOS","windows-latest":"Windows","ubuntu-latest":"Ubuntu"}')[matrix.os] }} ${{ matrix.python-version }} ${{ matrix.nox-session}}
    continue-on-error: ${{ matrix.experimental }}
    steps:
      - name: Checkout Repository
        uses: actions/checkout@v2

      - name: Set Up Python - ${{ matrix.python-version }}
        uses: actions/setup-python@v2
        with:
          python-version: ${{ matrix.python-version }}

      - name: Set Up Python 3 to run nox
        if: matrix.python-version != '3.7'
        uses: actions/setup-python@v2
        with:
          python-version: "3"

      - name: Install Dependencies
        run: python -m pip install --upgrade pip setuptools nox

      - name: Run Tests
        run: ./ci/run_tests.sh
        env:
          PYTHON_VERSION: ${{ matrix.python-version }}
          NOX_SESSION: ${{ matrix.nox-session }}

      - name: Upload Coverage
        if: ${{ matrix.nox-session != 'unsupported_python2' }}
        uses: "actions/upload-artifact@v2"
        with:
          name: coverage-data
          path: ".coverage.*"
          if-no-files-found: error


  coverage:
    runs-on: "ubuntu-latest"
    needs: test
    steps:
      - uses: actions/checkout@v2
      - name: "Use latest Python so it understands all syntax"
        uses: actions/setup-python@v2
        with:
          python-version: "3.10"

      - name: "Install coverage"
        run: "python -m pip install --upgrade coverage"

      - name: "Download coverage data"
        uses: actions/download-artifact@v2
        with:
          name: coverage-data

      - name: "Combine & check coverage"
        run: |
          python -m coverage combine
          python -m coverage html --skip-covered --skip-empty
          python -m coverage report --ignore-errors --show-missing --fail-under=100

      - name: "Upload report if check failed"
        uses: actions/upload-artifact@v2
        with:
          name: coverage-report
          path: htmlcov
        if: ${{ failure() }}