-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
action.yaml
141 lines (121 loc) · 3.82 KB
/
action.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
name: "DDEV add-on test"
author: "Julien Loizelet"
description: "A Github Action to run DDEV add-on tests"
inputs:
ddev_version:
type: choice
required: false
default: "stable"
description: "DDEV Version to use"
options:
- "stable"
- "HEAD"
addon_repository:
description: "Repository of the tested addon"
required: true
addon_ref:
description: "Repository ref of the tested addon"
required: true
addon_path:
description: "Path to clone the addon"
required: false
default: "./"
keepalive:
type: boolean
description: "Keeps GitHub from turning off tests after 60 days"
required: false
default: true
keepalive_time_elapsed:
description: "Time elapsed from the most recent commit to hit API and prevent expiration (in days)"
required: false
default: "0"
debug_enabled:
type: boolean
description: "Debug with tmate"
required: false
default: false
disable_checkout_action:
type: boolean
description: "Disable addon checkout action"
required: false
default: false
token:
description: "A Github PAT"
required: true
test_command:
description: "Test command to run"
required: false
default: ""
runs:
using: "composite"
steps:
- uses: Homebrew/actions/setup-homebrew@master
- name: Environment setup
shell: bash
run: |
# For bats-assert and friends
brew tap kaos/shell >/dev/null
brew install bats-core bats-file bats-assert bats-support jq mkcert yq >/dev/null
mkcert -install
- uses: actions/checkout@v4
if: inputs.disable_checkout_action == 'false'
with:
repository: ${{ inputs.addon_repository }}
ref: ${{ inputs.addon_ref }}
path: ${{ inputs.addon_path }}
- name: Use ddev stable
shell: bash
if: inputs.ddev_version == 'stable'
run: brew install ddev/ddev/ddev >/dev/null
- name: Use ddev HEAD
shell: bash
if: inputs.ddev_version == 'HEAD'
run: brew install --HEAD ddev/ddev/ddev >/dev/null
- name: Download docker images
shell: bash
run: ddev debug download-images >/dev/null
- uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: true
github-token: ${{ inputs.token }}
if: inputs.debug_enabled == 'true'
- name: Run test
env:
# Allow ddev get to use a GitHub token to prevent rate limiting by tests
DDEV_GITHUB_TOKEN: ${{ inputs.token }}
# Don't try interactive behaviors
DDEV_NONINTERACTIVE: "true"
# Don't send telemetry to amplitude
DDEV_NO_INSTRUMENTATION: "true"
# Use test_command input if provided
TEST_COMMAND_INPUT: ${{ inputs.test_command }}
# Use the addon path
ADDON_PATH: ${{ inputs.addon_path }}
# Use the event name
GITHUB_EVENT_NAME: ${{ github.event_name }}
shell: bash
# Use of "set +H" to ensure that bash history expansion is disabled so that ! can be used in test command
run: |
set +H
if [ -n "$TEST_COMMAND_INPUT" ]; then
TEST_COMMAND="$TEST_COMMAND_INPUT"
else
case "$GITHUB_EVENT_NAME" in
"push"|"pull_request")
TEST_COMMAND="bats tests --filter-tags !release"
;;
*)
TEST_COMMAND="bats tests"
;;
esac
fi
echo "Running: $TEST_COMMAND in $ADDON_PATH"
cd $ADDON_PATH && $TEST_COMMAND
# keepalive-workflow keeps GitHub from turning off tests after 60 days
- uses: gautamkrishnar/keepalive-workflow@v2
if: always() && matrix.ddev_version == 'stable' && inputs.keepalive == 'true' && github.event_name == 'schedule'
with:
time_elapsed: ${{ inputs.keepalive_time_elapsed }}
branding:
icon: "code"
color: "blue"