summaryrefslogtreecommitdiff
path: root/.github/workflows/testsuite.yml
blob: 85072d7edd9eea75de71e38c8923cd908cc74c2b (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
# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt

name: "Test Suite"

on:
  push:
    branches: ["master"]
  pull_request:
    branches: ["master"]
  workflow_dispatch:

defaults:
  run:
    # The default shell is:
    #   bash --noprofile --norc -eo pipefail {0}
    # which makes it hard to do our own status checking.
    # Turn off -eo pipefail
    shell: bash --noprofile --norc {0}

jobs:
  tests:
    name: "Python ${{ matrix.python-version }} on ${{ matrix.os }}"
    runs-on: "${{ matrix.os }}"

    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
        python-version:
          - "2.7"
          - "3.5"
          - "3.6"
          - "3.7"
          - "3.8"
          - "3.9"
          - "pypy3"
        exclude:
          # Windows PyPy doesn't seem to work?
          - os: windows-latest
            python-version: "pypy3"
      fail-fast: false

    steps:
      - name: "Check out the repo"
        uses: "actions/checkout@v2"

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

      - name: "Install Visual C++ if needed"
        if: runner.os == 'Windows' && matrix.python-version == '2.7'
        run: |
          choco install vcpython27 -f -y

      - name: "Install dependencies"
        run: |
          set -xe
          python -VV
          python -m site
          python -m pip install -r requirements/ci.pip
          python -m pip install -c requirements/pins.pip tox-gh-actions

      - name: "Run tox for ${{ matrix.python-version }}"
        id: tox1
        continue-on-error: true
        run: |
          python -m tox
          tox_status=$?
          if [ $tox_status -ne 0 ]; then
            # https://github.community/t/annotations-how-to-create-them/18387
            echo "::warning file=testsuite.yml,line=1,col=1::tox failed, retrying..."
            exit $tox_status
          fi

      - name: "Retry tox for ${{ matrix.python-version }}"
        id: tox2
        continue-on-error: true
        if: steps.tox1.outcome == 'failure'
        run: |
          python -m tox
          tox_status=$?
          if [ $tox_status -ne 0 ]; then
            echo "::warning file=testsuite.yml,line=1,col=1::tox failed again, retrying..."
            exit $tox_status
          fi

      - name: "Retry tox again for ${{ matrix.python-version }}"
        id: tox3
        continue-on-error: true
        if: steps.tox2.outcome == 'failure'
        run: |
          python -m tox
          tox_status=$?
          if [ $tox_status -ne 0 ]; then
            echo "::error file=testsuite.yml,line=1,col=1::tox failed a third time, probably a real failure"
            exit $tox_status
          fi

      - name: "Set status"
        if: always()
        run: |
          if ${{ steps.tox1.outcome != 'success' && steps.tox2.outcome != 'success' && steps.tox3.outcome != 'success' }}; then
             exit 1
          fi