-
Notifications
You must be signed in to change notification settings - Fork 1
270 lines (265 loc) · 9.25 KB
/
build.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
on:
pull_request:
push:
branches:
- main
workflow_dispatch: # Allow manual triggering
jobs:
versiontag:
runs-on: ubuntu-latest
if: github.ref != 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Check version tag
run: |
curl -f https://raw.githubusercontent.com/pvarki/docker-rasenmaeher-integration/main/version.yml -o /tmp/main_version.yml || touch /tmp/main_version.yml
diff /tmp/main_version.yml ./version.yml && exit 1 || exit 0
apiunits:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
checks: write
strategy:
matrix:
python-version: ["3.11"] # , "3.12"]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
cd api && poetry install
- name: Prep docker
run: |
rm -rf api/tests/data/cfssl/*
rm -rf api/tests/data/ca_public/*
docker system prune --all --volumes --force
cd api/tests && docker compose -f docker-compose.yml build --pull
docker compose -f docker-compose.yml pull --ignore-buildable
docker compose -f docker-compose.yml up -d --wait || docker compose -f docker-compose.yml logs
docker compose -f docker-compose.yml down -v
- name: Test with pytest
run: |
cd api && poetry run py.test -v --junitxml=pytest-apiunit.xml tests/
- name: Publish Test Report
uses: mikepenz/action-junit-report@v4
if: success() || failure() # always run even if the previous step fails
with:
report_paths: 'api/pytest*.xml'
detailed_summary: true
check_name: 'api unit tests'
rmlocal:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
checks: write
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: install dependencies
id: install_dependencies
run: |
python -m pip install --upgrade pip
pip install -r tests/requirements.txt
- name: pre-commit
id: pre_commit
run: |
export SKIP=no-commit-to-branch
source example_env.sh
pre-commit run --all-files
- name: docker compose build
id: compose_build
run: |
shopt -s expand_aliases
alias dcloc="docker compose -p rmlocal -f docker-compose-local.yml"
docker system prune --all --volumes --force
dcloc build --pull
dcloc pull --ignore-buildable
- name: docker compose cleanup
id: compose_clean_1
run: |
shopt -s expand_aliases
alias dcloc="docker compose -p rmlocal -f docker-compose-local.yml"
alias dcdev="docker compose -p rmdev -f docker-compose-local.yml -f docker-compose-dev.yml"
dcloc down -v || true
dcdev down -v || true
- name: docker compose up first attempt
id: compose_up_first
run: |
shopt -s expand_aliases
alias dcloc="docker compose -p rmlocal -f docker-compose-local.yml"
dcloc up --wait || (dcloc logs && exit 1)
continue-on-error: true
- name: docker compose up second attempt
if: ${{ steps.compose_up_first.outcome == 'failure' }}
id: compose_up_second
run: |
shopt -s expand_aliases
alias dcloc="docker compose -p rmlocal -f docker-compose-local.yml"
dcloc up --wait || (dcloc logs && exit 1)
continue-on-error: true
- name: add test users
id: add_test_users
run: |
docker ps
docker exec rmlocal-rmapi-1 rasenmaeher_api addtestusers
docker exec rmlocal-rmapi-1 cat /etc/hosts
- name: Test with pytest
id: run_pytest
run: |
shopt -s expand_aliases
alias dcloc="docker compose -p rmlocal -f docker-compose-local.yml"
py.test -v --junitxml=pytest-rmlocal.xml tests/ || (dcloc logs && exit 1)
- name: Publish Test Report
uses: mikepenz/action-junit-report@v4
if: success() || failure() # always run even if the previous step fails
with:
report_paths: '**/pytest*.xml'
detailed_summary: true
include_passed: true
check_name: 'rmlocal integration tests'
- name: docker compose cleanup
id: compose_clean_2
if: ${{ !cancelled() }}
run: |
shopt -s expand_aliases
alias dcloc="docker compose -p rmlocal -f docker-compose-local.yml"
dcloc down -v || true
rmdev:
if: false
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
checks: write
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: install dependencies
id: install_dependencies
run: |
python -m pip install --upgrade pip
pip install -r tests/requirements.txt
- name: pre-commit
id: pre_commit
run: |
export SKIP=no-commit-to-branch
source example_env.sh
pre-commit run --all-files
- name: docker compose build
id: compose_build
run: |
shopt -s expand_aliases
alias dcdev="docker compose -p rmdev -f docker-compose-local.yml -f docker-compose-dev.yml"
docker system prune --all --volumes --force
dcdev build --pull
dcdev pull --ignore-buildable
- name: docker compose cleanup
id: compose_clean_1
run: |
shopt -s expand_aliases
alias dcdev="docker compose -p rmdev -f docker-compose-local.yml -f docker-compose-dev.yml"
alias dcloc="docker compose -p rmlocal -f docker-compose-local.yml"
dcdev down -v || true
dcloc down -v || true
- name: docker compose up first attempt
id: compose_up_first
run: |
shopt -s expand_aliases
alias dcdev="docker compose -p rmdev -f docker-compose-local.yml -f docker-compose-dev.yml"
dcdev up --wait || ( dcdev logs && exit 1 )
continue-on-error: true
- name: docker compose up second attempt
if: ${{ steps.compose_up_first.outcome == 'failure' }}
id: compose_up_second
run: |
shopt -s expand_aliases
alias dcdev="docker compose -p rmdev -f docker-compose-local.yml -f docker-compose-dev.yml"
dcdev up --wait || ( dcdev logs && exit 1 )
continue-on-error: true
- name: add test users
id: add_test_users
run: |
docker ps
docker exec rmdev-rmapi-1 /.venv/bin/rasenmaeher_api addtestusers
- name: Test with pytest
id: run_pytest
run: |
shopt -s expand_aliases
alias dcdev="docker compose -p rmdev -f docker-compose-local.yml -f docker-compose-dev.yml"
py.test -v --junitxml=pytest-rmdev.xml tests/ || ( dcdev logs && exit 1 )
- name: Publish Test Report
uses: mikepenz/action-junit-report@v4
if: success() || failure() # always run even if the previous step fails
with:
report_paths: '**/pytest*.xml'
detailed_summary: true
include_passed: true
check_name: 'rmdev integration tests'
- name: docker compose cleanup
id: compose_clean_2
if: ${{ !cancelled() }}
run: |
shopt -s expand_aliases
alias dcdev="docker compose -p rmdev -f docker-compose-local.yml -f docker-compose-dev.yml"
dcdev down -v || true
build_and_publish:
runs-on: ubuntu-latest
needs: [apiunits, rmlocal]
strategy:
matrix:
extra_env: ["none", "date"]
asset_set: ["neutral", "fdf"]
steps:
- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Fix ref slashes
run: |
echo REF_NO_SLASHES=$(echo "${{ github.ref_name }}" | sed 's/\//-/g') >> ${GITHUB_ENV}
- name: Set VITE_ASSET_SET
run: |
echo "VITE_ASSET_SET=${{ matrix.asset_set }}" >> ${GITHUB_ENV}
cat ${GITHUB_ENV}
- name: Set DOCKER_TAG_EXTRA if date
run: |
test "${{ matrix.extra_env }}" = "date" && echo "DOCKER_TAG_EXTRA=-$(date +%Y%m%d)" >> ${GITHUB_ENV} || true
cat ${GITHUB_ENV}
- name: Set DOCKER_TAG_EXTRA if not main
if: github.event.pull_request.merged != true
run: |
test "${{ github.ref }}" = "refs/heads/main" || echo "DOCKER_TAG_EXTRA=-$REF_NO_SLASHES" >> ${GITHUB_ENV}
cat ${GITHUB_ENV}
- name: Build takinit
run: |
source example_env.sh
docker compose build takinit
- name: push takinit
if: ${{ !env.ACT }}
run: |
source example_env.sh
docker compose push takinit
- name: Build main composition
run: |
source example_env.sh
docker compose build
- name: Push main composition
if: ${{ !env.ACT }}
run: |
source example_env.sh
docker compose push