-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
103 lines (101 loc) · 5.05 KB
/
action.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
# This is the definition of a custom GitHub Action, allowing super-easy usage of this tool in GitHub workflows
name: 'eZPlatform Ultimate Test Stack'
description: 'Sets up the desired eZPlatform version and runs tests'
inputs:
configuration-file:
description: 'Path to the configuration file which defines the test environment to set up. Required when not defining env vars'
required: true
default: ''
run-on:
description: 'Whether to use Docker Containers or run tests on the runner VM. Values: host, containers. When using containers, you have to leave the DB_HOST env var empty or set it to `mysql`'
required: true
default: 'host'
test-command:
description: "The command used to run the test suite. If left empty, it defaults to the teststack's `runtests`"
required: true
default: ''
code-coverage-service:
description: "Whether to generate and upload code coverage to 3rd party services. Supported: scrutinizer, codecov"
required: true
default: ''
repo-token:
description: "GitHub access token. Used to avoid API rate limiting when downloading composer dependencies. Set it to `$ { { secrets.GITHUB_TOKEN } }`"
required: true
default: ''
runs:
using: "composite"
steps:
-
run: |
if [ -z "${{ inputs.configuration-file }}" ]; then
if [ -z "${EZ_PACKAGES}" ]; then
echo "Warning: no configuration file is used, and no packages are defined in the EZ_PACKAGES env var"
fi
elif [ -f "${{ github.workspace }}/${{ inputs.configuration-file }}" ]; then
set -a && . "${{ github.workspace }}/${{ inputs.configuration-file }}" && set +a
elif [ -f "${{ inputs.configuration-file }}" ]; then
set -a && . "${{ inputs.configuration-file }}" && set +a
else
echo "Error: the configuration file '${{ inputs.configuration-file }}' was not found"
exit 1
fi
if [ -n "${{ inputs.repo-token }}" ]; then
export GITHUB_TOKEN="${{ inputs.repo-token }}"
fi
"${{ github.action_path }}/bin/setup.sh"
if [ -z "${{ inputs.test-command }}" ]; then
if [ -z "${{ inputs.upload-code-coverage }}" ]; then
"${{ github.action_path }}/bin/runtests.sh"
else
"${{ github.action_path }}/bin/runtests.sh" -u "${{ inputs.upload-code-coverage }}"
fi
else
# @todo should we check if test-command is a relative path to a script? what if it has double quotes in it instead?
# @todo add support for code-coverage
${{ inputs.test-command }}
if [ -n "${{ inputs.upload-code-coverage }}" ]; then
echo "Warning: option upload-code-coverage not supported together with test-command"
fi
fi
shell: bash
if: ${{ inputs.run-on == 'host' }}
-
run: |
if [ -z "{{ inputs.configuration-file }}" ]; then
if [ -z "${EZ_PACKAGES}" ]; then
echo "Warning: no configuration file is used, and no packages are defined in the EZ_PACKAGES env var"
fi
elif [ -f "${{ github.workspace }}/${{ inputs.configuration-file }}" ]; then
export TESTSTACK_CONFIG_FILE="${{ github.workspace }}/${{ inputs.configuration-file }}"
elif [ -f "${{ inputs.configuration-file }}" ]; then
export TESTSTACK_CONFIG_FILE="${{ inputs.configuration-file }}"
else
echo "Error: the configuration file was not found"
exit 1
fi
if [ -n "${{ inputs.repo-token }}" ]; then
export GITHUB_TOKEN="${{ inputs.repo-token }}"
fi
"${{ github.action_path }}/teststack" setup
if [ -z "${{ inputs.test-command }}" ]; then
if [ -z "${{ inputs.upload-code-coverage }}" ]; then
"${{ github.action_path }}/teststack" runtests
else
"${{ github.action_path }}/teststack" -o "${{ inputs.upload-code-coverage }}" runtests
fi
else
# @todo should we check if test-command is a relative path to a script? what if it has double quotes in it instead?
# @todo add support for code-coverage
"${{ github.action_path }}/teststack" exec ${{ inputs.test-command }}
if [ -n "${{ inputs.upload-code-coverage }}" ]; then
echo "Warning: option upload-code-coverage not supported together with test-command"
fi
fi
shell: bash
if: ${{ inputs.run-on == 'containers' }}
-
run: |
echo "Error: unsupported value '${{ inputs.run-on }}' for `run-on` input"
exit 1
shell: bash
if: ${{ inputs.run-on != 'containers' && inputs.run-on != 'host' }}