-
Notifications
You must be signed in to change notification settings - Fork 14
486 lines (458 loc) · 16.5 KB
/
on_push.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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
name: Test and Build
on: [push]
env:
# NOTE keep versions in sync with dev_images.yml and version in TOSCA templates
TERRAFORM_VERSION: 1.1.4 # sync with tosca_plugins/artifacts.yaml
HELM_VERSION: 3.7.1 # sync with configurators/helm-template.yaml
GCLOUD_VERSION: 499.0.0 # sync with tosca_plugins/artifacts.yaml and Dockerfile
KOMPOSE_VERSION: v1.26.1 # sync with Dockerfile
KUBECTL_VERSION: v1.24.2
K3D_VERSION: v4.4.6
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python: [3.8, 3.9, "3.10", "3.11.0", "3.12", "3.13"]
env:
TOX_SKIP_ENV: .+(docker|lock)
UNFURL_LOGGING: info
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
check-latest: true
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: clippy
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ env.TERRAFORM_VERSION }}
terraform_wrapper: false
- name: Setup helm
uses: Azure/[email protected]
with:
version: ${{ env.HELM_VERSION }}
- name: Setup kubectl
uses: Azure/[email protected]
with:
version: ${{ env.KUBECTL_VERSION }}
- name: Setup kompose
run: |
wget https://github.com/kubernetes/kompose/releases/download/${KOMPOSE_VERSION}/kompose-linux-amd64
chmod +x kompose-linux-amd64
sudo mv kompose-linux-amd64 /usr/local/bin/kompose
- name: Setup k3d
run: |
wget https://github.com/rancher/k3d/releases/download/"${{ env.K3D_VERSION }}"/k3d-linux-amd64
chmod +x k3d-linux-amd64
sudo mv k3d-linux-amd64 /usr/local/bin/k3d
- name: Set up the cluster
run: |
k3d cluster create
kubectl get node
k3d kubeconfig merge --all -d
kubectl config view
- name: Install Tox and any other packages
run: pip install tox==3.28.0
- name: Run mypy and Tox
# Run tox using the version of Python in `PATH`
run: |
git config --global user.email "[email protected]"
git config --global user.name "Test Robot"
git config --global push.autoSetupRemote true
git config --global init.defaultBranch main
export PY_V=py3`python -c "import sys; print(sys.version_info.minor, end='')"`
tox -c tosca-parser/tox.ini -v -e $PY_V
tox -e $PY_V -v -- -vv -n auto --dist loadfile
.tox/$PY_V/bin/mypy unfurl --install-types --non-interactive
- name: Run cargo clippy and cargo test
if: matrix.python == 3.12
run: |
cargo clippy --manifest-path rust/Cargo.toml
cargo test --no-default-features --manifest-path rust/Cargo.toml
- name: build docs
if: matrix.python == 3.12
run: tox -e docs -- -W --keep-going
- name: upload docs
if: matrix.python == 3.12
uses: actions/upload-artifact@v4
with:
name: DocumentationHTML
path: .tox/docs/html/
publish_dockerhub:
needs: test
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
env:
DOCKERHUB_USER: "ocbuilds"
# Map a step output to a job output
outputs:
release: ${{ steps.get_tag_name.outputs.release }}
steps:
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ env.DOCKERHUB_USER }}
password: ${{ secrets.DOCKER_HUB }}
- name: Fetch repo
uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
- name: Get the tag name or abbreviated commit digest
id: get_tag_name
run: |
label=$(git describe --contains --always --match=v*)
echo "tag=${label%^0}" >> $GITHUB_OUTPUT
if [[ $label =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,4}.0$ ]]; then
echo "release=true" >> $GITHUB_OUTPUT
fi
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
onecommons/unfurl
tags: |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
type=raw,value=stable,enable=${{ steps.get_tag_name.outputs.release || 'false' }}
type=raw,value=${{ steps.get_tag_name.outputs.tag }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and push
id: docker_build
uses: docker/build-push-action@v4
with:
context: ./
file: ./docker/Dockerfile
push: true
build-args: |
HELM_VERSION=${{ env.HELM_VERSION }}
TERRAFORM_VERSION=${{ env.TERRAFORM_VERSION }}
GCLOUD_VERSION=${{ env.GCLOUD_VERSION }}
KOMPOSE_VERSION=${{ env.KOMPOSE_VERSION }}
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
publish_dockerhub_server:
needs: test
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
env:
DOCKERHUB_USER: "ocbuilds"
steps:
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ env.DOCKERHUB_USER }}
password: ${{ secrets.DOCKER_HUB }}
- name: Fetch repo
uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
- name: Get the tag name or abbreviated commit digest
id: get_tag_name
run: |
label=$(git describe --contains --always --match=v*)
echo "tag=${label%^0}" >> $GITHUB_OUTPUT
if [[ $label =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,4}.0$ ]]; then
echo "release=true" >> $GITHUB_OUTPUT
fi
- name: Docker meta for unfurl server
id: meta_server
uses: docker/metadata-action@v4
with:
images: |
onecommons/unfurl
tags: |
type=raw,value=latest-server,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
type=raw,value=stable-server,enable=${{ steps.get_tag_name.outputs.release || 'false' }}
type=raw,value=${{ steps.get_tag_name.outputs.tag }}-server
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and push unfurl server
id: docker_build_server
uses: docker/build-push-action@v4
with:
context: ./
file: ./docker/Dockerfile.server
push: true
tags: ${{ steps.meta_server.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
publish_dockerhub_nginx:
needs: [test, publish_dockerhub_server]
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
env:
DOCKERHUB_USER: "ocbuilds"
steps:
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ env.DOCKERHUB_USER }}
password: ${{ secrets.DOCKER_HUB }}
- name: Fetch repo
uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
- name: Get the tag name or abbreviated commit digest
id: get_tag_name
run: |
label=$(git describe --contains --always --match=v*)
echo "tag=${label%^0}" >> $GITHUB_OUTPUT
if [[ $label =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,4}.0$ ]]; then
echo "release=true" >> $GITHUB_OUTPUT
fi
- name: Docker meta for unfurl server
id: meta_server
uses: docker/metadata-action@v4
with:
images: |
onecommons/unfurl
tags: |
type=raw,value=latest-server-cached,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
type=raw,value=stable-server-cached,enable=${{ steps.get_tag_name.outputs.release || 'false' }}
type=raw,value=${{ steps.get_tag_name.outputs.tag }}-server-cached
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and push unfurl server
id: docker_build_server
uses: docker/build-push-action@v4
with:
context: ./
file: ./docker/Dockerfile.server-cached
push: true
build-args: |
FROM_IMAGE=docker.io/onecommons/unfurl
FROM_TAG=${{ steps.get_tag_name.outputs.tag }}-server
tags: ${{ steps.meta_server.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
publish_dockerhub_podman:
needs: publish_dockerhub
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
env:
DOCKERHUB_USER: "ocbuilds"
steps:
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ env.DOCKERHUB_USER }}
password: ${{ secrets.DOCKER_HUB }}
- name: fetch repo
uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
- name: Get the tag name or abbreviated commit digest
id: get_tag_name
run: |
label=$(git describe --contains --always --match=v*)
echo "tag=${label%^0}" >> $GITHUB_OUTPUT
if [[ $label =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,4}.0$ ]]; then
echo "release=true" >> $GITHUB_OUTPUT
fi
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
onecommons/unfurl
tags: |
type=raw,value=latest-podman,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
type=raw,value=stable-podman,enable=${{ steps.get_tag_name.outputs.release || 'false' }}
type=raw,value=${{ steps.get_tag_name.outputs.tag }}-podman
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and push
id: docker_build
uses: docker/build-push-action@v4
with:
context: ./
file: ./docker/Dockerfile.podman
push: true
build-args: |
HELM_VERSION=${{ env.HELM_VERSION }}
TERRAFORM_VERSION=${{ env.TERRAFORM_VERSION }}
GCLOUD_VERSION=${{ env.GCLOUD_VERSION }}
KOMPOSE_VERSION=${{ env.KOMPOSE_VERSION }}
UNFURL_TAG=${{ steps.get_tag_name.outputs.tag }}
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
build:
name: >
build py3.${{ matrix.python-version }} on ${{ matrix.platform || matrix.os }}
(${{ matrix.alt_arch_name || matrix.arch }})
needs:
- test
strategy:
fail-fast: false
matrix:
os: [ubuntu, macos]
python-version: ['8']
arch: [main, alt]
include:
- os: ubuntu
platform: linux
- os: ubuntu
arch: alt
alt_arch_name: aarch64
- os: macos
arch: alt
alt_arch_name: arm64
# - os: macos
# arch: main
runs-on: ${{ format('{0}-latest', matrix.os) }}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: set up python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: set up rust
if: matrix.os != 'ubuntu'
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
- run: rustup target add aarch64-apple-darwin x86_64-apple-darwin
if: matrix.os == 'macos'
- run: rustup toolchain install stable-i686-pc-windows-msvc
if: matrix.os == 'windows'
- run: rustup target add i686-pc-windows-msvc
if: matrix.os == 'windows'
- name: install python dependencies
run: pip install -U setuptools wheel twine cibuildwheel pbr
- name: build sdist
if: matrix.os == 'ubuntu' && matrix.python-version == '8'
run: |
pip install -U setuptools-rust
python setup.py sdist
- name: Set up QEMU
if: matrix.os == 'ubuntu'
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: build ${{ matrix.platform || matrix.os }} binaries
run: cibuildwheel --output-dir dist
env:
CIBW_BUILD_FRONTEND: "build"
CIBW_BUILD: 'cp3${{ matrix.python-version }}-*'
# rust doesn't seem to be available for musl linux on i686
# and skip rare archs to speed up builds
CIBW_SKIP: '*-musllinux_i686 *ppc* *s390x'
# we build for "alt_arch_name" if it exists, else 'auto
CIBW_ARCHS: ${{ matrix.alt_arch_name || 'auto' }}
# see https://cibuildwheel.readthedocs.io/en/stable/faq/#universal2, tests can run on cross-compiled binaries
# CIBW_TEST_SKIP: '*-macosx_arm64'
# CIBW_TEST_REQUIRES: pytest
# CIBW_TEST_COMMAND: 'pytest {project}/tests -s'
CIBW_ENVIRONMENT: 'PATH="$HOME/.cargo/bin:$PATH" MACOSX_DEPLOYMENT_TARGET=10.12'
CIBW_ENVIRONMENT_WINDOWS: 'PATH="$UserProfile\.cargo\bin;$PATH"'
CIBW_ARCHS_MACOS: "universal2"
CIBW_MANYLINUX_I686_IMAGE: manylinux2014
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
CIBW_MUSLLINUX_X86_64_IMAGE: musllinux_1_1
CIBW_MANYLINUX_AARCH64_IMAGE: quay.io/pypa/manylinux_2_28_aarch64:latest
CIBW_MUSLLINUX_AARCH64_IMAGE: musllinux_1_1
CIBW_BEFORE_BUILD: rustup show
CIBW_BEFORE_BUILD_LINUX: >
curl https://sh.rustup.rs -sSf | sh -s -- --profile=minimal -y &&
rustup show
- run: ${{ matrix.ls || 'ls -lh' }} dist/
- run: twine check dist/*
- uses: actions/upload-artifact@v3 # v4 doesn't allow same filename to be reloaded, see https://github.com/actions/upload-artifact/blob/main/docs/MIGRATION.md#merging-multiple-artifacts
with:
name: pypi_files
path: dist
inspect-pypi-assets:
needs: [build]
runs-on: ubuntu-latest
steps:
- name: get dist artifacts
uses: actions/download-artifact@v3
with:
name: pypi_files
path: dist
- name: list dist files
run: |
ls -lh dist/
echo "`ls dist | wc -l` files"
- name: extract and list sdist file
run: |
mkdir sdist-files
tar -xvf dist/*.tar.gz -C sdist-files
tree -a sdist-files
- name: extract and list wheel file
run: |
ls dist/*cp3*-manylinux*x86_64.whl | head -n 1
python -m zipfile --list `ls dist/*cp3*-manylinux*x86_64.whl | head -n 1`
- run: pip install twine
- run: twine check dist/*
- name: release to test pypi
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.TEST_PYPI }}
verbose: true
repository-url: https://test.pypi.org/legacy/
publish_pypi:
needs: [inspect-pypi-assets, publish_dockerhub]
if: needs.publish_dockerhub.outputs.release
runs-on: ubuntu-latest
steps:
- name: get dist artifacts
uses: actions/download-artifact@v3
with:
name: pypi_files
path: dist
- name: release to pypi
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI }}
verbose: true
docs:
needs: test
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/publish-docs'
runs-on: ubuntu-latest
steps:
- name: Download documentation
uses: actions/download-artifact@v4
with:
name: DocumentationHTML
path: build
- name: Commit documentation changes
run: |
git clone ${{github.server_url}}/${{github.repository}} --branch gh-pages --single-branch gh-pages
cp -r build/* gh-pages/
cd gh-pages
touch .nojekyll
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add .
git commit -m "Update documentation" -a || true
# The above command will fail if no changes were present, so we ignore
# that.
- name: Push docs to gh-pages branch
uses: ad-m/github-push-action@master
with:
branch: gh-pages
directory: gh-pages
github_token: ${{ secrets.GITHUB_TOKEN }}