-
Notifications
You must be signed in to change notification settings - Fork 522
247 lines (216 loc) · 7.57 KB
/
ci.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
235
236
237
238
239
240
241
242
243
244
245
246
name: Codon CI
on:
push:
branches:
- master
- develop
tags:
- '*'
pull_request:
branches:
- develop
jobs:
release:
name: Create GitHub Release
runs-on: ubuntu-latest
steps:
- name: Check
if: contains(github.ref, 'tags/v')
id: check
run: echo "::set-output name=MAKE_RELEASE::true"
- name: Create Release
id: create_release
if: steps.check.outputs.MAKE_RELEASE
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: false
prerelease: false
- name: Output Release URL File
if: steps.check.outputs.MAKE_RELEASE
run: echo "${{ steps.create_release.outputs.upload_url }}" > release_url.txt
- name: Save Release URL File for Publish
if: steps.check.outputs.MAKE_RELEASE
uses: actions/upload-artifact@v4
with:
name: release_url
path: release_url.txt
manylinux:
runs-on: ubuntu-latest
name: Codon CI (manylinux)
needs: [ release ]
steps:
- uses: actions/checkout@v4
- name: Cache Dependencies
id: cache-deps
uses: actions/cache@v4
with:
path: llvm
key: manylinux-llvm
- name: Main
uses: ./.github/actions/build-manylinux
- name: Load Release URL File
if: contains(github.ref, 'tags/v')
uses: actions/download-artifact@v4
with:
name: release_url
- name: Get Release URL
id: get_release_url
if: contains(github.ref, 'tags/v')
run: |
echo ::set-output name=file_name::${REPOSITORY_NAME##*/}-${TAG_REF_NAME##*/v} # RepositoryName-v1.0.0
value=`cat release_url/release_url.txt`
echo ::set-output name=upload_url::$value
env:
TAG_REF_NAME: ${{ github.ref }}
REPOSITORY_NAME: ${{ github.repository }}
- name: Upload Release Asset
if: contains(github.ref, 'tags/v')
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.get_release_url.outputs.upload_url }}
asset_path: ./codon-linux-x86_64.tar.gz
asset_name: codon-linux-x86_64.tar.gz
asset_content_type: application/gzip
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: manylinux-x86_64
path: codon-linux-x86_64.tar.gz
main:
strategy:
matrix:
os:
- ubuntu-latest
- macos-12
runs-on: ${{ matrix.os }}
name: Codon CI
needs: [ release ]
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Linux Setup
if: startsWith(matrix.os, 'ubuntu')
run: |
echo "LIBEXT=so" >> $GITHUB_ENV
echo "OS_NAME=linux" >> $GITHUB_ENV
- name: macOS Setup
if: startsWith(matrix.os, 'macos')
run: |
brew install automake
echo "LIBEXT=dylib" >> $GITHUB_ENV
echo "OS_NAME=osx" >> $GITHUB_ENV
- name: Set up Python
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install numpy cython wheel astunparse
which python
which pip
echo "CODON_PYTHON=$(python test/python/find-python-library.py)" >> $GITHUB_ENV
- name: Cache Dependencies
id: cache-deps
uses: actions/cache@v4
with:
path: llvm
key: ${{ runner.os }}-llvm
- name: Build Dependencies
if: steps.cache-deps.outputs.cache-hit != 'true'
run: ./scripts/deps.sh 2
env:
CC: clang
CXX: clang++
- name: Build
run: |
mkdir build
export LLVM_DIR=$(llvm/bin/llvm-config --cmakedir)
(cd build && cmake .. -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=${CC} \
-DCMAKE_CXX_COMPILER=${CXX})
cmake --build build --config Release -- VERBOSE=1
cmake --install build --prefix=codon-deploy
env:
CC: clang
CXX: clang++
- name: Build Cython
run: |
(cd codon-deploy/python && python3 setup.py sdist)
CODON_DIR=$(pwd)/codon-deploy python -m pip install -v codon-deploy/python/dist/*.gz
python test/python/cython_jit.py
env:
CC: clang
CXX: clang++
- name: Test
run: |
ln -s build/libcodonrt.${LIBEXT} .
build/codon_test
test/app/test.sh build
(cd test/python && CODON_DIR=$(pwd)/../../codon-deploy python3 setup.py build_ext --inplace && python3 pyext.py)
env:
CODON_PATH: ./stdlib
PYTHONPATH: .:./test/python
LD_LIBRARY_PATH: ./build
- name: Artifact Environment
run: |
echo "CODON_BUILD_ARCHIVE=codon-$(uname -s | awk '{print tolower($0)}')-$(uname -m).tar.gz" >> $GITHUB_ENV
- name: Prepare Artifacts
run: |
cp -rf codon-deploy/python/dist .
rm -rf codon-deploy/lib/libfmt.a codon-deploy/lib/pkgconfig codon-deploy/lib/cmake codon-deploy/python/codon.egg-info codon-deploy/python/dist codon-deploy/python/build
if [ -e build/libunwind.${LIBEXT} ]; then cp build/libunwind.${LIBEXT} codon-deploy/lib/codon/; fi
tar -czf ${CODON_BUILD_ARCHIVE} codon-deploy
du -sh codon-deploy
- name: Load Release URL File
if: contains(github.ref, 'tags/v')
uses: actions/download-artifact@v4
with:
name: release_url
- name: Get Release URL
id: get_release_url
if: contains(github.ref, 'tags/v')
run: |
echo ::set-output name=file_name::${REPOSITORY_NAME##*/}-${TAG_REF_NAME##*/v} # RepositoryName-v1.0.0
value=`cat release_url/release_url.txt`
echo ::set-output name=upload_url::$value
env:
TAG_REF_NAME: ${{ github.ref }}
REPOSITORY_NAME: ${{ github.repository }}
- name: Upload Release Asset
if: contains(github.ref, 'tags/v') && startsWith(matrix.os, 'macos')
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.get_release_url.outputs.upload_url }}
asset_path: ./codon-darwin-x86_64.tar.gz
asset_name: codon-darwin-x86_64.tar.gz
asset_content_type: application/gzip
- name: Upload Artifacts
if: startsWith(matrix.os, 'macos')
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}-x86_64
path: codon-darwin-x86_64.tar.gz
- name: Upload Artifacts
if: startsWith(matrix.os, 'ubuntu')
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}-x86_64
path: codon-linux-x86_64.tar.gz
# - name: Publish on TestPyPI
# if: github.ref == 'refs/heads/develop' && startsWith(matrix.os, 'ubuntu')
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# repository-url: https://test.pypi.org/legacy/
# skip-existing: true
- name: Publish Package
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') && startsWith(matrix.os, 'ubuntu')
uses: pypa/gh-action-pypi-publish@release/v1