Skip to content

Commit

Permalink
Refactor test/run
Browse files Browse the repository at this point in the history
  • Loading branch information
sschmid committed Nov 5, 2024
1 parent 1974de7 commit a483799
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/alpine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ jobs:
submodules: recursive

- name: "Run tests"
run: test/run --alpine
run: test/run -p alpine
2 changes: 1 addition & 1 deletion .github/workflows/archlinux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ jobs:
submodules: recursive

- name: "Run tests"
run: test/run --archlinux
run: test/run -p archlinux
2 changes: 1 addition & 1 deletion .github/workflows/debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ jobs:
submodules: recursive

- name: "Run tests"
run: test/run --debian
run: test/run -p debian
2 changes: 1 addition & 1 deletion .github/workflows/fedora.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ jobs:
submodules: recursive

- name: "Run tests"
run: test/run --fedora
run: test/run -p fedora
2 changes: 1 addition & 1 deletion .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ jobs:
submodules: recursive

- name: "Run tests"
run: test/run --ubuntu
run: test/run -p ubuntu
53 changes: 27 additions & 26 deletions test/run
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,30 @@ set -e

declare -rx TEST_BASH_VERSION="${TEST_BASH_VERSION:-"5.2"}"

case "${1:-}" in
--alpine)
DOCKER_BUILDKIT=1 docker build --build-arg BASH_VERSION="${TEST_BASH_VERSION}" --progress=plain \
--target test -t sschmid/pw/test/alpine -f docker/alpine/Dockerfile .
;;
--archlinux)
DOCKER_BUILDKIT=1 docker build --progress=plain \
--target test -t sschmid/pw/test/archlinux -f docker/archlinux/Dockerfile .
;;
--debian)
DOCKER_BUILDKIT=1 docker build --progress=plain \
--target test -t sschmid/pw/test/debian -f docker/debian/Dockerfile .
;;
--fedora)
DOCKER_BUILDKIT=1 docker build --progress=plain \
--target test -t sschmid/pw/test/fedora -f docker/fedora/Dockerfile .
;;
--ubuntu)
DOCKER_BUILDKIT=1 docker build --progress=plain \
--target test -t sschmid/pw/test/ubuntu -f docker/ubuntu/Dockerfile .
;;
*)
test/bats/bin/bats "${@:-test}"
test/shellcheck
;;
esac
run_tests() {
DOCKER_BUILDKIT=1 docker build --target test -t "sschmid/pw/test/$1" -f "docker/$1/Dockerfile" .
}

while getopts ":ap:" options; do
case "${options}" in
a)
run_tests alpine
run_tests archlinux
run_tests debian
run_tests fedora
run_tests ubuntu
;;
p)
run_tests "${OPTARG}"
exit
;;
*)
echo "Invalid option: -${OPTARG}" >&2
exit 1
;;
esac
done
shift $(( OPTIND - 1 ))

test/bats/bin/bats "${@:-test}"
test/shellcheck

0 comments on commit a483799

Please sign in to comment.