Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/actions/smoke-test/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ echo "(*) Pulling latest '@devcontainer/cli"

#Temporarily installing cli from source until https://github.com/devcontainers/cli/pull/6 is merged
cd build
chmod +x devcontainers-cli-0.6.3.tgz
chmod +x devcontainers-cli-0.6.4.tgz

echo "(*) Building image - ${IMAGE}"
npx --yes devcontainers-cli-0.6.3.tgz up --workspace-folder ../src/${IMAGE}
npx --yes devcontainers-cli-0.6.4.tgz up --workspace-folder ../src/${IMAGE}
# devcontainer build --workspace-folder "src/${IMAGE}/" --image-name vsc-${IMAGE}

4 changes: 2 additions & 2 deletions .github/actions/smoke-test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ set -e
# Run actual test
echo "(*) Running test..."
cd build
chmod +x devcontainers-cli-0.6.3.tgz
chmod +x devcontainers-cli-0.6.4.tgz

npx --yes devcontainers-cli-0.6.3.tgz exec --workspace-folder $(pwd)/../src/$IMAGE /bin/sh -c 'set -e && if [ -f "test-project/test.sh" ]; then cd test-project && if [ "$(id -u)" = "0" ]; then chmod +x test.sh; else sudo chmod +x test.sh; fi && ./test.sh; else ls -a; fi'
npx --yes devcontainers-cli-0.6.4.tgz exec --workspace-folder $(pwd)/../src/$IMAGE /bin/sh -c 'set -e && if [ -f "test-project/test.sh" ]; then cd test-project && if [ "$(id -u)" = "0" ]; then chmod +x test.sh; else sudo chmod +x test.sh; fi && ./test.sh; else ls -a; fi'

# Clean up
docker stop $(docker container ls -q)
Binary file added build/devcontainers-cli-0.6.4.tgz
Binary file not shown.
2 changes: 1 addition & 1 deletion build/src/push.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ async function pushImage(definitionId, repo, release, updateLatest,
}

const spawnOpts = { stdio: 'inherit', cwd: workingDir, shell: true };
await asyncUtils.spawn('npx --yes devcontainers-cli-0.6.3.tgz', [
await asyncUtils.spawn('npx --yes devcontainers-cli-0.6.4.tgz', [
'build',
'--workspace-folder', definitionPath,
'--log-level ', 'info',
Expand Down
Binary file added src/alpine/devcontainers-cli-0.6.4.tgz
Binary file not shown.
Binary file added src/anaconda/devcontainers-cli-0.6.4.tgz
Binary file not shown.
148 changes: 148 additions & 0 deletions src/anaconda/test-project/test-utils.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
#!/bin/bash
SCRIPT_FOLDER="$(cd "$(dirname $0)" && pwd)"
USERNAME=${1:-vscode}

if [ -z $HOME ]; then
HOME="/root"
fi

FAILED=()

echoStderr()
{
echo "$@" 1>&2
}

check() {
LABEL=$1
shift
echo -e "\n🧪 Testing $LABEL"
if "$@"; then
echo "✅ Passed!"
return 0
else
echoStderr "❌ $LABEL check failed."
FAILED+=("$LABEL")
return 1
fi
}

checkMultiple() {
PASSED=0
LABEL="$1"
echo -e "\n🧪 Testing $LABEL."
shift; MINIMUMPASSED=$1
shift; EXPRESSION="$1"
while [ "$EXPRESSION" != "" ]; do
if $EXPRESSION; then ((PASSED++)); fi
shift; EXPRESSION=$1
done
if [ $PASSED -ge $MINIMUMPASSED ]; then
echo "✅ Passed!"
return 0
else
echoStderr "❌ $LABEL check failed."
FAILED+=("$LABEL")
return 1
fi
}

checkOSPackages() {
LABEL=$1
shift
echo -e "\n🧪 Testing $LABEL"
if dpkg-query --show -f='${Package}: ${Version}\n' "$@"; then
echo "✅ Passed!"
return 0
else
echoStderr "❌ $LABEL check failed."
FAILED+=("$LABEL")
return 1
fi
}

checkExtension() {
# Happens asynchronusly, so keep retrying 10 times with an increasing delay
EXTN_ID="$1"
TIMEOUT_SECONDS="${2:-10}"
RETRY_COUNT=0
echo -e -n "\n🧪 Looking for extension $1 for maximum of ${TIMEOUT_SECONDS}s"
until [ "${RETRY_COUNT}" -eq "${TIMEOUT_SECONDS}" ] || \
[ ! -e $HOME/.vscode-server/extensions/${EXTN_ID}* ] || \
[ ! -e $HOME/.vscode-server-insiders/extensions/${EXTN_ID}* ] || \
[ ! -e $HOME/.vscode-test-server/extensions/${EXTN_ID}* ] || \
[ ! -e $HOME/.vscode-remote/extensions/${EXTN_ID}* ]
do
sleep 1s
(( RETRY_COUNT++ ))
echo -n "."
done

if [ ${RETRY_COUNT} -lt ${TIMEOUT_SECONDS} ]; then
echo -e "\n✅ Passed!"
return 0
else
echoStderr -e "\n❌ Extension $EXTN_ID not found."
FAILED+=("$LABEL")
return 1
fi
}

checkCommon()
{
PACKAGE_LIST="apt-utils \
git \
openssh-client \
less \
iproute2 \
procps \
curl \
wget \
unzip \
nano \
jq \
lsb-release \
ca-certificates \
apt-transport-https \
dialog \
gnupg2 \
libc6 \
libgcc1 \
libgssapi-krb5-2 \
liblttng-ust0 \
libstdc++6 \
zlib1g \
locales \
sudo"

# Actual tests
checkOSPackages "common-os-packages" ${PACKAGE_LIST}
check "non-root-user" id ${USERNAME}
check "locale" [ $(locale -a | grep en_US.utf8) ]
check "sudo" sudo echo "sudo works."
check "zsh" zsh --version
check "oh-my-zsh" [ -d "$HOME/.oh-my-zsh" ]
check "login-shell-path" [ -f "/etc/profile.d/00-restore-env.sh" ]
check "code" which code
}

reportResults() {
if [ ${#FAILED[@]} -ne 0 ]; then
echoStderr -e "\n💥 Failed tests: ${FAILED[@]}"
exit 1
else
echo -e "\n💯 All passed!"
exit 0
fi
}

fixTestProjectFolderPrivs() {
if [ "${USERNAME}" != "root" ]; then
TEST_PROJECT_FOLDER="${1:-$SCRIPT_FOLDER}"
FOLDER_USER="$(stat -c '%U' "${TEST_PROJECT_FOLDER}")"
if [ "${FOLDER_USER}" != "${USERNAME}" ]; then
echoStderr "WARNING: Test project folder is owned by ${FOLDER_USER}. Updating to ${USERNAME}."
sudo chown -R ${USERNAME} "${TEST_PROJECT_FOLDER}"
fi
fi
}
20 changes: 20 additions & 0 deletions src/anaconda/test-project/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
cd $(dirname "$0")

source test-utils.sh vscode

# Run common tests
checkCommon

# Image specific tests
check "conda" conda --version
check "python" python --version
check "pylint" pylint --version
check "flake8" flake8 --version
check "autopep8" autopep8 --version
check "yapf" yapf --version
check "pydocstyle" pydocstyle --version
check "pycodestyle" pycodestyle --version

# Report result
reportResults
Loading