-
Notifications
You must be signed in to change notification settings - Fork 10
294 lines (251 loc) · 9.14 KB
/
ci.yml
File metadata and controls
294 lines (251 loc) · 9.14 KB
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
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: CI workflow
on:
pull_request:
paths-ignore:
- 'docs/**'
push:
branches:
- master
paths-ignore:
- 'docs/**'
release:
types:
- created
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
DEBIAN_FRONTEND: noninteractive
LANG: C.UTF-8
jobs:
flake8:
runs-on: ubuntu-latest
continue-on-error: true
name: Check flake8 rules
steps:
- uses: actions/checkout@v5
- uses: actions/setup-python@v6
with:
python-version: '3.10'
- name: Install flake8
run: pip install flake8
- run: flake8 convertit
isort:
runs-on: ubuntu-latest
continue-on-error: true
name: Check isort rules
steps:
- uses: actions/checkout@v5
- uses: actions/setup-python@v6
with:
python-version: '3.10'
- name: Install isort
run: pip install isort
- run: isort -c convertit
build:
runs-on: ubuntu-latest
continue-on-error: true
strategy:
matrix:
version: ['24.04', '22.04', docker]
include:
- version: '24.04'
distro: noble
- version: '22.04'
distro: jammy
- version: docker
distro: docker image
name: Build ${{ matrix.distro }}
steps:
- uses: actions/checkout@v5
- name: Prepare debian versioning
if: ${{ matrix.version != 'docker' }}
run: |
sed -i 's/+dev/.ubuntu${{ matrix.version }}~dev'$GITHUB_RUN_ID'/' debian/changelog
sed -i 's/convertit (\([0-9]\+\.[0-9]\+\.[0-9]\+\)\(.*\)) RELEASED;/convertit (\1.ubuntu${{ matrix.version }}\2) ${{ matrix.distro }};/' debian/changelog
- name: Building package
if: ${{ matrix.version != 'docker' }}
run: |
DISTRO=ubuntu:${{ matrix.distro }} make build_deb
cp ./dpkg/*.deb /home/runner/work/convertit/
- name: Archive package artifact
if: ${{ matrix.version != 'docker' }}
uses: actions/upload-artifact@v5
with:
name: debian-${{ matrix.distro }}
path: |
/home/runner/work/convertit/*.deb
- name: Set up Docker Buildx
if: ${{ matrix.version == 'docker' }}
id: buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image
if: ${{ matrix.version == 'docker' }}
run: |
docker build -t convertit:latest .
- name: Upload image
if: ${{ matrix.version == 'docker' }}
uses: ishworkh/container-image-artifact-upload@v2.0.0
with:
image: "convertit:latest"
e2e:
strategy:
matrix:
distro: [ noble, jammy, docker ]
include:
- distro: noble
version: '24.04'
- distro: jammy
version: '22.04'
- distro: docker
version: latest
name: Test ${{ matrix.distro }}
runs-on: ubuntu-${{ matrix.version }}
needs: [ build ]
steps:
- uses: actions/checkout@v5
- uses: actions/download-artifact@v6
if: ${{ matrix.distro != 'docker' }}
with:
name: debian-${{ matrix.distro }}
- name: Download image
if: ${{ matrix.distro == 'docker' }}
uses: ishworkh/container-image-artifact-download@v2.1.0
with:
image: "convertit:latest"
- name: Prepare test server
run: docker run -d -p 8080:80 -v ./test:/var/www/ -v ./test/nginx.conf:/etc/nginx/conf.d/default.conf nginx:alpine
- name: Install package
if: ${{ matrix.distro != 'docker' }}
run: |
sudo apt -qq update
sudo apt-get -yqq install --no-install-recommends /home/runner/work/convertit/convertit/*.deb || exit 0;
- name: Run docker image (if required)
if: ${{ matrix.distro == 'docker' }}
run: |
docker run -p 6543:6543 -d convertit:latest
- name: Test ODT / PDF conversion
run: |
wget -O myfile.pdf "http://localhost:6543/?url=http://172.17.0.1:8080/example.odt&from=application/vnd.oasis.opendocument.text"
if file -b --mime-type ./myfile.pdf |grep -q 'application/pdf'; then
echo "File is PDF";
exit 0;
else
echo "File is not PDF";
file -b -f ./myfile.pdf;
exit 1;
fi
- name: Test ODT / DOC conversion
run: |
wget -O myfile.doc "http://localhost:6543/?url=http://172.17.0.1:8080/example.odt&from=application/vnd.oasis.opendocument.text&to=application/msword"
if file -b --mime-type ./myfile.doc |grep -q 'application/msword'; then
echo "File is DOC";
exit 0;
else
echo "File is not DOC";
file -b -f ./myfile.doc;
exit 1;
fi
- name: Test SVG / PNG conversion
run: |
wget -O myfile.png "http://localhost:6543/?url=http://172.17.0.1:8080/example.svg&from=image/svg%2Bxml&to=image/png"
if file -b --mime-type ./myfile.png |grep -q 'image/png'; then
echo "File is PNG";
exit 0;
else
echo "File is not PNG";
file -b -f ./myfile.png;
exit 1;
fi
- name: Test SVG / PDF conversion
run: |
wget -O myfile.pdf "http://localhost:6543/?url=http://172.17.0.1:8080/example.svg&from=image/svg%2Bxml&to=application/pdf"
if file -b --mime-type ./myfile.pdf |grep -q 'application/pdf'; then
echo "File is PDF";
exit 0;
else
echo "File is not PDF";
file -b -f ./myfile.pdf;
exit 1;
fi
deploy:
name: Publish (on release only)
runs-on: ubuntu-latest
needs: [ flake8, isort, e2e ]
if: ${{ github.event_name == 'release' && github.event.action == 'created' }}
steps:
- uses: actions/checkout@v5
- name: Download 20.04 debian artifact
uses: actions/download-artifact@v6
with:
name: debian-focal
- name: Download 22.04 debian artifact
uses: actions/download-artifact@v6
with:
name: debian-jammy
- name: Download 24.04 debian artifact
uses: actions/download-artifact@v6
with:
name: debian-noble
- name: Download docker image
uses: ishworkh/container-image-artifact-download@v2.1.0
with:
image: "convertit:latest"
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_LOGIN }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
makinacorpus/convertit
ghcr.io/makinacorpus/convertit
- name: Build and push image
uses: docker/build-push-action@v6
with:
push: true
provenance: mode=max
sbom: true
builder: ${{ steps.buildx.outputs.name }}
tags: ${{ steps.meta.outputs.tags }}
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATE_KEY }}
known_hosts: ${{ secrets.SSH_KNOWN_HOSTS }}
- name: Publish debian packages
run: |
if [[ "${{ github.ref }}" == *"dev"* ]]; then
export DEB_COMPONENT=dev
else
export DEB_COMPONENT=main
fi
echo "${{ github.ref }} : Publishing as $DEB_COMPONENT package"
scp -P ${{ secrets.SSH_PORT }} -o StrictHostKeyChecking=no /home/runner/work/convertit/convertit/convertit_*_amd64.deb ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/srv/packages/incoming/$DEB_COMPONENT/
if [[ "${{ github.ref }}" == *"dev"* ]]; then
ssh -p ${{ secrets.SSH_PORT }} -o StrictHostKeyChecking=no ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} make jammy_dev -C /srv/packages
ssh -p ${{ secrets.SSH_PORT }} -o StrictHostKeyChecking=no ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} make noble_dev -C /srv/packages
else
ssh -p ${{ secrets.SSH_PORT }} -o StrictHostKeyChecking=no ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} make jammy_main -C /srv/packages
ssh -p ${{ secrets.SSH_PORT }} -o StrictHostKeyChecking=no ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} make noble_main -C /srv/packages
fi
- name: Attach debian packages as release binaries
uses: skx/github-action-publish-binaries@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: '*.deb'