-
Notifications
You must be signed in to change notification settings - Fork 578
129 lines (125 loc) · 3.44 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
name: CI
on:
push:
branches:
- main
tags:
- "**"
pull_request:
branches:
- main
merge_group:
branches:
- main
types:
- checks_requested
jobs:
test-go:
name: "Test Go"
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-8-cores, macos-12]
runs-on: ${{ matrix.platform }}
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
- uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Install Python dependencies
run: |
python -m pip install '.[dev]'
yes | python -m mypy --install-types replicate || true
- name: Build
run: make cog
- name: Test
run: make test-go
test-python:
name: "Test Python ${{ matrix.python-version }}"
runs-on: ubuntu-latest-8-cores
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Python dependencies
run: |
python -m pip install '.[dev]'
yes | python -m mypy --install-types replicate || true
- name: Test
run: make test-python
env:
HYPOTHESIS_PROFILE: ci
# cannot run this on mac due to licensing issues: https://github.com/actions/virtual-environments/issues/2150
test-integration:
name: "Test integration"
runs-on: ubuntu-latest-16-cores
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
- uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Install Python dependencies
run: |
python -m pip install '.[dev]'
yes | python -m mypy --install-types replicate || true
- name: Test
run: make test-integration
release:
needs:
- test-go
- test-python
- test-integration
if: startsWith(github.ref, 'refs/tags/v')
outputs:
cog_version: ${{ steps.build-python-package.outputs.version }}
runs-on: ubuntu-latest-8-cores
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
- name: Build
run: make cog
- uses: goreleaser/goreleaser-action@v4
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build Python package
id: build-python-package
run: |
# clean package built for go client
rm -rf dist
# install build
pip install build
# build package
python -m build --wheel
# set output
echo "version=$(ls dist/ | cut -d- -f2)" >> $GITHUB_OUTPUT
- name: Push Python package
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
packages-dir: dist