-
Notifications
You must be signed in to change notification settings - Fork 653
234 lines (233 loc) · 9.8 KB
/
compile-pypi.yml
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
name: Compile PyPI package
on:
workflow_dispatch:
inputs:
tags:
description: 'Tag for releases'
required: true
type: string
workflow_call:
inputs:
tags:
required: true
type: string
outputs:
sucess:
description: 'Whether the build is successful or not'
value: ${{ jobs.sucess-build.outputs.success }}
push:
branches: [main]
paths-ignore:
- 'docs/**'
- 'bazel/**'
- 'typings/**'
- '*.md'
- 'changelog.d/**'
- 'assets/**'
- 'openllm-contrib/clojure/**'
pull_request:
branches: [main]
paths-ignore:
- 'docs/**'
- 'bazel/**'
- 'typings/**'
- '*.md'
- 'changelog.d/**'
- 'assets/**'
- 'openllm-contrib/clojure/**'
env:
LINES: 120
COLUMNS: 120
HATCH_VERBOSE: 2
CIBW_BUILD_FRONTEND: build
CIBW_ENVIRONMENT_PASS_LINUX: >
HATCH_BUILD_HOOKS_ENABLE MYPYPATH
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
get_commit_message:
name: Get commit message
runs-on: ubuntu-latest
if: "github.repository == 'bentoml/OpenLLM'" # Don't run on fork repository
outputs:
message: ${{ steps.commit_message.outputs.message }}
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # ratchet:actions/checkout@v4.1.1
# Gets the correct commit message for pull request
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Get commit message
id: commit_message
run: |
set -xe
COMMIT_MSG=$(git log --no-merges -1 --oneline)
echo "message=$COMMIT_MSG" >> $GITHUB_OUTPUT
echo github.ref ${{ github.ref }}
pure-wheels-sdist:
name: Pure wheels and sdist distribution (${{ matrix.directory }})
runs-on: ubuntu-latest
needs: get_commit_message
if: >-
contains(needs.get_commit_message.outputs.message, '[wheel build]') || github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call' || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, '02 - Wheel Build')) || (github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/main')))
strategy:
fail-fast: false
matrix:
directory: ['openllm-core', 'openllm-python', 'openllm-client']
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # ratchet:actions/checkout@v4.1.1
with:
fetch-depth: 0
ref: '${{ inputs.tags }}'
- uses: bentoml/setup-bentoml-action@862aa8fa0e0c3793fcca4bfe7a62717a497417e4 # ratchet:bentoml/setup-bentoml-action@v1
with:
bentoml-version: 'main'
python-version-file: .python-version-default
- name: Build
run: hatch build
working-directory: ${{ matrix.directory }}
- name: Upload artifacts
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # ratchet:actions/upload-artifact@v3
with:
name: python-artefacts
path: ${{ matrix.directory }}/dist/*
if-no-files-found: error
mypyc:
name: Compiled wheels (${{ matrix.buildplatform[1] }}-${{ matrix.directory }})
runs-on: ${{ matrix.buildplatform[0] }}
if: false
# if: >-
# contains(needs.get_commit_message.outputs.message, '[wheel build]') || github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call' || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, '02 - Wheel Build')) || (github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/main')))
strategy:
fail-fast: false
matrix:
# Github Actions doesn't support pairing matrix values together, let's improvise
# https://github.com/github/feedback/discussions/7835#discussioncomment-1769026
buildplatform:
- [ubuntu-latest, linux-x86_64, '']
- [macos-latest, macos-x86_64, 'x86_64']
- [macos-latest, macos-arm64, 'arm64']
- [macos-latest, macos-universal2, 'universal2']
directory: ['openllm-core', 'openllm-python', 'openllm-client']
needs: get_commit_message
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # ratchet:actions/checkout@v4.1.1
with:
fetch-depth: 0
ref: '${{ inputs.tags }}'
- uses: bentoml/setup-bentoml-action@862aa8fa0e0c3793fcca4bfe7a62717a497417e4 # ratchet:bentoml/setup-bentoml-action@v1
with:
bentoml-version: 'main'
python-version: '3.8'
- name: Build wheels via cibuildwheel
uses: pypa/cibuildwheel@fff9ec32ed25a9c576750c91e06b410ed0c15db7 # ratchet:pypa/cibuildwheel@v2.16.2
with:
package-dir: ${{ matrix.directory }}
config-file: pyproject.toml
env:
CIBW_PRERELEASE_PYTHONS: True
CIBW_ARCHS_MACOS: '${{ matrix.buildplatform[2] }}'
MYPYPATH: /project/typings
- name: Upload wheels as workflow artifacts
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # ratchet:actions/upload-artifact@v3
with:
name: ${{ matrix.buildplatform[1] }}-mypyc-wheels
path: ./wheelhouse/*.whl
check-download-artefacts:
name: dry-run for downloading artefacts
if: github.event_name == 'pull_request'
needs: [pure-wheels-sdist]
# needs: [pure-wheels-sdist, mypyc]
runs-on: ubuntu-latest
steps:
- name: Download Python artifacts
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # ratchet:actions/download-artifact@v3
with:
name: python-artefacts
path: dist
# - name: Download Linux x86_64 compiled artifacts
# uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # ratchet:actions/download-artifact@v3
# with:
# name: linux-x86_64-mypyc-wheels
# path: dist
# - name: Download MacOS x86_64 compiled artifacts
# uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # ratchet:actions/download-artifact@v3
# with:
# name: macos-x86_64-mypyc-wheels
# path: dist
# - name: Download MacOS arm64 compiled artifacts
# uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # ratchet:actions/download-artifact@v3
# with:
# name: macos-arm64-mypyc-wheels
# path: dist
# - name: Download MacOS universal2 compiled artifacts
# uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # ratchet:actions/download-artifact@v3
# with:
# name: macos-universal2-mypyc-wheels
# path: dist
# - name: dry ls
# run: ls -rthlaR
push-nightly:
name: Push nightly wheels
if: ${{ !github.event.repository.fork && github.event_name == 'push' }}
runs-on: ubuntu-latest
permissions:
id-token: write
# needs: [pure-wheels-sdist, mypyc]
needs: [pure-wheels-sdist]
steps:
- name: Download Python artifacts
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # ratchet:actions/download-artifact@v3
with:
name: python-artefacts
path: dist
# - name: Download Linux x86_64 compiled artifacts
# uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # ratchet:actions/download-artifact@v3
# with:
# name: linux-x86_64-mypyc-wheels
# path: dist
# - name: Download MacOS x86_64 compiled artifacts
# uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # ratchet:actions/download-artifact@v3
# with:
# name: macos-x86_64-mypyc-wheels
# path: dist
# - name: Download MacOS arm64 compiled artifacts
# uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # ratchet:actions/download-artifact@v3
# with:
# name: macos-arm64-mypyc-wheels
# path: dist
# - name: Download MacOS universal2 compiled artifacts
# uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # ratchet:actions/download-artifact@v3
# with:
# name: macos-universal2-mypyc-wheels
# path: dist
- name: Publish nightly wheels to test.pypi.org
uses: pypa/gh-action-pypi-publish@b7f401de30cb6434a1e19f805ff006643653240e # ratchet:pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
sucess-push: # https://github.com/marketplace/actions/alls-green#why
if: github.event_name == 'push'
# needs: [push-nightly, pure-wheels-sdist, mypyc]
needs: [push-nightly, pure-wheels-sdist]
runs-on: ubuntu-latest
outputs:
success: ${{ steps.everygreen.outputs.success }}
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # ratchet:re-actors/alls-green@release/v1
id: evergreen
with:
jobs: ${{ toJSON(needs) }}
sucess-pr: # https://github.com/marketplace/actions/alls-green#why
if: github.event_name == 'pull_request'
# needs: [pure-wheels-sdist, mypyc]
needs: [pure-wheels-sdist]
runs-on: ubuntu-latest
outputs:
success: ${{ steps.everygreen.outputs.success }}
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # ratchet:re-actors/alls-green@release/v1
id: evergreen
with:
jobs: ${{ toJSON(needs) }}