-
Notifications
You must be signed in to change notification settings - Fork 7
251 lines (238 loc) · 7.53 KB
/
main.yaml
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
name: Test, build and deploy
on:
push:
branches: ["**"]
pull_request:
branches: ["**"]
release:
types: [created]
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.8.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install coverage
python -m pip install -r requirements.txt
- name: Test with unittest
run: python -m coverage run --source=. -m unittest discover -v -s test/unit/faassupervisor -p '*.py'
- name: Generate XML coverage report
run: python -m coverage xml
- name: Report coverage
uses: codacy/codacy-coverage-reporter-action@v1
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: coverage.xml
pypi:
needs: test
if: github.event_name == 'release'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.8.9
- name: Install dependencies
run: |
pip install --upgrade pip
pip install setuptools wheel twine
pip install -r requirements.txt
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USER }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASS }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
build-amd64:
needs: test
runs-on: ubuntu-latest
steps:
- name: Check out the codebase.
uses: actions/checkout@v4
- name: Build binary
run: |
docker run --rm --volume "${PWD}:/repo" ghcr.io/grycap/faas-supervisor-build:ubuntu16.04-1.1 /bin/sh -c " \
cd /repo && \
pip3.8 install -r requirements.txt
pyinstaller --onefile -n supervisor-bin faassupervisor/supervisor.py
pyinstaller faassupervisor/supervisor.py
cd dist
zip -r supervisor.zip supervisor
rm -r supervisor
mv supervisor-bin supervisor
"
- name: Upload amd64 binary
uses: actions/upload-artifact@v4
with:
name: supervisor
path: dist/supervisor
- name: Upload amd64 zip
uses: actions/upload-artifact@v4
with:
name: supervisor.zip
path: dist/supervisor.zip
build-alpine-amd64:
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build binary
run: |
docker run --rm --volume "${PWD}:/repo" ghcr.io/grycap/faas-supervisor-build:alpine-1.1 /bin/sh -c " \
cd /repo && \
pip install -r requirements.txt &&\
pyinstaller --onefile -n supervisor-alpine faassupervisor/supervisor.py &&\
pyinstaller faassupervisor/supervisor.py &&\
cd dist &&\
zip -r supervisor-alpine.zip supervisor
"
- name: Upload amd64 binary
uses: actions/upload-artifact@v4
with:
name: supervisor-alpine
path: dist/supervisor-alpine
- name: Upload amd64 zip
uses: actions/upload-artifact@v4
with:
name: supervisor-alpine.zip
path: dist/supervisor-alpine.zip
build-aarch64:
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build binary on emulated aarch64
run: |
docker run --rm --platform arm64 --volume "${PWD}:/repo" ghcr.io/grycap/faas-supervisor-build:ubuntu16.04-1.1 /bin/sh -c " \
cd /repo && \
pip3.8 install -r requirements.txt && \
pyinstaller --onefile -n supervisor-arm64 faassupervisor/supervisor.py && \
pyinstaller faassupervisor/supervisor.py && \
cd dist && \
zip -r supervisor-arm64.zip supervisor \
"
- name: Upload arm64 binary
uses: actions/upload-artifact@v4
with:
name: supervisor-arm64
path: dist/supervisor-arm64
- name: Upload arm64 zip
uses: actions/upload-artifact@v4
with:
name: supervisor-arm64.zip
path: dist/supervisor-arm64.zip
build-alpine-aarch64:
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build binary on emulated aarch64
run: |
docker run --rm --platform arm64 --volume "${PWD}:/repo" ghcr.io/grycap/faas-supervisor-build:alpine-1.1 /bin/sh -c " \
cd /repo && \
pyinstaller --onefile -n supervisor-alpine faassupervisor/supervisor.py &&\
pyinstaller faassupervisor/supervisor.py &&\
cd dist &&\
zip -r supervisor-alpine.zip supervisor
"
- name: Upload arm64 binary
uses: actions/upload-artifact@v4
with:
name: supervisor-alpine-arm64
path: dist/supervisor-alpine-arm64
- name: Upload arm64 zip
uses: actions/upload-artifact@v4
with:
name: supervisor-alpine-arm64.zip
path: dist/supervisor-alpine-arm64.zip
release-assets:
needs:
- build-amd64
- build-aarch64
- build-alpine-amd64
- build-alpine-aarch64
if: github.event_name == 'release'
runs-on: ubuntu-latest
steps:
- name: Download jobs' artifacts
uses: actions/download-artifact@v4
- name: Upload artifacts to release
uses: softprops/action-gh-release@v1
with:
files: |
supervisor/supervisor
supervisor.zip/supervisor.zip
supervisor-arm64/supervisor-arm64
supervisor-arm64.zip/supervisor-arm64.zip
supervisor-alpine.zip/supervisor-alpine.zip
supervisor-alpine/supervisor-alpine
supervisor-alpine-arm64.zip/supervisor-alpine-arm64.zip
supervisor-alpine-arm64/supervisor-alpine-arm64
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
push_faas_supervisor_kit:
if: github.event_name == 'release'
needs:
- release-assets
env:
REGISTRY: ghcr.io
IMAGE_NAME: grycap/faas-supervisor-kit
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
attestations: write
id-token: write
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Log in to Docker Hub
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
id: push
uses: docker/build-push-action@v4
with:
context: .
file: ./extra/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
FAAS_VERSION=${{ steps.meta.outputs.version }}
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true