Add podman to launch test (#4882)

Users can set the DOCKER environnement variable to select Docker or
Podman to run the tests.

Co-authored-by: L'HOSPITAL Logan <lhospitallogan@gmail.com>
This commit is contained in:
Logan
2024-12-29 05:42:04 +01:00
committed by GitHub
parent d69f8fed73
commit c9df465148
4 changed files with 29 additions and 17 deletions

View File

@@ -1,12 +1,13 @@
#!/usr/bin/env bash
DOCKER=${DOCKER:-docker}
export DOCKER
# Author: w0rp <devw0rp@gmail.com>
#
# 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
@@ -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
@@ -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"
@@ -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')
@@ -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)) ) \

View File

@@ -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
@@ -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
@@ -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 '========================================'
@@ -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 '========================================'
@@ -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 '========================================'
@@ -64,7 +64,7 @@ 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 '========================================'
@@ -72,7 +72,7 @@ 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

View File

@@ -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

View File

@@ -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