Repository navigation
Expand file tree
/
Copy pathaction.yaml
More file actions
160 lines (142 loc) · 5.18 KB
/
Copy pathaction.yaml
File metadata and controls
160 lines (142 loc) · 5.18 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
name: "DDEV add-on test"
author: "Julien Loizelet"
description: "A Github Action to run DDEV add-on tests"
inputs:
ddev_version:
required: false
default: "stable"
description: "DDEV version to use: stable, HEAD, tag:<version> or pr:<number>"
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: "./"
debug_enabled:
type: boolean
description: "Enable remote debugging session"
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@23156a3d9674d7f52f74f1a58979ec4d77847166 # https://github.com/Homebrew/actions/commits/main/setup-homebrew/
- name: Environment setup
shell: bash
run: |
brew trust bats-core/bats-core
# Hide Homebrew's Landlock ABI 10 warning, remove once Ubuntu runners have Linux 7.2+
brew install bats-core bats-core/bats-core/bats-assert bats-core/bats-core/bats-file bats-core/bats-core/bats-support jq mkcert yq >/dev/null 2> >(grep -vF 'or later is required to deny all network access' >&2)
mkcert -install
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # https://github.com/actions/checkout/commits/v7.0.1/
if: inputs.disable_checkout_action == 'false'
with:
repository: ${{ inputs.addon_repository }}
ref: ${{ inputs.addon_ref }}
path: ${{ inputs.addon_path }}
- name: Install ddev stable
shell: bash
run: |
brew trust ddev/ddev
brew install ddev/ddev/ddev >/dev/null 2> >(grep -vF 'or later is required to deny all network access' >&2)
- name: Use ddev ${{ inputs.ddev_version }}
shell: bash
if: inputs.ddev_version != 'stable' && inputs.ddev_version != ''
env:
DDEV_VERSION: ${{ inputs.ddev_version }}
# Allow the download to use a GitHub token to prevent rate limiting
DDEV_GITHUB_TOKEN: ${{ inputs.token }}
run: |
case "${DDEV_VERSION}" in
HEAD | head)
source_args=(--head)
;;
tag:?*)
source_args=(--tag "${DDEV_VERSION#tag:}")
;;
pr:?*)
source_args=(--pr "${DDEV_VERSION#pr:}")
;;
*)
echo "::error::Unknown ddev_version '${DDEV_VERSION}', use stable, HEAD, tag:<version> or pr:<number>"
exit 1
;;
esac
ddev_bin_dir="${RUNNER_TEMP}/ddev-bin"
if ddev utility download-ddev "${source_args[@]}" --output "${ddev_bin_dir}"; then
# Prepend to PATH, ddev finds ddev-hostname there too
echo "${ddev_bin_dir}" >> "${GITHUB_PATH}"
elif [ "${source_args[0]}" = "--head" ]; then
echo "::warning::Could not download the main build, building it with Homebrew instead"
brew unlink ddev >/dev/null
brew install --HEAD ddev/ddev/ddev >/dev/null 2> >(grep -vF 'or later is required to deny all network access' >&2)
else
exit 1
fi
- name: Show ddev version
shell: bash
run: ddev version
- name: Download docker images
shell: bash
run: |
if ddev utility --help >/dev/null 2>&1; then
ddev utility download-images >/dev/null
else
ddev debug download-images >/dev/null
fi
- name: Setup upterm session
uses: owenthereal/action-upterm@42902ffb5244d6d63501c1daf4f4ec82884025f6 # https://github.com/owenthereal/action-upterm/commits/v1.16.0/
with:
limit-access-to-actor: true
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
branding:
icon: "code"
color: "blue"