summaryrefslogtreecommitdiff
path: root/.github/workflows/coverage.yml
blob: 59e7ccc685851398f4a97e60add7d09017be06f9 (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
130
131
132
133
134
135
136
137
138
139
140
# 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: "Coverage"

on:
  push:
    branches: ["master"]
  # as currently structured, this adds too many jobs (checks?), so don't run it
  # on pull requests yet.
  #pull_request:
  workflow_dispatch:

defaults:
  run:
    shell: bash

jobs:
  coverage:
    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.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 coverage for ${{ matrix.python-version }}"
        env:
          COVERAGE_COVERAGE: "yes"
        run: |
          set -xe
          python -m tox
          python -m igor combine_html
          mv .metacov .metacov.${{ matrix.python-version }}.${{ matrix.os }}

      - name: "Upload coverage data"
        uses: actions/upload-artifact@v2
        with:
          name: metacov
          path: .metacov.*

  combine:
    name: "Combine coverage data"
    needs: coverage
    runs-on: ubuntu-latest

    steps:
      - name: "Check out the repo"
        uses: "actions/checkout@v2"
        with:
          fetch-depth: "0"

      - name: "Set up Python"
        uses: "actions/setup-python@v2"
        with:
          python-version: "3.9"

      - name: "Install dependencies"
        run: |
          set -xe
          python -VV
          python -m site
          python -m pip install -r requirements/ci.pip
          python setup.py --quiet clean develop
          python igor.py zip_mods install_egg

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

      - name: "Combine and report"
        run: |
          set -xe
          python -m igor combine_html

      - name: "Upload to codecov"
        uses: codecov/codecov-action@v1
        with:
          file: coverage.xml

      - name: "Upload HTML report"
        uses: actions/upload-artifact@v2
        with:
          name: html_report
          path: htmlcov

      - name: Pushes to another repository
        uses: sebastian-palma/github-action-push-to-another-repository@allow-creating-destination-directory
        env:
          API_TOKEN_GITHUB: ${{ secrets.COVERAGE_REPORTS_TOKEN }}
        with:
          source-directory: 'htmlcov'
          destination-github-username: 'nedbat'
          destination-repository-name: 'coverage-reports'
          destination-repository-directory: 'reports/${{ github.sha }}'
          empty-repository: false
          create-destination-directory: true
          target-branch: main
          commit-message: "Coverage report for ${{ github.sha }}"
          user-email: ned@nedbatchelder.com

      - name: Show link to report
        run: |
          echo "https://nedbat.github.io/coverage-reports/reports/${{ github.sha }}/htmlcov"