-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yaml
More file actions
410 lines (391 loc) · 14.7 KB
/
action.yaml
File metadata and controls
410 lines (391 loc) · 14.7 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
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
name: 'prepare_shop'
description: 'Prepares the shop and creates a cache for it'
inputs:
container_name:
type: string
required: false
description: 'Name of the container running php'
default: 'php'
container_options:
type: string
required: false
description: 'Additional options when running something in the the container'
default: ''
container_method:
type: string
required: false
description: 'Method to execute the commands inside a container, either "run" or "exec"'
default: 'exec'
git_sdk_repository:
type: string
required: false
description: 'Organisation/Repository for the docker-eshop sdk'
default: 'OXID-eSales/docker-eshop-sdk'
git_sdk_ref:
type: string
required: false
description: 'Branch, tag or hash of the commit to check out'
default: 'master'
compilation_url:
type: string
required: false
description: 'URL for downloading a basic composer.json template'
default: ''
git_repository:
type: string
required: false
description: 'Organisation/Repository containing the root composer.json if not using compilation_url'
default: 'OXID-eSales/oxideshop_ce'
git_ref:
type: string
required: false
description: 'Branch, tag or hash of the commit to check out'
default: ''
github_event_name:
type: string
required: false
description: 'Name of the github event (github.event_name), used to handle pull requests'
default: ''
github_event_number:
type: string
required: false
description: 'Number of the github event (github.event_number), used to handle pull requests'
default: '0'
github_base_ref:
type: string
required: false
description: 'Base reference (github.base_ref) for testing the github pull request'
default: ''
github_sha:
type: string
required: false
description: 'github.sha is used in generating the cache id'
default: ''
github_run_number:
type: string
required: false
description: 'github.run_number and github.run_attempts are used in generating the cache id'
default: '0'
github_run_attempt:
type: string
required: false
description: 'github.run_number and github.run_attempts are used in generating the cache id'
default: '0'
github_ref_name:
type: string
required: false
description: 'Current branch (github.ref_name) for modifying composer.json'
default: ''
php:
type: string
required: false
description: 'Version of PHP for this instance'
default: '8.2'
mysql:
type: string
required: false
description: 'Version of MySQL for this instance'
default: 'mysql-8.0.36'
custom_ini_error_reporting:
type: string
required: false
description: 'Error reporting settings for php custom.ini'
default: 'E_ALL & ~E_DEPRECATED & ~E_NOTICE & ~E_WARNING'
custom_ini_xdebug:
type: string
required: false
description: 'xdebug settings for php custom.ini'
default: 'xdebug.max_nesting_level=1000'
add_services:
type: string
required: false
description: 'Space separated list of extra services to add'
default: 'selenium-chrome'
composer_file:
type: string
required: false
description: 'Name of the original composer.json'
default: 'source/composer.json'
composer_transform:
type: string
required: false
description: 'JSON code to merge into composer.json'
default: ''
composer_backup:
type: boolean
required: false
description: 'Should we create a backup for composer.json'
default: true
composer_update:
type: boolean
required: false
description: 'Run composer update after transform'
default: true
composer_update_options:
type: string
required: false
description: 'Options to pass along to composer during install'
default: '--no-interaction'
composer_dev_ref:
type: string
required: false
description: 'Development package reference'
default: 'dev-b-8.0.x'
enterprise_github_token:
type: string
required: false
description: 'OAuth token to access enterprise repos'
default: ''
composer_version:
type: string
required: false
description: 'Composer version (e.g., 2.8.12). Empty = use docker image default'
default: ''
docker_login:
type: boolean
required: false
description: 'should we log in to docker'
default: true
docker_user:
type: string
required: false
description: 'secrets.DOCKER_HUB_USER for docker login'
default: ''
docker_token:
type: string
required: false
description: 'secrets.DOCKER_HUB_TOKEN for docker login'
default: ''
copy_script_targets:
type: string
description: 'Copy the test scripts to these target folders'
default: 'tests/scripts'
required: false
debug:
type: string
description: 'Appended to debugging scripts'
default: ''
required: false
runs:
using: "composite"
steps:
- name: 'Clone testing environment master'
if: ${{ inputs.git_sdk_repository != '' }}
shell: bash
run: |
# prepare_shop: Clone testing environment master
REF='${{ inputs.git_sdk_ref }}'
git init
git config advice.detachedHead false
git remote add origin https://github.com/${{ inputs.git_sdk_repository }}.git
git -c protocol.version=2 fetch \
--no-tags --prune --no-recurse-submodules \
--filter=blob:none --depth=1 \
origin +refs/heads/${{ inputs.git_sdk_ref }}*:refs/remotes/origin/${REF}* +refs/tags/${REF}*:refs/tags/${REF}*
BRANCH=$(git branch --list --remote origin/${REF};git tag --list ${REF})
git checkout --progress --force $(echo $BRANCH|head -1)
${{ inputs.debug }}
- name: 'Fetch the compilation composer.json'
if: ${{ inputs.compilation_url != '' }}
shell: bash
run: |
# prepare_shop: Fetch the compilation composer.json
${{ inputs.debug }}
mkdir -p source
curl -sSjkLo source/composer.json \
-H "Authorization: Bearer ${{ inputs.enterprise_github_token }}" \
-H 'Accept: application/vnd.github.raw+json' \
'${{ inputs.compilation_url }}'
- name: 'Clone ${{ inputs.git_repository }} (${{ inputs.git_ref }})'
if: ${{ inputs.compilation_url == '' && inputs.github_event_name != 'pull_request' }}
shell: bash
run: |
# prepare_shop: Clone ${{ inputs.git_repository }} (${{ inputs.git_ref }})
${{ inputs.debug }}
if [ -n "${{ inputs.enterprise_github_token }}" ]; then
URL="https://oxidci:${{ inputs.enterprise_github_token }}@github.com/${{ inputs.git_repository }}.git"
else
URL="https://github.com/${{ inputs.git_repository }}.git"
fi
REF='${{ inputs.git_ref }}'
echo -e "\033[0;35m### Cloning ${REF} ###\033[0m"
git clone --depth 2 "${URL}" --branch "${REF}" --single-branch source
- name: 'PR-Clone ${{ inputs.git_repository }} (${{ inputs.git_ref }})'
if: ${{ inputs.compilation_url == '' && inputs.github_event_name == 'pull_request' }}
shell: bash
run: |
# prepare_shop: PR-Clone ${{ inputs.git_repository }} (${{ inputs.git_ref }})
${{ inputs.debug }}
echo -e "\033[0;35mHandling the pull request\033[0m"
if [ -n "${{ inputs.enterprise_github_token }}" ]; then
URL="https://oxidci:${{ inputs.enterprise_github_token }}@github.com/${{ inputs.git_repository }}.git"
else
URL="https://github.com/${{ inputs.git_repository }}.git"
fi
echo -e "\033[0;35m### Cloning ${{ inputs.github_base_ref }} and merging head:pr_${{ inputs.github_event_number }} ###\033[0m"
git clone --depth 2 "${URL}" --branch ${{ inputs.github_base_ref }} --single-branch source
git -C source fetch origin refs/pull/${{ inputs.github_event_number }}/head:pr_${{ inputs.github_event_number }}
git -C source checkout pr_${{ inputs.github_event_number }}
- name: 'Prepare container configuration'
shell: bash
run: |
# prepare_shop: Prepare container configuration
${{ inputs.debug }}
make setup
make addbasicservices
if [ -n "${{ inputs.add_services }}" ]; then
for SERVICE in ${{ inputs.add_services }}; do
echo -e "\033[0;35mAdding service ${SERVICE}\033[0m"
if [ "${SERVICE}" == "nginx-rp" ]; then
perl -pi\
-e 's#- 80:80#- 8000:80#g;'\
-e 's#apache:localhost.local#nginx:localhost.local#g;'\
docker-compose.yml
fi
make file=services/${SERVICE}.yml addservice
done
fi
perl -pi\
-e "s#PHP_VERSION=.*#PHP_VERSION='${{ inputs.php }}'#g;"\
-e "s#MYSQL_VERSION=.*#MYSQL_VERSION='${{ inputs.mysql }}'#g;"\
.env
perl -pi\
-e 's#display_errors =.*#display_errors = false#g;'\
-e 'print "${{ inputs.custom_ini_xdebug }}\n\n";'\
-e 'print "error_reporting = ${{ inputs.custom_ini_error_reporting }}\n"'\
containers/php/custom.ini
perl -pi\
-e 's#/var/www/#/var/www/source/#g;'\
containers/httpd/project.conf
- name: 'Login to Docker Hub'
if: ${{ inputs.docker_login == 'true' && inputs.docker_user != '' }}
uses: 'docker/login-action@v3'
with:
username: ${{ inputs.docker_user }}
password: ${{ inputs.docker_token }}
- name: 'Warn on missing docker credentials'
if: ${{ inputs.docker_login == 'true' && inputs.docker_user == '' }}
shell: bash
run: |
# prepare_shop: Warn on missing docker credentials
MSG="Please set the repository secrets DOCKER_HUB_USER and DOCKER_HUB_TOKEN to avoid running into docker.io rate limiting"
echo "::warning title=Missing secrets::${MSG}"
- name: 'Start containers'
id: start
shell: bash
run: |
# prepare_shop: Start containers
${{ inputs.debug }}
make up
docker compose ps --all
- name: 'Output docker logs if make up failed'
if: ${{ always() && steps.start.outcome != 'success' }}
shell: bash
run: |
# prepare_shop: Output docker logs if make up failed
echo -e "\033[0;35m### docker-compose.yml ###\033[0m"
cat docker-compose.yml
echo -e "\033[0;35m### docker compose logs ###\033[0m"
docker compose logs --tail=all
for c in $(docker ps -aq); do
echo -e "\033[0;35m### Logs for $c ###\033[0m"
docker logs -n 200 $c
done
- name: 'Configure enterprise token'
if: ${{ inputs.enterprise_github_token != '' }}
shell: bash
run: |
# prepare_shop: Configure enterprise token
${{ inputs.debug }}
docker compose ${{ inputs.container_method }} -T \
${{ inputs.container_options }} \
${{ inputs.container_name}} \
composer config -g github-oauth.github.com "${{ inputs.enterprise_github_token }}"
- name: 'Set Composer version'
if: ${{ inputs.composer_version != '' }}
shell: bash
run: |
# prepare_shop: Set Composer version
${{ inputs.debug }}
echo -e "\033[0;35mSetting Composer to version ${{ inputs.composer_version }}\033[0m"
docker compose ${{ inputs.container_method }} -T \
-u root \
${{ inputs.container_options }} \
${{ inputs.container_name }} \
composer self-update ${{ inputs.composer_version }}
- name: 'Modify composer.json'
if: ${{ inputs.composer_transform != '' }}
uses: 'OXID-eSales/github-actions/composer_merge@v5'
with:
file: '${{ inputs.composer_file }}'
backup: true
transform: |
${{ inputs.composer_transform }}
update: false
update_options: ${{ inputs.composer_update_options }}
container_name: ${{ inputs.container_name }}
container_options: ${{ inputs.container_options }}
container_method: 'exec'
debug: ${{ inputs.debug }}
# yamllint disable rule:line-length
- name: 'Modify composer.json to allow the same feature-branch'
if: ${{ inputs.github_event_name != 'pull_request' }}
shell: bash
run: |
# prepare_shop: Modify composer.json to allow the same feature-branch
${{ inputs.debug }}
if [ -f '${{ inputs.composer_file }}' ]; then
BASE_BRANCH_PATTERN='^b-[0-9]+\.[0-9]+\.x$'
if [[ '${{ inputs.github_ref_name }}' =~ $BASE_BRANCH_PATTERN ]]; then
echo -e "\033[0;35mNot modifying composer.json because ${{ inputs.github_ref_name }} is a base branch\033[0m"
else
echo -e "\033[0;35mAllow dev-${{ inputs.github_ref_name }} for oxid-esales requires\033[0m"
sed -e 's#"oxid-esales/\(.*\)":[[:space:]]*"${{ inputs.composer_dev_ref }}"#"oxid-esales/\1": "dev-${{ inputs.github_ref_name }} || ${{ inputs.composer_dev_ref }}"#' \
-i.backup '${{ inputs.composer_file }}'
fi
fi
# yamllint enable rule:line-length
- name: 'Install dependencies'
shell: bash
if: ${{ inputs.composer_update == 'true' }}
run: |
# prepare_shop: Install dependencies
${{ inputs.debug }}
docker compose ${{ inputs.container_method }} -T \
${{ inputs.container_options }} \
${{ inputs.container_name }} \
composer update --no-interaction
- name: 'Setup config inc file'
shell: bash
run: |
# prepare_shop: Setup config inc file
${{ inputs.debug }}
if [ -f source/source/config.inc.php.dist ]; then
cp source/source/config.inc.php.dist source/source/config.inc.php
fi
if [ -f source/vendor/oxid-esales/oxideshop-ce/source/config.inc.php.dist ]; then
cp source/vendor/oxid-esales/oxideshop-ce/source/config.inc.php.dist source/vendor/oxid-esales/oxideshop-ce/source/config.inc.php
fi
- name: 'Copy test scripts'
if: ${{ inputs.copy_script_targets != '' }}
shell: bash
run: |
# prepare_shop: Copy tests scripts
${{ inputs.debug }}
cat >targets.tmp <<EOF
${{ inputs.copy_script_targets }}
EOF
sed -e 's|(.*)\r|$1|' -i.backup targets.tmp
while read -r TARGET ; do
mkdir -p "source/${TARGET}"
for FILE in $(find .github/oxid-esales/defaults/scripts -iname "*.sh" -o -iname "*.txt"); do
BASE=$(basename "${FILE}")
if [ -f "source/${TARGET}/${BASE}" ]; then
echo "File 'source/${TARGET}/${BASE}' already exists, skipping copy"
else
echo "Copying default file '${FILE}' to 'source/${TARGET}'"
cp -a "${FILE}" "source/${TARGET}/${BASE}"
fi
done
done <targets.tmp
rm targets.tmp