Skip to content
This repository was archived by the owner on Nov 30, 2023. It is now read-only.

Commit 58dd364

Browse files
authored
Add non-default tests
1 parent e60bdc4 commit 58dd364

File tree

5 files changed

+41
-9
lines changed

5 files changed

+41
-9
lines changed

.github/workflows/script-library.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ jobs:
1414
strategy:
1515
matrix:
1616
os: ["debian:bullseye", "debian:buster", "ubuntu:focal", "ubuntu:bionic", alpine, centos, "mcr.microsoft.com/oryx/build:github-actions-20210902.1"]
17+
defaults: ["true", "false"]
1718
fail-fast: false
1819
runs-on: ubuntu-latest
1920
steps:
@@ -34,7 +35,7 @@ jobs:
3435
id: test_script_library
3536
run: |
3637
set -e
37-
bash script-library/test/regression/test.sh "${{ matrix.os }}" false true true linux/amd64
38+
bash script-library/test/regression/test.sh "${{ matrix.os }}" false "${{ matrix.defaults }}" true linux/amd64
3839
3940
copy-scripts:
4041
name: Copy and commit script-library updates

script-library/desktop-lite-debian.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,8 @@ EOF
273273
cat << EOF > /usr/local/share/desktop-init.sh
274274
#!/bin/bash
275275
276-
USERNAME=${USERNAME}
276+
user_name="${USERNAME}"
277+
group_name="$(id -gn ${USERNAME})"
277278
LOG=/tmp/container-init.log
278279
279280
export DBUS_SESSION_BUS_ADDRESS="${DBUS_SESSION_BUS_ADDRESS:-"autolaunch:"}"
@@ -318,8 +319,8 @@ sudoIf()
318319
# Use sudo to run as non-root user if not already running
319320
sudoUserIf()
320321
{
321-
if [ "\$(id -u)" -eq 0 ] && [ "\${USERNAME}" != "root" ]; then
322-
sudo -u \${USERNAME} "\$@"
322+
if [ "\$(id -u)" -eq 0 ] && [ "\${user_name}" != "root" ]; then
323+
sudo -u \${user_name} "\$@"
323324
else
324325
"\$@"
325326
fi
@@ -347,7 +348,7 @@ done
347348
sudo rm -rf /tmp/.X11-unix /tmp/.X*-lock
348349
mkdir -p /tmp/.X11-unix
349350
sudoIf chmod 1777 /tmp/.X11-unix
350-
sudoIf chown root:\${USERNAME} /tmp/.X11-unix
351+
sudoIf chown root:\${group_name} /tmp/.X11-unix
351352
if [ "\$(echo "\${VNC_RESOLUTION}" | tr -cd 'x' | wc -c)" = "1" ]; then VNC_RESOLUTION=\${VNC_RESOLUTION}x16; fi
352353
screen_geometry="\${VNC_RESOLUTION%*x*}"
353354
screen_depth="\${VNC_RESOLUTION##*x}"

script-library/test/regression/Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@ FROM ${IMAGE_TO_TEST}
99

1010
USER root
1111

12-
ARG USE_DEFAULTS="true"
1312
ARG USERNAME="vscode"
1413
ARG RUN_COMMON_SCRIPT="true"
1514
ARG UPGRADE_PACKAGES="false"
1615
ARG RUN_ONE="false"
1716
RUN --mount=target=/script-library,source=.,type=bind,rw \
18-
sh /script-library/test/regression/run-scripts.sh /script-library ${USE_DEFAULTS} ${USERNAME} ${RUN_COMMON_SCRIPT} ${UPGRADE_PACKAGES} ${RUN_ONE}
17+
sh /script-library/test/regression/run-scripts.sh /script-library true ${USERNAME} ${RUN_COMMON_SCRIPT} ${UPGRADE_PACKAGES} ${RUN_ONE}
1918

2019
ENV DBUS_SESSION_BUS_ADDRESS="autolaunch:" DISPLAY=":1" LANG="en_US.UTF-8" LANGUAGE="en_US.UTF-8"
2120
ENTRYPOINT [ "/usr/local/share/docker-init.sh", "/usr/local/share/ssh-init.sh", "/usr/local/share/desktop-init.sh" ]
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#-------------------------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
4+
#-------------------------------------------------------------------------------------------------------------
5+
6+
# Test non-defaults
7+
ARG IMAGE_TO_TEST=debian:10
8+
FROM ${IMAGE_TO_TEST}
9+
10+
# Add non-root user
11+
USER root
12+
ARG USERNAME="bort"
13+
RUN groupadd --gid 1001 the-borts && useradd -s /bin/bash --uid 1001 --gid 1001 -m ${USERNAME}
14+
15+
# Run non-default tests
16+
ARG RUN_COMMON_SCRIPT="true"
17+
ARG UPGRADE_PACKAGES="false"
18+
ARG RUN_ONE="false"
19+
RUN --mount=target=/script-library,source=.,type=bind,rw \
20+
sh /script-library/test/regression/run-scripts.sh /script-library false ${USERNAME} ${RUN_COMMON_SCRIPT} ${UPGRADE_PACKAGES} ${RUN_ONE}
21+
22+
ENV DBUS_SESSION_BUS_ADDRESS="autolaunch:" DISPLAY=":1" LANG="en_US.UTF-8" LANGUAGE="en_US.UTF-8"
23+
ENTRYPOINT [ "/usr/local/share/docker-init.sh", "/usr/local/share/ssh-init.sh", "/usr/local/share/desktop-init.sh" ]
24+
CMD [ "sleep", "infinity" ]
25+
26+
USER ${USERNAME}

script-library/test/regression/test.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,20 @@ else
2424
OTHER_ARGS="--builder vscode-dev-containers --platform ${PLATFORMS}"
2525
fi
2626

27+
if [ "${USE_DEFAULTS}" = "false" ]; then
28+
dockerfile_path="test/regression/alt.Dockerfile"
29+
else
30+
dockerfile_path="test/regression/Dockerfile"
31+
fi
32+
2733
BUILDX_COMMAND="docker buildx build \
2834
${OTHER_ARGS} \
2935
--progress=plain \
3036
--build-arg IMAGE_TO_TEST=$IMAGE_TO_TEST \
3137
--build-arg RUN_ONE=${RUN_ONE} \
3238
--build-arg RUN_COMMON_SCRIPT=${RUN_COMMON_SCRIPT} \
33-
--build-arg USE_DEFAULTS=${USE_DEFAULTS}
3439
-t vscdc-script-library-regression \
35-
-f test/regression/Dockerfile \
40+
-f ${dockerfile_path} \
3641
."
3742
echo $BUILDX_COMMAND
3843
$BUILDX_COMMAND

0 commit comments

Comments
 (0)