Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for all images #147

Merged
merged 10 commits into from
Oct 12, 2022
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
8 changes: 7 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,23 @@ jobs:
matrix:
config:
- image: accumulo
test: accumulo
- image: dns
test: dns
- image: centos7-oj17
- image: centos7-oj17-openldap-referrals
test: openldap
- image: spark3-iceberg
test: spark3-iceberg
- image: spark3-delta
test: spark3-delta
- image: kerberos
test: kerberos
- image: gpdb-6
test: gpdb-6
- image: hdp2.6-hive-kerberized-2
- image: hive3.1-hive
imag: hive3.1-hive
test: hive3.1-hive
- image: hdp2.6-hive-kerberized
test: hdp2.6-hive
- image: hdp3.1-hive-kerberized
Expand All @@ -31,6 +36,7 @@ jobs:
- image: cdh5.15-hive-kerberized
test: cdh5.15-hive
- image: cdh5.15-hive-kerberized-kms
# TODO add test https://github.com/trinodb/trino/issues/14543
- image: phoenix5
steps:
- uses: actions/checkout@v3
Expand Down
142 changes: 71 additions & 71 deletions bin/depend.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/usr/bin/env bash

usage() {
echo "$0 {-d|-g|-p {tag}|-x} {target image Dockerfile} [known image tags]" >&2
echo "$0 {-d|-g|-p {tag}|-x} {target image Dockerfile} [known image tags]" >&2
}

find_parent() {
awk '
awk '
BEGIN {
ec = 1;
}
Expand All @@ -28,9 +28,9 @@ find_parent() {
}

contains() {
needle=$1
shift
echo "$@" | grep -q -E "\<$needle\>"
needle=$1
shift
echo "$@" | grep -q -E "\<$needle\>"
}

#
Expand All @@ -40,43 +40,43 @@ contains() {
# invoking `docker pull' to fetch the base images.
#
make_friendly_name() {
echo "$1" | sed 's/:/@/g'
echo "$1" | sed 's/:/@/g'
}

untag() {
echo "${1%:*}"
echo "${1%:*}"
}

noop() {
:
:
}

depfiles_own_image() {
local target_image=$1
local make_friendly_parent=$(make_friendly_name "$2")
local untagged_parent=$(untag "$2")

echo "$target_image@latest: $make_friendly_parent"
echo ".PHONY: $target_image.dependants $untagged_parent.dependants"
echo "$untagged_parent.dependants: $target_image"
echo "$untagged_parent.dependants: $target_image.dependants"
local target_image=$1
local make_friendly_parent=$(make_friendly_name "$2")
local untagged_parent=$(untag "$2")

echo "$target_image@latest: $make_friendly_parent"
echo ".PHONY: $target_image.dependants $untagged_parent.dependants"
echo "$untagged_parent.dependants: $target_image"
echo "$untagged_parent.dependants: $target_image.dependants"
}

depfiles_ext_image() {
local target_image="$1"
local make_friendly_parent=$(make_friendly_name "$2")
local target_image="$1"
local make_friendly_parent=$(make_friendly_name "$2")

echo "$target_image@latest: $make_friendly_parent"
echo "$target_image@latest: $make_friendly_parent"
}

list_ext_image() {
local make_friendly_parent=$(make_friendly_name "$2")
echo "$make_friendly_parent"
local make_friendly_parent=$(make_friendly_name "$2")
echo "$make_friendly_parent"
}

graph_own_image() {
local untagged_parent=$(untag "$2")
cat <<-EOF
local untagged_parent=$(untag "$2")
cat <<-EOF
"$1" [shape=box]
"$untagged_parent" [shape=box]
"$1" -> "$untagged_parent"
Expand All @@ -85,58 +85,58 @@ EOF
}

graph_ext_image() {
cat <<-EOF
cat <<-EOF
"$1" [shape=box]
"$2" [shape=house; style=filled; fillcolor="#a0a0a0"]
"$1" -> "$2"
EOF
}

require_parent_tag() {
local target_image=$1
local parent_image=$2
local target_image=$1
local parent_image=$2

if ! echo "$parent_image" | grep ":${required_parent_tag}\$"; then
echo "FROM in Dockerfile for $target_image must specify a parent with the tag '$required_parent_tag'" >&2
exit 1
fi
if ! echo "$parent_image" | grep ":${required_parent_tag}\$"; then
echo "FROM in Dockerfile for $target_image must specify a parent with the tag '$required_parent_tag'" >&2
exit 1
fi
}

while getopts ":dgp:x" c; do
case $c in
d)
own_image_function=depfiles_own_image
ext_image_function=depfiles_ext_image
;;
x)
own_image_function=noop
ext_image_function=list_ext_image
;;
g)
own_image_function=graph_own_image
ext_image_function=graph_ext_image
;;
p)
own_image_function=require_parent_tag
required_parent_tag=$OPTARG
ext_image_function=noop
;;
\?)
echo "Unrecognized option -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument" >&2
exit 1
;;
esac
case $c in
d)
own_image_function=depfiles_own_image
ext_image_function=depfiles_ext_image
;;
x)
own_image_function=noop
ext_image_function=list_ext_image
;;
g)
own_image_function=graph_own_image
ext_image_function=graph_ext_image
;;
p)
own_image_function=require_parent_tag
required_parent_tag=$OPTARG
ext_image_function=noop
;;
\?)
echo "Unrecognized option -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument" >&2
exit 1
;;
esac
done

shift $((OPTIND-1))
shift $((OPTIND - 1))

if [ -z "$own_image_function" ] || [ $# -lt 2 ]; then
usage
exit 1
usage
exit 1
fi

target_dockerfile=$1
Expand All @@ -147,19 +147,19 @@ known_images="$*"
parent_image_tag=$(find_parent "$target_dockerfile")
ec=$?
case $ec in
0) ;;
1)
echo "Failed to find a parent docker image in $target_dockerfile" >&2
exit $ec
;;
2)
echo "Found multiple parent docker images in $target_dockerfile" >&2
exit $ec
;;
0) ;;
1)
echo "Failed to find a parent docker image in $target_dockerfile" >&2
exit $ec
;;
2)
echo "Found multiple parent docker images in $target_dockerfile" >&2
exit $ec
;;
esac

if contains "$parent_image_tag" "$known_images"; then
$own_image_function "$target_image" "$parent_image_tag"
$own_image_function "$target_image" "$parent_image_tag"
else
$ext_image_function "$target_image" "$parent_image_tag"
$ext_image_function "$target_image" "$parent_image_tag"
fi
10 changes: 5 additions & 5 deletions bin/flag.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/bin/sh

usage() {
echo "$0 {target image}" >&2
echo "$0 {target image}" >&2
}

find_args() {
local target_image=$(dirname "$target_dockerfile")
awk -v image="$target_image" '
local target_image=$(dirname "$target_dockerfile")
awk -v image="$target_image" '
BEGIN {
ARG_PATTERN = "^\\s*ARG";
print "DBFLAGS_" image " :=";
Expand All @@ -25,8 +25,8 @@ find_args() {
}

if [ $# -lt 1 ]; then
usage
exit 1
usage
exit 1
fi

target_dockerfile=$1
Expand Down
4 changes: 2 additions & 2 deletions bin/push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ set -xeuo pipefail

while [ "$#" -gt 0 ]; do
while ! docker push "$1"; do
echo "Failed to push $1, retrying in 30s..."
sleep 30
echo "Failed to push $1, retrying in 30s..."
sleep 30
done
shift
done
Loading