Skip to content

Commit 9c920cc

Browse files
committed
feature: introduce gatekeeper commands which will be executed prior the command
Signed-off-by: Maximilian Bösing <[email protected]>
1 parent c2d713a commit 9c920cc

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ The JSON string should represent an object with the following information:
3939
"command": "command to run to perform the check (empty in case you dont want to excecute any command)",
4040
"additional_composer_arguments": [
4141
"arguments which will be passed to `composer install` or `composer update`, passed as a list or as a list; e.g. --no-scripts"
42+
],
43+
"gatekeeper_commands": [
44+
"tool configuration linting",
45+
"tool specific setting overrides",
46+
"specific composer dependency to be installed prior executing command"
4247
]
4348
}
4449
```

entrypoint.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22

33
set -e
4+
set -o pipefail
45

56
function help {
67
echo "$0 <JSON>"
@@ -14,6 +15,7 @@ function help {
1415
echo " - dependencies: the dependency set to run against (lowest, latest, locked)"
1516
echo " - ignore_php_platform_requirement: flag to enable/disable the PHP platform requirement when executing composer \`install\` or \`update\`"
1617
echo " - additional_composer_arguments: a list of composer arguments to be added when \`install\` or \`update\` is called."
18+
echo " - gatekeeper_commands: a list of commands to run prior the real command"
1719
echo ""
1820
}
1921

@@ -138,6 +140,9 @@ if [[ "${PHP}" == "" ]];then
138140
exit 1
139141
fi
140142

143+
declare -a GATEKEEPER_COMMANDS=()
144+
readarray -t GATEKEEPER_COMMANDS="$(echo "${JOB}" | jq -rc '(.gatekeeper_commands // [])[]' )"
145+
141146
echo "Marking PHP ${PHP} as configured default"
142147
update-alternatives --quiet --set php "/usr/bin/php${PHP}"
143148
update-alternatives --quiet --set php-config "/usr/bin/php-config${PHP}"
@@ -216,6 +221,11 @@ if [ -x ".laminas-ci/pre-run.sh" ];then
216221
./.laminas-ci/pre-run.sh testuser "${PWD}" "${JOB}"
217222
fi
218223

224+
# Execute gatekeeper commands before executing the CI command
225+
for GATEKEEPER_COMMAND in "${GATEKEEPER_COMMANDS[@]}"; do
226+
sudo --preserve-env --set-home -u testuser /bin/bash -c "${GATEKEEPER_COMMAND}"
227+
done
228+
219229
# Disable exit-on-non-zero flag so we can run post-commands
220230
set +e
221231

0 commit comments

Comments
 (0)