Skip to content

Commit 374b4b0

Browse files
committed
small improvements to the test env setup scripts
1 parent 578abb0 commit 374b4b0

10 files changed

Lines changed: 42 additions & 18 deletions

File tree

tests/ci/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ COPY config/* /root/config/
1010

1111
RUN if [ ! -f /.dockerenv ]; then touch /.dockerenv; fi && \
1212
cd /root/setup && \
13-
./install_packages.sh && \
13+
./install_packages.sh -u && \
1414
./create_user.sh && \
1515
./setup_perl.sh && \
1616
./setup_apache.sh && \

tests/ci/setup/create_user.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ set -e
77
echo "Creating user account..."
88

99
USERNAME="${1:-docker}"
10+
USER_ID=2000
11+
USER_GID=2000
1012

1113
# adduser is not preinstalled on noble
1214
DEBIAN_FRONTEND=noninteractive apt-get install -y \
@@ -18,8 +20,8 @@ if [ -d /home/ubuntu ]; then
1820
rm -rf ubuntu
1921
fi
2022

21-
addgroup --gid 2000 "${USERNAME}"
22-
adduser --system --uid=2000 --gid=2000 --home "/home/${USERNAME}" --shell /bin/bash "${USERNAME}"
23+
addgroup --gid "${USER_GID}" "${USERNAME}"
24+
adduser --system --uid="${USER_ID}" --gid="${USER_GID}" --home "/home/${USERNAME}" --shell /bin/bash "${USERNAME}"
2325
adduser "${USERNAME}" "${USERNAME}"
2426

2527
mkdir -p "/home/${USERNAME}/.ssh"

tests/ci/setup/install_packages.sh

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,35 @@
11
#!/bin/sh
22

3-
# Has to be run as admin
3+
# Has to be run as root
44

55
set -e
66

77
echo "Installing base software packages..."
88

9-
# @todo make updating of preinstalled sw optional, so that f.e. we can have faster builds as part of CI
9+
UPDATE_INSTALLED=false
1010

1111
export DEBIAN_FRONTEND=noninteractive
1212

13+
while getopts ":u" opt
14+
do
15+
case $opt in
16+
u)
17+
UPDATE_INSTALLED=true
18+
;;
19+
\?)
20+
echo "Invalid option: -$OPTARG" >&2
21+
exit 1
22+
;;
23+
esac
24+
done
25+
1326
if [ ! -d /usr/share/man/man1 ]; then mkdir -p /usr/share/man/man1; fi
1427

1528
apt-get update
1629

17-
apt-get upgrade -y
30+
if [ "$UPDATE_INSTALLED" = true ]; then
31+
apt-get upgrade -y
32+
fi
1833

1934
apt-get install -y \
2035
git locales sudo unzip wget

tests/ci/setup/setup_apache.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/bin/sh
22

33
# Install and configure apache2
4-
# Has to be run as admin
5-
# @todo make this work across all ubuntu versions (precise to noble)
4+
# Has to be run as root
5+
# @todo make sure this works across all ubuntu versions (precise to noble)
66

77
echo "Installing and configuring Apache2..."
88

@@ -35,11 +35,11 @@ if [ -f /etc/apache2/sites-available/default-ssl.conf ]; then
3535
rm /etc/apache2/sites-available/default-ssl.conf
3636
fi
3737

38-
# NB: TESTS_ROOT_DIR in /etc/apache2/envvars is reset by entrypoint.sh when running in a local container
39-
# @todo avoid adding these lines if they already exist
38+
# @todo avoid adding these lines if they already exist - rewrite them instead
4039
if [ -n "${GITHUB_ACTIONS}" ]; then
4140
echo "export TESTS_ROOT_DIR=$(pwd)" >> /etc/apache2/envvars
4241
else
42+
# NB: TESTS_ROOT_DIR in /etc/apache2/envvars is reset by entrypoint.sh when running in a local container
4343
echo "export TESTS_ROOT_DIR=/var/www/html" >> /etc/apache2/envvars
4444
fi
4545
echo "export HTTPSERVER=localhost" >> /etc/apache2/envvars

tests/ci/setup/setup_app.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

33
# Install and configure the 'app'
4-
# Has to be run as admin
4+
# Has to be run as root
55

66
set -e
77

tests/ci/setup/setup_composer.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ rm composer-setup.php
2929

3030
###
3131

32-
if [ -f /usr/local/bin/composer.phar -a "$RESULT" = 0 ]; then
32+
if [ -f /usr/local/bin/composer.phar ] && [ "$RESULT" = 0 ]; then
3333
mv /usr/local/bin/composer.phar /usr/local/bin/composer && chmod 755 /usr/local/bin/composer
3434
fi
3535

tests/ci/setup/setup_perl.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Installs php modules necessary to test the Perl file in the extras dir
44

5-
# Has to be run as admin
5+
# Has to be run as root
66

77
# @todo test in the VM env: do we need any ubuntu dev packages ?
88

tests/ci/setup/setup_php.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#!/bin/sh
22

3-
# Has to be run as admin
3+
# Has to be run as root
44

55
# @todo make it optional to install xdebug. It is fe. missing in sury's ppa for Xenial
66
# @todo make it optional to install fpm. It is not needed for the cd workflow
77
# @todo make it optional to disable xdebug ?
88
# @todo set the list of required php extensions in a variable, allow it to be overridden
9-
# @todo allow to force usage of shivammatur/ondrej repos regardless of php version in use
9+
# @todo allow to force usage of shivammatur or ondrej repos regardless of php version in use
1010

1111
set -e
1212

tests/ci/setup/setup_privoxy.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
#!/bin/sh
22

33
# Install and configure privoxy
4-
# Has to be run as admin
4+
# Has to be run as root
55

66
set -e
77

88
echo "Installing privoxy..."
99

1010
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
1111

12-
DEBIAN_FRONTEND=noninteractive apt-get install -y privoxy
12+
export DEBIAN_FRONTEND=noninteractive
13+
14+
apt-get install -y privoxy
1315

1416
cp -f "$SCRIPT_DIR/../config/privoxy" /etc/privoxy/config
1517
service privoxy restart

tests/ci/vm.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

33
# @todo rename: this is not based on a vm. Also, the 'ci' folder should really be called 'env' or 'testenv'...
4-
# @todo support getting the various settings as cli options as well as via env vars?
4+
# @todo support getting the various settings as cli options as well as via env vars (use getopts)
55

66
set -e
77

@@ -317,6 +317,11 @@ case "${ACTION}" in
317317
unlock
318318
;;
319319

320+
-h)
321+
help
322+
exit 0
323+
;;
324+
320325
*)
321326
printf "\n\e[31mERROR:\e[0m unknown action '%s'\n\n" "${ACTION}" >&2
322327
help

0 commit comments

Comments
 (0)