Skip to content

Commit

Permalink
[TASK] runTests.sh: Don't mount home, passwd, group
Browse files Browse the repository at this point in the history
The patch changes runTests.sh and the container
definition to avoid mounting users home, /etc/passwd
and /etc/group. yarn based setups need some special
treatment but in the end bow to shell power, too.

Change-Id: I4e5665d31c5bef4e046e992eddd534ae597cce31
Resolves: #96253
Releases: main, 11.5, 10.4
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72517
Tested-by: core-ci <typo3@b13.com>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
  • Loading branch information
lolli42 committed Dec 6, 2021
1 parent 923f84e commit 21692a3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 147 deletions.
18 changes: 0 additions & 18 deletions Build/Scripts/runTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ setUpDockerComposeDotEnv() {
# use $UID directly itself since it is a shell variable and not an env variable, so
# we have to set it explicitly here.
echo "HOST_UID=$(id -u)"
# Your local home directory for composer and npm caching
echo "HOST_HOME=${HOME}"
# Your local user
echo "CORE_ROOT=${CORE_ROOT}"
echo "HOST_USER=${USER}"
Expand All @@ -38,7 +36,6 @@ setUpDockerComposeDotEnv() {
echo "PHP_VERSION=${PHP_VERSION}"
echo "CHUNKS=${CHUNKS}"
echo "THISCHUNK=${THISCHUNK}"
echo "PASSWD_PATH=${PASSWD_PATH}"
} > .env
}

Expand Down Expand Up @@ -309,7 +306,6 @@ MYSQL_VERSION="5.5"
POSTGRES_VERSION="10"
CHUNKS=0
THISCHUNK=0
PASSWD_PATH=/etc/passwd

# Option parsing
# Reset in case getopts has been used previously in the shell
Expand Down Expand Up @@ -409,20 +405,6 @@ fi
# Move "7.2" to "php72", the latter is the docker container name
DOCKER_PHP_IMAGE=$(echo "php${PHP_VERSION}" | sed -e 's/\.//')

# Some scripts rely on a proper /etc/passwd that includes the user that runs the
# containers, for instance to determine users $HOME. yarn v1 is espcecially picky
# here since it fails if it can't write a .yarnrc file to users home ...
# MacOS in it's endless wisdom however decided that /etc/passwd is a stupid thing
# and does not write an entry for the standard user in it. In turn, stuff like yarn fails.
# As a solution, we detect if the user executing the script is within /etc/passwd
# and volume mount that file within containers. If not, we create a fake passwd file
# and mount that one.
[ -z "${USER}" ] && USER=$(id -u -n)
if [ "$(grep -c "^${USER}:" /etc/passwd)" -ne 1 ]; then
echo "${USER}:x:$(id -u "$USER"):$(id -g "$USER"):$(id -gn "$USER"):${HOME}:/bin/bash" > macos_passwd
PASSWD_PATH="./macos_passwd"
fi

# Set $1 to first mass argument, this is the optional test file or test directory to execute
shift $((OPTIND - 1))
TEST_FILE=${1}
Expand Down
Loading

0 comments on commit 21692a3

Please sign in to comment.