-
Notifications
You must be signed in to change notification settings - Fork 13
/
test-image.sh
70 lines (59 loc) · 2.36 KB
/
test-image.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env bash
#
# Please refer to AUTHORS.md for a complete list of Copyright holders.
# Copyright (C) 2016-2023, Dockershelf Developers.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# Exit early if there are errors and be verbose
set -euxo pipefail
# Some initial configuration
BASEDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Load helper functions
source "${BASEDIR}/library.sh"
DOCKER_IMAGE_NAME="${1}"
BRANCH="${2}"
if [ "${BRANCH}" == "develop" ]; then
DOCKER_IMAGE_NAME_SUFFIX="-dev"
else
DOCKER_IMAGE_NAME_SUFFIX=""
fi
# Exit if we didn't get an image to test
if [ -z "${DOCKER_IMAGE_NAME}" ]; then
msgerror "No Docker image name was given. Aborting."
exit 1
fi
DOCKER_IMAGE_TAG="${DOCKER_IMAGE_NAME##*:}"
DOCKER_IMAGE_TARGET="${DOCKER_IMAGE_NAME##dockershelf/}"
DOCKER_IMAGE_TYPE="${DOCKER_IMAGE_TARGET%%:*}"
DOCKER_IMAGE_TYPE_VERSION="${DOCKER_IMAGE_TAG%%-*}"
DOCKER_TEST_IMAGE_NAME="${DOCKER_IMAGE_NAME}-test${DOCKER_IMAGE_NAME_SUFFIX}"
# Execute rspec for our test suite (amd64)
DOCKER_IMAGE_TAG="${DOCKER_IMAGE_TAG}" \
DOCKER_IMAGE_NAME="${DOCKER_TEST_IMAGE_NAME}-amd64" \
DOCKER_IMAGE_TYPE="${DOCKER_IMAGE_TYPE}" \
DOCKER_IMAGE_TYPE_VERSION="${DOCKER_IMAGE_TYPE_VERSION}" \
DOCKER_IMAGE_ARCH="amd64" \
bundle exec rspec \
--color \
--backtrace \
--format documentation \
"${BASEDIR}/${DOCKER_IMAGE_TYPE}/test-image.rb"
# Execute rspec for our test suite (arm64)
DOCKER_IMAGE_TAG="${DOCKER_IMAGE_TAG}" \
DOCKER_IMAGE_NAME="${DOCKER_TEST_IMAGE_NAME}-arm64" \
DOCKER_IMAGE_TYPE="${DOCKER_IMAGE_TYPE}" \
DOCKER_IMAGE_TYPE_VERSION="${DOCKER_IMAGE_TYPE_VERSION}" \
DOCKER_IMAGE_ARCH="arm64" \
bundle exec rspec \
--color \
--backtrace \
--format documentation \
"${BASEDIR}/${DOCKER_IMAGE_TYPE}/test-image.rb"