summaryrefslogtreecommitdiff
path: root/.github/workflows/kit.yml
blob: 679eeed44e15e11340f5e6f62c3b88e6db8463e8 (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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
# For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt

# This file is meant to be processed with cog.
# Running "make prebuild" will bring it up to date.

# Based on:
# https://github.com/joerick/cibuildwheel/blob/master/examples/github-deploy.yml

# To test installing wheels without uploading them to PyPI:
#
#   $ mkdir /tmp/pypi
#   $ cp dist/* /tmp/pypi
#   $ python -m pip install piprepo
#   $ piprepo build /tmp/pypi
#   $ python -m pip install -v coverage --index-url=file:///tmp/pypi/simple
#
# Note that cibuildwheel recommends not shipping wheels for pre-release versions
# of Python: https://cibuildwheel.readthedocs.io/en/stable/options/#prerelease-pythons
# So we don't.

name: "Kits"

on:
  push:
    branches:
      # Don't build kits all the time, but do if the branch is about kits.
      - "**/*kit*"
  workflow_dispatch:
  repository_dispatch:
    types:
      - build-kits

defaults:
  run:
    shell: bash

env:
  PIP_DISABLE_PIP_VERSION_CHECK: 1

permissions:
  contents: read

concurrency:
  group: "${{ github.workflow }}-${{ github.ref }}"
  cancel-in-progress: true

jobs:
  wheels:
    name: "${{ matrix.py }} ${{ matrix.os }} ${{ matrix.arch }} wheels"
    runs-on: ${{ matrix.os }}-latest
    strategy:
      matrix:
        include:
          # To change the matrix, edit the choices, then process this file with cog:
          #
          # $ make workflows
          #
          # which runs:
          #
          # $ python -m pip install cogapp
          # $ python -m cogapp -crP .github/workflows/kit.yml
          #
          # Choices come from the table on https://pypi.org/project/cibuildwheel/
          #
          # [[[cog
          #   #----- vvv Choices for the matrix vvv -----
          #
          #   # Operating systems:
          #   oss = ["ubuntu", "macos", "windows"]
          #
          #   # For each OS, what arch to use with cibuildwheel:
          #   os_archs = {
          #       "ubuntu": ["x86_64", "i686", "aarch64"],
          #       "macos": ["arm64", "x86_64"],
          #       "windows": ["x86", "AMD64"],
          #   }
          #   # PYVERSIONS. Available versions:
          #   # https://github.com/actions/python-versions/blob/main/versions-manifest.json
          #   # Include prereleases if they are at rc stage.
          #   # PyPy versions are handled further below in the "pypy" step.
          #   pys = ["cp37", "cp38", "cp39", "cp310", "cp311"]
          #
          #   # Some OS/arch combinations need overrides for the Python versions:
          #   os_arch_pys = {
          #     ("macos", "arm64"): ["cp38", "cp39", "cp310", "cp311"],
          #   }
          #
          #   #----- ^^^ ---------------------- ^^^ -----
          #
          #   import json
          #   for the_os in oss:
          #       for the_arch in os_archs[the_os]:
          #           for the_py in os_arch_pys.get((the_os, the_arch), pys):
          #               them = {
          #                   "os": the_os,
          #                   "py": the_py,
          #                   "arch": the_arch,
          #               }
          #               print(f"- {json.dumps(them)}")
          # ]]]
          - {"os": "ubuntu", "py": "cp37", "arch": "x86_64"}
          - {"os": "ubuntu", "py": "cp38", "arch": "x86_64"}
          - {"os": "ubuntu", "py": "cp39", "arch": "x86_64"}
          - {"os": "ubuntu", "py": "cp310", "arch": "x86_64"}
          - {"os": "ubuntu", "py": "cp311", "arch": "x86_64"}
          - {"os": "ubuntu", "py": "cp37", "arch": "i686"}
          - {"os": "ubuntu", "py": "cp38", "arch": "i686"}
          - {"os": "ubuntu", "py": "cp39", "arch": "i686"}
          - {"os": "ubuntu", "py": "cp310", "arch": "i686"}
          - {"os": "ubuntu", "py": "cp311", "arch": "i686"}
          - {"os": "ubuntu", "py": "cp37", "arch": "aarch64"}
          - {"os": "ubuntu", "py": "cp38", "arch": "aarch64"}
          - {"os": "ubuntu", "py": "cp39", "arch": "aarch64"}
          - {"os": "ubuntu", "py": "cp310", "arch": "aarch64"}
          - {"os": "ubuntu", "py": "cp311", "arch": "aarch64"}
          - {"os": "macos", "py": "cp38", "arch": "arm64"}
          - {"os": "macos", "py": "cp39", "arch": "arm64"}
          - {"os": "macos", "py": "cp310", "arch": "arm64"}
          - {"os": "macos", "py": "cp311", "arch": "arm64"}
          - {"os": "macos", "py": "cp37", "arch": "x86_64"}
          - {"os": "macos", "py": "cp38", "arch": "x86_64"}
          - {"os": "macos", "py": "cp39", "arch": "x86_64"}
          - {"os": "macos", "py": "cp310", "arch": "x86_64"}
          - {"os": "macos", "py": "cp311", "arch": "x86_64"}
          - {"os": "windows", "py": "cp37", "arch": "x86"}
          - {"os": "windows", "py": "cp38", "arch": "x86"}
          - {"os": "windows", "py": "cp39", "arch": "x86"}
          - {"os": "windows", "py": "cp310", "arch": "x86"}
          - {"os": "windows", "py": "cp311", "arch": "x86"}
          - {"os": "windows", "py": "cp37", "arch": "AMD64"}
          - {"os": "windows", "py": "cp38", "arch": "AMD64"}
          - {"os": "windows", "py": "cp39", "arch": "AMD64"}
          - {"os": "windows", "py": "cp310", "arch": "AMD64"}
          - {"os": "windows", "py": "cp311", "arch": "AMD64"}
        # [[[end]]] (checksum: ded8a9f214bf59776562d91ae6828863)
      fail-fast: false

    steps:
      - name: "Setup QEMU"
        if: matrix.os == 'ubuntu'
        uses: docker/setup-qemu-action@e81a89b1732b9c48d79cd809d8d81d79c4647a18
        with:
          platforms: arm64

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

      - name: "Install Python 3.8"
        uses: actions/setup-python@v4
        with:
          python-version: "3.8"
          cache: pip
          cache-dependency-path: 'requirements/*.pip'

      - name: "Install tools"
        run: |
          python -m pip install -r requirements/kit.pip

      - name: "Build wheels"
        env:
          CIBW_BUILD: ${{ matrix.py }}-*
          CIBW_ARCHS: ${{ matrix.arch }}
          CIBW_ENVIRONMENT: PIP_DISABLE_PIP_VERSION_CHECK=1
          CIBW_TEST_COMMAND: python -c "from coverage.tracer import CTracer; print('CTracer OK!')"
        run: |
          python -m cibuildwheel --output-dir wheelhouse

      - name: "List wheels"
        run: |
          ls -al wheelhouse/

      - name: "Upload wheels"
        uses: actions/upload-artifact@v3
        with:
          name: dist
          path: wheelhouse/*.whl

  sdist:
    name: "Source distribution"
    runs-on: ubuntu-latest
    steps:
      - name: "Check out the repo"
        uses: actions/checkout@v3

      - name: "Install Python 3.8"
        uses: actions/setup-python@v4
        with:
          python-version: "3.8"
          cache: pip
          cache-dependency-path: 'requirements/*.pip'

      - name: "Install tools"
        run: |
          python -m pip install -r requirements/kit.pip

      - name: "Build sdist"
        run: |
          python -m build

      - name: "List tarballs"
        run: |
          ls -al dist/

      - name: "Upload sdist"
        uses: actions/upload-artifact@v3
        with:
          name: dist
          path: dist/*.tar.gz

  pypy:
    name: "PyPy wheel"
    runs-on: ubuntu-latest
    steps:
      - name: "Check out the repo"
        uses: actions/checkout@v3

      - name: "Install PyPy"
        uses: actions/setup-python@v4
        with:
          python-version: "pypy-3.7" # Minimum of PyPy PYVERSIONS
          cache: pip
          cache-dependency-path: 'requirements/*.pip'

      - name: "Install requirements"
        run: |
          pypy3 -m pip install -r requirements/kit.pip

      - name: "Build wheel"
        run: |
          # One wheel works for all PyPy versions. PYVERSIONS
          # yes, this is weird syntax: https://github.com/pypa/build/issues/202
          pypy3 -m build -w -C="--global-option=--python-tag" -C="--global-option=pp37.pp38.pp39"

      - name: "List wheels"
        run: |
          ls -al dist/

      - name: "Upload wheels"
        uses: actions/upload-artifact@v3
        with:
          name: dist
          path: dist/*.whl

  sign:
    name: "Sign artifacts"
    needs:
      - wheels
      - sdist
      - pypy
    runs-on: ubuntu-latest
    permissions:
      id-token: write
    steps:
      - name: "Download artifacts"
        uses: actions/download-artifact@v3
        with:
          name: dist

      - name: "What did we get?"
        run: |
          ls -alR

      - name: "Sign"
        uses: sigstore/gh-action-sigstore-python@v1.2.3
        with:
          inputs: coverage-*.*
          upload-signing-artifacts: true