-
Notifications
You must be signed in to change notification settings - Fork 147
234 lines (228 loc) · 7.41 KB
/
default.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: default
on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 2
- uses: actions/cache@v2
id: cache
with:
# pants-specific cache
path: |
~/.cache/pants/setup
~/.cache/pants/lmdb_store
~/.cache/pants/named_caches
key: ${{ runner.os }}-
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.10"
cache: pip
- name: Bootstrap Pants
run: |
mkdir .tmp
./pants --no-verify-config version
- name: Check BUILD files
run: ./pants tailor --check update-build-files --check
- name: Lint
run: |
if [ "$GITHUB_EVENT_NAME" == "pull_request" -a -n "$GITHUB_HEAD_REF" ]; then
echo "(skipping matchers for pull request from local branches)"
else
echo "::add-matcher::.github/workflows/flake8-matcher.json"
fi
if [ -n "$GITHUB_BASE_REF" ]; then
BASE_REF="origin/${GITHUB_BASE_REF}"
git fetch --no-tags --depth=1 origin "$GITHUB_BASE_REF"
else
BASE_REF="HEAD~1"
fi
./pants lint --changed-since=$BASE_REF --changed-dependees=transitive
- name: Upload pants log
uses: actions/upload-artifact@v2
with:
name: pants.lint.log
path: .pants.d/pants.log
if: always() # We want the log even on failures.
typecheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 2
- uses: actions/cache@v2
id: cache
with:
# pants-specific cache
path: |
~/.cache/pants/setup
~/.cache/pants/lmdb_store
~/.cache/pants/named_caches
key: ${{ runner.os }}-
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.10"
cache: pip
- name: Bootstrap Pants
run: |
mkdir .tmp
./pants --no-verify-config version
- name: Check BUILD files
run: ./pants tailor --check update-build-files --check
- name: Typecheck
run: |
if [ "$GITHUB_EVENT_NAME" == "pull_request" -a -n "$GITHUB_HEAD_REF" ]; then
echo "(skipping matchers for pull request from local branches)"
else
echo "::add-matcher::.github/workflows/mypy-matcher.json"
fi
if [ -n "$GITHUB_BASE_REF" ]; then
BASE_REF="origin/${GITHUB_BASE_REF}"
git fetch --no-tags --depth=1 origin "$GITHUB_BASE_REF"
else
BASE_REF="HEAD~1"
fi
./pants check --changed-since=$BASE_REF --changed-dependees=transitive
- name: Upload pants log
uses: actions/upload-artifact@v2
with:
name: pants.check.log
path: .pants.d/pants.log
if: always() # We want the log even on failures.
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 2
submodules: true
- uses: actions/cache@v2
id: cache
with:
# pants-specific cache
path: |
~/.cache/pants/setup
~/.cache/pants/lmdb_store
~/.cache/pants/named_caches
key: ${{ runner.os }}-
- name: Create LFS file hash list
run: git lfs ls-files -l | cut -d ' ' -f1 | sort > .lfs-assets-id
- name: Restore LFS cache
uses: actions/cache@v2
id: lfs-cache
with:
path: .git/lfs
key: lfs-${{ hashFiles('.lfs-assets-id') }}
- name: Git LFS Pull
run: git lfs pull
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.10"
cache: pip
- name: Bootstrap Pants
run: |
mkdir .tmp
./pants --no-verify-config version
- name: Check BUILD files
run: ./pants tailor --check update-build-files --check
- name: Test
run: |
if [ -n "$GITHUB_BASE_REF" ]; then
BASE_REF="origin/${GITHUB_BASE_REF}"
git fetch --no-tags --depth=1 origin "$GITHUB_BASE_REF"
else
BASE_REF="HEAD~1"
fi
./pants test --changed-since=$BASE_REF --changed-dependees=transitive
- name: Upload pants log
uses: actions/upload-artifact@v2
with:
name: pants.test.log
path: .pants.d/pants.log
if: always() # We want the log even on failures.
deploy-to-pypi:
needs: [lint, typecheck, test]
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: actions/cache@v2
id: cache
with:
# pants-specific cache
path: |
~/.cache/pants/setup
~/.cache/pants/lmdb_store
~/.cache/pants/named_caches
key: ${{ runner.os }}-
- name: Create LFS file hash list
run: git lfs ls-files -l | cut -d ' ' -f1 | sort > .lfs-assets-id
- name: Restore LFS cache
uses: actions/cache@v2
id: lfs-cache
with:
path: .git/lfs
key: lfs-${{ hashFiles('.lfs-assets-id') }}
- name: Git LFS Pull
run: git lfs pull
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.10"
cache: pip
- name: Bootstrap Pants
run: |
mkdir .tmp
./pants --no-verify-config version
- name: Install local dependencies for packaging and publishing
run: |
pip install -U 'twine~=4.0' 'packaging>=21.3'
- name: Build packages
run: |
# Normalize the package version
PKGVER=$(python -c "import packaging.version,pathlib; print(str(packaging.version.Version(pathlib.Path('VERSION').read_text())))")
# Build non-platform-specific wheels
./pants --platform-specific-resources-target=linux_x86_64 --tag="wheel" --tag="-platform-specific" package '::'
# Build x86_64 wheels
MANYLINUX_PTAG=manylinux2014_x86_64
MACOS_PTAG=macosx_11_0_x86_64
./pants --platform-specific-resources-target=linux_x86_64 --tag="wheel" --tag="+platform-specific" package '::'
for pkgname in "kernel_binary"; do
mv "dist/backend.ai_${pkgname}-${PKGVER}-py3-none-any.whl" \
"dist/backend.ai_${pkgname}-${PKGVER}-py3-none-${MANYLINUX_PTAG}.${MACOS_PTAG}.whl"
done
# Build arm64 wheels
MANYLINUX_PTAG=manylinux2014_aarch64
MACOS_PTAG=macosx_11_0_arm64
./pants --platform-specific-resources-target=linux_arm64 --tag="wheel" --tag="+platform-specific" package '::'
for pkgname in "kernel_binary"; do
mv "dist/backend.ai_${pkgname}-${PKGVER}-py3-none-any.whl" \
"dist/backend.ai_${pkgname}-${PKGVER}-py3-none-${MANYLINUX_PTAG}.${MACOS_PTAG}.whl"
done
ls -lh dist
- name: Publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
# We don't use `./pants publish ::` because we manually rename the
# wheels after buildling them to add arch-specific tags.
run: |
twine upload dist/*.whl
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: dist
path: dist
- name: Upload pants log
uses: actions/upload-artifact@v2
with:
name: pants.deploy.log
path: .pants.d/pants.log
if: always() # We want the log even on failures.