-
Notifications
You must be signed in to change notification settings - Fork 14
337 lines (331 loc) · 11.8 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
name: Test and Build
on: [push]
env:
# NOTE keep versions in sync with 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: 398.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"]
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 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: build docs
if: matrix.python == 3.9
run: tox -e docs -- -W --keep-going
- name: upload docs
if: matrix.python == 3.9
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
publish_pypi:
needs: publish_dockerhub
if: needs.publish_dockerhub.outputs.release
runs-on: ubuntu-latest
steps:
- name: fetch repo
uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
- name: build python package
run: python setup.py sdist bdist_wheel
- name: release to pypi
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI }}
verbose: true
docs:
needs: publish_dockerhub
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/publish-docs'
runs-on: ubuntu-latest
steps:
- name: Download documentation
uses: actions/download-artifact@v3
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 }}