Skip to content

Commit f8a24fb

Browse files
committed
✨ putting in place the tests for the installer
1 parent 2932b7e commit f8a24fb

9 files changed

Lines changed: 143 additions & 73 deletions

File tree

.github/workflows/self-test-installation.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,6 @@ jobs:
4949
-e VALET_CONFIG_ENABLE_COLORS=true \
5050
-e RUNNING_IN_DOCKER=true \
5151
-e BRANCH_NAME=${BRANCH_NAME} \
52-
noyacode/minideb-bash5.0 \
53-
./tests.d/self-install/test self test -c
52+
--entrypoint /usr/local/bin/bash-5.0 \
53+
noyacode/valet-tests-slimdeb:latest \
54+
./tests.d/install/test

commands.d/self-test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ function selfTest_runSingleTestSuite() {
412412
# the function test::fail was called
413413
# Can be reproduced by inserting a `test::fail` call in the test script.
414414
fs::readFile "${GLOBAL_TEST_LOG_FILE}"
415-
log::error "The test script ⌜${testScript##*/}⌝ at line ⌜${lineNumber}⌝ failed because an error was explicitly thrown in the test script:"$'\n\n'"${REPLY}"$'\n\n'"test::fail called in ⌜${testScript/#"${GLOBAL_PROGRAM_STARTED_AT_DIRECTORY}/"/}:${lineNumber}⌝."
415+
log::error "The test script ⌜${testScript##*/}⌝ at line ⌜${lineNumber}⌝ failed because an error was explicitly thrown in the test script:"$'\n\n'"${REPLY}"$'\n'"test::fail called in ⌜${testScript/#"${GLOBAL_PROGRAM_STARTED_AT_DIRECTORY}/"/}:${lineNumber}⌝."
416416
log::printCallStack stackToSkip=0 stackToSkipAtEnd=11
417417

418418
elif [[ ${scriptGotError} == "true" ]]; then

tests.d/install/01.install.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
3+
# shellcheck source=../../libraries.d/lib-fs
4+
source fs
5+
6+
# cancel the test suite if not running on windows
7+
if ! command -v docker &>/dev/null; then
8+
test::skipTestSuite "This test suite is only runnable on systems with Docker installed, skipping it."
9+
fi
10+
11+
function main() {
12+
:
13+
}
14+
15+
main
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Test suite install
2+
3+
## Test script 01.install
4+
Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set -Eeu -o pipefail
55
# installation of Valet and its extensions, as well as the update.
66

77
# Run locally from valet directory:
8-
# ./tests.d/self-install/test
8+
# ./tests.d/install/test
99

1010
# We expect this script to run in a Docker container, with curl installed
1111
# and a 'me' user with sudo privileges.
@@ -15,15 +15,15 @@ set -Eeu -o pipefail
1515
function main() {
1616
if [[ -z ${RUNNING_IN_DOCKER:-} ]]; then
1717
# we are running this locally
18-
if command -v docker &> /dev/null; then
18+
if command -v docker &>/dev/null; then
1919
echo "Running the test in a container."
2020
# To build the image:
21-
# - cd tests.d/self-install/docker-valet-test
21+
# - cd tests.d/install/docker-valet-test
2222
# - docker build -t noyacode/minideb-bash5.0 .
2323
# Then to run it:
2424
# - docker run --rm -it -v .:/app -w /app -e RUNNING_IN_DOCKER=true --entrypoint /bin/bash noyacode/minideb-bash5.0
25-
# - ./tests.d/self-install/test
26-
docker run --rm -it -v .:/app -w /app -e RUNNING_IN_DOCKER=true --entrypoint /bin/bash noyacode/minideb-bash5.0 -c -o errexit -o nounset -o pipefail "chmod +x ./tests.d/self-install/test; ./tests.d/self-install/test"
25+
# - ./tests.d/install/test
26+
docker run --rm -it -v .:/app -w /app -e RUNNING_IN_DOCKER=true --entrypoint /bin/bash noyacode/minideb-bash5.0 -c -o errexit -o nounset -o pipefail "chmod +x ./tests.d/install/test; ./tests.d/install/test"
2727
return 0
2828
fi
2929
echo "Need docker to run this test."
@@ -34,8 +34,6 @@ function main() {
3434
BRANCH_NAME="${BRANCH_NAME:-main}"
3535
export BRANCH_NAME
3636

37-
38-
3937
echo "================================================"
4038
echo "Installing Valet: --unattended --use-branch --version ${BRANCH_NAME}."
4139
echo "================================================"
@@ -64,8 +62,6 @@ function main() {
6462

6563
export VALET_VERBOSE=false
6664

67-
68-
6965
echo "================================================"
7066
echo "Install extension: extension-1 using git."
7167
echo "================================================"
@@ -120,9 +116,6 @@ function main() {
120116

121117
echo "yyy" | valet self update
122118

123-
124-
125-
126119
echo "================================================"
127120
echo "Create extension: test-extension1."
128121
echo "================================================"
@@ -138,8 +131,6 @@ function main() {
138131
valet self extend .
139132
popd &>/dev/null
140133

141-
142-
143134
echo "================================================"
144135
echo "Updating Valet: --skip-extensions."
145136
echo "================================================"
@@ -158,7 +149,7 @@ function main() {
158149

159150
echo "Previous version:"
160151
valet --version
161-
echo "0.0.0" > /opt/valet/version
152+
echo "0.0.0" >/opt/valet/version
162153
#echo "y" | valet self update
163154

164155
echo "Latest release version:"
@@ -181,7 +172,6 @@ function main() {
181172
which valet || echo "No valet command found."
182173
[[ -d /opt/valet ]] || echo "Valet directory removed."
183174

184-
185175
echo "================================================"
186176
echo "Installing Valet: --unattended --use-branch --version ${BRANCH_NAME} --installation-directory /valet --no-shim --no-showcase."
187177
echo "================================================"
@@ -194,9 +184,6 @@ function main() {
194184

195185
bash -c 'eval "$(valet self uninstall --script 2>/dev/null)"'
196186

197-
198-
199-
200187
echo "================================================"
201188
echo "Installing Valet as me: --use-branch --version ${BRANCH_NAME}."
202189
echo "================================================"
@@ -223,8 +210,6 @@ function main() {
223210

224211
bash -c 'eval "$(valet self uninstall --script 2>/dev/null)"'
225212

226-
227-
228213
echo "================================================"
229214
echo "Installing Valet: --use-branch --version ${BRANCH_NAME} --unattended --single-user-installation --no-showcase."
230215
echo "================================================"
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
FROM debian:trixie AS bash-builder
2+
3+
SHELL ["/bin/bash", "-o", "errexit", "-o", "nounset", "-o", "pipefail", "-c", "-x"]
4+
5+
ARG STANDARD_PACKAGES="locales ca-certificates curl build-essential wget devscripts"
6+
7+
RUN \
8+
apt-get update; \
9+
apt-get install -qq -y ${STANDARD_PACKAGES};
10+
11+
# build bash 5.0
12+
RUN \
13+
cd /tmp; \
14+
wget http://ftp.gnu.org/gnu/bash/bash-5.0.tar.gz; \
15+
tar xf bash-5.0.tar.gz; \
16+
cd bash-5.0; \
17+
export CFLAGS="-O2 -fpermissive"; \
18+
./configure; \
19+
make; \
20+
unset -v CFLAGS; \
21+
cp ./bash /usr/local/bin/bash-5.0; \
22+
cd /tmp; \
23+
rm -rf /tmp/*
24+
25+
# build bash 5.1
26+
RUN \
27+
cd /tmp; \
28+
wget http://ftp.gnu.org/gnu/bash/bash-5.1.tar.gz; \
29+
tar xf bash-5.1.tar.gz; \
30+
cd bash-5.1; \
31+
export CFLAGS="-g -O2 -Wno-implicit-function-declaration -std=gnu11"; \
32+
./configure; \
33+
make; \
34+
unset -v CFLAGS; \
35+
cp ./bash /usr/local/bin/bash-5.1; \
36+
cd /tmp; \
37+
rm -rf /tmp/*
38+
39+
# build bash 5.2
40+
RUN \
41+
cd /tmp; \
42+
wget http://ftp.gnu.org/gnu/bash/bash-5.2.tar.gz; \
43+
tar xf bash-5.2.tar.gz; \
44+
cd bash-5.2; \
45+
export CFLAGS="-g -O2 -Wno-implicit-function-declaration -std=gnu11"; \
46+
./configure; \
47+
make; \
48+
unset -v CFLAGS; \
49+
cp ./bash /usr/local/bin/bash-5.2; \
50+
cd /tmp; \
51+
rm -rf /tmp/*
52+
53+
# build bash 5.3
54+
RUN \
55+
cd /tmp; \
56+
wget http://ftp.gnu.org/gnu/bash/bash-5.3.tar.gz; \
57+
tar xf bash-5.3.tar.gz; \
58+
cd bash-5.3; \
59+
./configure; \
60+
make; \
61+
cp ./bash /usr/local/bin/bash-5.3; \
62+
cd /tmp; \
63+
rm -rf /tmp/*
64+
65+
RUN \
66+
pushd /tmp; \
67+
curl -fsSL https://github.com/nushell/nushell/releases/download/0.111.0/nu-0.111.0-x86_64-unknown-linux-gnu.tar.gz -o nu.tar.gz; \
68+
tar -xvf nu.tar.gz; \
69+
mv nu-0.111.0-x86_64-unknown-linux-gnu/nu /usr/local/bin/nu; \
70+
curl -fsSL https://github.com/dandavison/delta/releases/download/0.19.1/delta-0.19.1-x86_64-unknown-linux-gnu.tar.gz -O; \
71+
tar -xvf delta-0.19.1-x86_64-unknown-linux-gnu.tar.gz; \
72+
mv delta-0.19.1-x86_64-unknown-linux-gnu/delta /usr/local/bin/delta; \
73+
popd; \
74+
rm -rf /tmp/*
75+
76+
77+
FROM debian:trixie-slim
78+
79+
SHELL ["/bin/bash", "-o", "errexit", "-o", "nounset", "-o", "pipefail", "-c", "-x"]
80+
81+
ARG STANDARD_PACKAGES="locales ca-certificates curl git xonsh fish zsh csh tcsh ksh wget"
82+
83+
COPY --from=bash-builder /usr/local/bin /usr/local/bin
84+
85+
# ✅ install packages
86+
# ✅ set up locale
87+
ARG LOCALE=en_US
88+
ENV LANG=${LOCALE}.UTF-8
89+
ENV LC_ALL=${LOCALE}.UTF-8
90+
ENV LANGUAGE=${LOCALE}.UTF-8
91+
RUN \
92+
apt-get update; \
93+
apt-get install -qq -y ${STANDARD_PACKAGES}; \
94+
localedef -i ${LOCALE} -c -f UTF-8 -A /usr/share/locale/locale.alias ${LOCALE}.UTF-8; \
95+
echo "${LOCALE}.UTF-8 UTF-8" >> /etc/locale.gen; \
96+
echo "LANG=${LOCALE}.UTF-8" >> /etc/locale.conf; \
97+
locale-gen ${LOCALE}.UTF-8; \
98+
useradd -m -s /bin/bash me; \
99+
chmod a+x /usr/local/bin/*;
100+
101+
USER me
102+
WORKDIR /home/me
103+
ENTRYPOINT [ "/bin/bash" ]
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
3+
# docker build . -t valet-tests-slimdeb:latest --progress plain
4+
# docker tag valet-tests-slimdeb:latest noyacode/valet-tests-slimdeb:latest
5+
# docker push noyacode/valet-tests-slimdeb:latest
6+
7+
docker run --rm -it --entrypoint /usr/local/bin/bash-5.0 valet-tests-slimdeb:latest
8+
docker run --rm -it --entrypoint /usr/local/bin/bash-5.1 valet-tests-slimdeb:latest
9+
docker run --rm -it --entrypoint /usr/local/bin/bash-5.2 valet-tests-slimdeb:latest
10+
docker run --rm -it --entrypoint /usr/local/bin/bash-5.3 valet-tests-slimdeb:latest

tests.d/self-install/minideb-bash5.0/Dockerfile

Lines changed: 0 additions & 48 deletions
This file was deleted.

version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.37.256
1+
0.37.258

0 commit comments

Comments
 (0)