forked from facebookincubator/velox
-
Notifications
You must be signed in to change notification settings - Fork 0
188 lines (167 loc) · 5.96 KB
/
build_pyvelox.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
# Copyright (c) Facebook, Inc. and its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Build Pyvelox Wheels
on:
workflow_dispatch:
inputs:
version:
description: 'pyvelox version'
required: false
ref:
description: 'git ref to build'
required: false
publish:
description: 'publish to PyPI'
required: false
type: boolean
default: false
# schedule:
# - cron: '15 0 * * *'
pull_request:
paths:
- 'velox/**'
- '!velox/docs/**'
- 'third_party/**'
- 'pyvelox/**'
- '.github/workflows/build_pyvelox.yml'
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.repository }}-${{ github.head_ref || github.sha }}
cancel-in-progress: true
jobs:
# TODO: https://github.com/facebookincubator/velox/issues/9014
if: false
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04]
steps:
- uses: actions/checkout@v3
with:
ref: ${{ inputs.ref || github.ref }}
fetch-depth: 0
submodules: recursive
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: "Determine Version"
if: ${{ !inputs.version && github.event_name != 'pull_request' }}
id: version
run: |
# count number of commits since last tag matching a regex
# and use that to determine the version number
# e.g. if the last tag is 0.0.1, and there have been 5 commits since then
# the version will be 0.0.1a5
git fetch --tags
INITIAL_COMMIT=5d4db2569b7c249644bf36a543ba1bd8f12bf77c
# Can't use PCRE for portability
BASE_VERSION=$(grep -oE '[0-9]+\.[0-9]+\.[0-9]+' version.txt)
LAST_TAG=$(git describe --tags --match "pyvelox-v[0-9]*" --abbrev=0 || echo $INITIAL_COMMIT)
COMMITS_SINCE_TAG=$(git rev-list --count ${LAST_TAG}..HEAD)
if [ "$LAST_TAG" = "$INITIAL_COMMIT" ]; then
VERSION=$BASE_VERSION
else
VERSION=$(echo $LAST_TAG | sed '/pyvelox-v//')
fi
# NEXT_VERSION=$(echo $VERSION | awk -F. -v OFS=. '{$NF++ ; print}')
echo "build_version=${VERSION}a${COMMITS_SINCE_TAG}" >> $GITHUB_OUTPUT
- run: mkdir -p .ccache
- name: "Restore ccache"
uses: actions/cache/restore@v3
id: restore-cache
with:
path: ".ccache"
key: ccache-wheels-${{ matrix.os }}-${{ github.sha }}
restore-keys: |
ccache-wheels-${{ matrix.os }}-
- name: Install macOS dependencies
if: matrix.os == 'macos-11'
run: |
echo "OPENSSL_ROOT_DIR=/usr/local/opt/[email protected]/" >> $GITHUB_ENV
bash scripts/setup-macos.sh &&
bash scripts/setup-macos.sh install_folly
- name: "Create sdist"
if: matrix.os == 'ubuntu-22.04'
env:
BUILD_VERSION: "${{ inputs.version || steps.version.outputs.build_version }}"
run: |
python setup.py sdist --dist-dir wheelhouse
- name: Build wheels
uses: pypa/[email protected]
env:
# required for preadv/pwritev
MACOSX_DEPLOYMENT_TARGET: "11.0"
CIBW_ARCHS: "x86_64"
# On PRs only build for Python 3.7
CIBW_BUILD: ${{ github.event_name == 'pull_request' && 'cp37-*' || 'cp3*' }}
CIBW_SKIP: "*musllinux* cp36-*"
CIBW_MANYLINUX_X86_64_IMAGE: "ghcr.io/facebookincubator/velox-dev:torcharrow-avx"
CIBW_BEFORE_ALL_LINUX: >
mkdir -p /output &&
cp -R /host${{ github.workspace }}/.ccache /output/.ccache &&
ccache -s
CIBW_ENVIRONMENT_PASS_LINUX: CCACHE_DIR BUILD_VERSION
CIBW_TEST_EXTRAS: "tests"
CIBW_TEST_COMMAND: "cd {project}/pyvelox && python -m unittest -v"
CIBW_TEST_SKIP: "*macos*"
CCACHE_DIR: "${{ matrix.os != 'macos-11' && '/output' || github.workspace }}/.ccache"
BUILD_VERSION: "${{ inputs.version || steps.version.outputs.build_version }}"
with:
output-dir: wheelhouse
- name: "Move .ccache to workspace"
if: matrix.os != 'macos-11'
run: |
mkdir -p .ccache
cp -R ./wheelhouse/.ccache/* .ccache
- name: "Save ccache"
uses: actions/cache/save@v3
id: cache
with:
path: ".ccache"
key: ccache-wheels-${{ matrix.os }}-${{ github.sha }}
- name: "Rename wheel compatibility tag"
if: matrix.os == 'macos-11'
run: |
brew install rename
cd wheelhouse
rename 's/11_0/10_15/g' *.whl
- uses: actions/upload-artifact@v3
with:
name: wheels
path: |
./wheelhouse/*.whl
./wheelhouse/*.tar.gz
publish_wheels:
name: Publish Wheels to PyPI
if: ${{ github.event_name == 'schedule' || inputs.publish }}
needs: build_wheels
runs-on: ubuntu-22.04
steps:
- uses: actions/download-artifact@v3
with:
name: wheels
path: ./wheelhouse
- run: ls wheelhouse
- uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Publish a Python distribution to PyPI
uses: pypa/[email protected]
with:
password: ${{ secrets.PYPI_API_TOKEN }}
packages_dir: wheelhouse