Skip to content

Commit

Permalink
Add podman to launch test
Browse files Browse the repository at this point in the history
Users can set the DOCKER environnement variable to select Docker or
Podman to run the tests.
  • Loading branch information
L'HOSPITAL Logan committed Dec 18, 2024
1 parent 9d30fb2 commit 83617a2
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 17 deletions.
28 changes: 20 additions & 8 deletions run-tests
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#!/usr/bin/env bash

DOCKER=${DOCKER:-docker}
export DOCKER
# Author: w0rp <[email protected]>
#
# This script runs tests for the ALE project. Run `./run-tests --help` for
# options, or read the output below.
#

image=denseanalysis/ale
image=docker.io/denseanalysis/ale

# Create docker image tag based on Dockerfile contents
if [ -n "$(command -v md5)" ]; then
Expand Down Expand Up @@ -155,7 +156,18 @@ set -eu

# Check if docker un image is available locally
has_image=$(docker images --quiet "${image}:${image_tag}" | wc -l)
arch=$(docker info -f '{{ .Architecture }}')

if [[ "$DOCKER" == docker ]]; then
arch=$(docker info -f '{{ .Architecture }}')
elif [[ "$DOCKER" == podman ]]; then
arch=$(podman info -f '{{ .Host.Arch }}')
if [[ "$arch" == "amd64" ]]; then
arch="x86_64"
fi
else
echo "The DOCKER environnement variable must be docker or podman, not ${DOCKER}"
exit 1
fi

download_image() {
if [[ $arch != x86_64 ]]; then
Expand All @@ -174,12 +186,12 @@ if [ "$has_image" -eq 0 ] && ! download_image; then
if [[ $arch != x86_64 ]]; then
echo "Building testbed/vim:24 for $arch"
testbed_vim_ref=902917c4caa50db2f2e80009b839605602f9f014
docker build -t "testbed/vim:$testbed_vim_ref" "https://github.com/Vimjas/vim-testbed.git#$testbed_vim_ref"
"$DOCKER" build -t "testbed/vim:$testbed_vim_ref" "https://github.com/Vimjas/vim-testbed.git#$testbed_vim_ref"
build_args+=( --build-arg TESTBED_VIM_VERSION="$testbed_vim_ref" )
fi

docker build "${build_args[@]}" -t "${image}:${image_tag}" .
docker tag "${image}:${image_tag}" "${image}:latest"
"$DOCKER" build "${build_args[@]}" -t "${image}:${image_tag}" .
"$DOCKER" tag "${image}:${image_tag}" "${image}:latest"

if [[ -z "${DOCKER_HUB_USER:-}" || -z "${DOCKER_HUB_PASS:-}" ]]; then
echo "Docker Hub credentials not set, skip push"
Expand All @@ -192,7 +204,7 @@ else
echo "Docker run image ${image}:${image_tag} ready"
fi

docker tag "${image}:${image_tag}" "${image}:latest"
"$DOCKER" tag "${image}:${image_tag}" "${image}:latest"

output_dir=$(mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir')

Expand Down Expand Up @@ -225,7 +237,7 @@ cancel_tests() {

trap cancel_tests INT TERM

for vim in $(docker run --rm "$DOCKER_RUN_IMAGE" ls /vim-build/bin | grep '^neovim\|^vim' ); do
for vim in $("$DOCKER" run --rm "$DOCKER_RUN_IMAGE" ls /vim-build/bin | grep '^neovim\|^vim' ); do
if ( [[ $vim =~ ^vim-v8.0 ]] && ((run_vim_80_tests)) ) \
|| ( [[ $vim =~ ^vim-v9.0 ]] && ((run_vim_90_tests)) ) \
|| ( [[ $vim =~ ^neovim-v0.6 ]] && ((run_neovim_06_tests)) ) \
Expand Down
14 changes: 7 additions & 7 deletions test/script/custom-checks
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ echo 'Custom warnings/errors follow:'
echo

set -o pipefail
docker run "${docker_flags[@]}" test/script/custom-linting-rules . || exit_code=$?
"$DOCKER" run "${docker_flags[@]}" test/script/custom-linting-rules . || exit_code=$?
set +o pipefail
echo

Expand All @@ -24,7 +24,7 @@ echo 'Duplicate tags follow:'
echo

set -o pipefail
docker run "${docker_flags[@]}" test/script/check-duplicate-tags . || exit_code=$?
"$DOCKER" run "${docker_flags[@]}" test/script/check-duplicate-tags . || exit_code=$?
set +o pipefail
echo

Expand All @@ -35,7 +35,7 @@ echo 'Invalid tag references tags follow:'
echo

set -o pipefail
docker run "${docker_flags[@]}" test/script/check-tag-references || exit_code=$?
"$DOCKER" run "${docker_flags[@]}" test/script/check-tag-references || exit_code=$?
set +o pipefail

echo '========================================'
Expand All @@ -45,7 +45,7 @@ echo 'Differences follow:'
echo

set -o pipefail
docker run "${docker_flags[@]}" test/script/check-supported-tools-tables || exit_code=$?
"$DOCKER" run "${docker_flags[@]}" test/script/check-supported-tools-tables || exit_code=$?
set +o pipefail

echo '========================================'
Expand All @@ -55,7 +55,7 @@ echo 'Badly aligned tags follow:'
echo

set -o pipefail
docker run "${docker_flags[@]}" test/script/check-tag-alignment || exit_code=$?
"$DOCKER" run "${docker_flags[@]}" test/script/check-tag-alignment || exit_code=$?
set +o pipefail

echo '========================================'
Expand All @@ -64,15 +64,15 @@ echo '========================================'
echo

set -o pipefail
docker run "${docker_flags[@]}" test/script/check-toc || exit_code=$?
"$DOCKER" run "${docker_flags[@]}" test/script/check-toc || exit_code=$?
set +o pipefail

echo '========================================'
echo 'Check Python code'
echo '========================================'
echo

docker run --rm -v "$PWD:/testplugin" "$DOCKER_RUN_IMAGE" \
"$DOCKER" run --rm -v "$PWD:/testplugin" "$DOCKER_RUN_IMAGE" \
python -W ignore -m unittest discover /testplugin/test/python \
|| exit_code=$?
echo
Expand Down
2 changes: 1 addition & 1 deletion test/script/run-vader-tests
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ while [ "$tries" -lt 5 ]; do
exit_code=0
set -o pipefail
# shellcheck disable=SC2086
docker run -a stderr -e VADER_OUTPUT_FILE=/dev/stderr "${docker_flags[@]}" \
"$DOCKER" run -a stderr -e VADER_OUTPUT_FILE=/dev/stderr "${docker_flags[@]}" \
"/vim-build/bin/$vim" -u test/vimrc ${headless} \
"+Vader! $tests" 2>&1 | filter-vader-output | color-vader-output || exit_code=$?
set +o pipefail
Expand Down
2 changes: 1 addition & 1 deletion test/script/run-vint
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ echo 'Vint warnings/errors follow:'
echo

set -o pipefail
docker run -a stdout "${docker_flags[@]}" vint -s . || exit_code=$?
"$DOCKER" run -a stdout "${docker_flags[@]}" vint -s . || exit_code=$?
set +o pipefail
echo

Expand Down

0 comments on commit 83617a2

Please sign in to comment.