Skip to content

Commit 85fccc7

Browse files
authored
Merge pull request #102 from boesing/feature/gatekeeper-commands
Introduce `before_script` which will be executed prior the command
2 parents cfc3bb0 + 49e20d6 commit 85fccc7

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

README.md

Lines changed: 8 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+
"before_script": [
44+
"tool configuration linting",
45+
"tool specific setting overrides",
46+
"specific composer dependency to be installed prior executing command"
4247
]
4348
}
4449
```
@@ -113,6 +118,8 @@ The `.laminas-ci/pre-run.sh` command runs immediately prior to the QA command, a
113118
- `$2`: the WORKDIR path
114119
- `$3`: the `$JOB` passed to the entrypoint (see above)
115120

121+
It is also possible to pass `before_script` with a list of commands via the `$JOB` variable.
122+
116123
The `.laminas-ci/post-run.sh` command will receive these arguments:
117124

118125
- `$1`: the exit status of the QA command
@@ -219,6 +226,7 @@ The container the action provides and consumes builds off the ubuntu:focal image
219226
- 7.3
220227
- 7.4
221228
- 8.0
229+
- 8.1
222230

223231
Each provides the following extensions by default:
224232

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 " - before_script: a list of commands to run before the real command"
1719
echo ""
1820
}
1921

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

143+
declare -a BEFORE_SCRIPT=()
144+
readarray -t BEFORE_SCRIPT="$(echo "${JOB}" | jq -rc '(.before_script // [])[]' )"
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+
for BEFORE_SCRIPT_COMMAND in "${BEFORE_SCRIPT[@]}"; do
225+
echo "Running before_script: ${BEFORE_SCRIPT_COMMAND}"
226+
sudo --preserve-env --set-home -u testuser /bin/bash -c "${BEFORE_SCRIPT_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)