-
Notifications
You must be signed in to change notification settings - Fork 563
177 lines (168 loc) · 5.22 KB
/
ci.yaml
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
name: CI
on:
merge_group:
push:
branches: [main]
tags: ["v[0-9]+.[0-9]+.[0-9]+*"]
pull_request:
workflow_dispatch:
env:
HYPOTHESIS_PROFILE: ci
FORCE_COLOR: "1"
PIP_DISABLE_PIP_VERSION_CHECK: "1"
PIP_NO_PYTHON_VERSION_WARNING: "1"
permissions: {}
jobs:
build-python:
name: Build & verify python package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # needed for setuptools_scm version determination
- uses: hynek/build-and-inspect-python-package@v2
id: baipp
outputs:
python-versions: ${{ steps.baipp.outputs.supported_python_classifiers_json_array }}
lint:
name: Lint
needs: build-python
runs-on: ubuntu-latest-8-cores
steps:
- name: Download pre-built packages
uses: actions/download-artifact@v4
with:
name: Packages
path: dist
- name: Set COG_WHEEL
run: echo COG_WHEEL=$(ls dist/*.whl) >>"$GITHUB_ENV"
- name: Extract source distribution
run: tar xf dist/*.tar.gz --strip-components=1
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- uses: actions/setup-python@v5
with:
python-version: 3.12
- uses: hynek/setup-cached-uv@v2
- name: Prepare tox
run: uv pip install --system tox tox-uv
- name: Lint
run: make lint
test-go:
name: "Test Go"
needs: build-python
strategy:
fail-fast: false
matrix:
# https://docs.github.com/en/free-pro-team@latest/actions/reference/specifications-for-github-hosted-runners#supported-runners-and-hardware-resources
platform: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # needed for goreleaser version determination
- name: Download pre-built packages
uses: actions/download-artifact@v4
with:
name: Packages
path: dist
- name: Set COG_WHEEL
run: echo COG_WHEEL=$(ls dist/*.whl) >>"$GITHUB_ENV"
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Build
run: make cog
- name: Test
run: make test-go
test-python:
name: "Test Python ${{ matrix.python-version }} + Pydantic v${{ matrix.pydantic }}"
needs: build-python
runs-on: ubuntu-latest-8-cores
strategy:
fail-fast: false
matrix:
pydantic: ["1", "2"]
python-version: ${{ fromJson(needs.build-python.outputs.python-versions) }}
steps:
- name: Download pre-built packages
uses: actions/download-artifact@v4
with:
name: Packages
path: dist
- name: Set COG_WHEEL
run: echo COG_WHEEL=$(ls dist/*.whl) >>"$GITHUB_ENV"
- name: Extract source distribution
run: tar xf dist/*.tar.gz --strip-components=1
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: hynek/setup-cached-uv@v2
- name: Prepare tox
run: |
echo TOX_PYTHON=py$(echo "${{ matrix.python-version }}" | tr -d .) >>$GITHUB_ENV
uv pip install --system tox
- run: uv pip install --system tox-uv
- name: Remove src to ensure tests run against wheel
run: rm -rf python/cog
- name: Test
run: python -Im tox run --installpkg "$COG_WHEEL" -e ${{ env.TOX_PYTHON }}-pydantic${{ matrix.pydantic }}-tests
# cannot run this on mac due to licensing issues: https://github.com/actions/virtual-environments/issues/2150
test-integration:
name: "Test integration"
needs: build-python
runs-on: ubuntu-latest-16-cores
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # needed for goreleaser version determination
- name: Download pre-built packages
uses: actions/download-artifact@v4
with:
name: Packages
path: dist
- name: Set COG_WHEEL
run: echo COG_WHEEL=$(ls dist/*.whl) >>"$GITHUB_ENV"
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- uses: actions/setup-python@v5
with:
python-version: 3.12
- uses: hynek/setup-cached-uv@v2
- name: Prepare tox
run: uv pip install --system tox tox-uv
- name: Test
run: make test-integration
release:
name: "Release"
needs:
- test-go
- test-python
- test-integration
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # needed for goreleaser version determination
- name: Download pre-built packages
uses: actions/download-artifact@v4
with:
name: Packages
path: dist
- name: Set COG_WHEEL
run: echo COG_WHEEL=$(ls dist/*.whl) >>"$GITHUB_ENV"
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- uses: goreleaser/goreleaser-action@v6
with:
version: '~> v2'
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}