-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·54 lines (44 loc) · 1.22 KB
/
test.sh
File metadata and controls
executable file
·54 lines (44 loc) · 1.22 KB
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
#!/bin/bash
#####################
# SETUP
#########
# Fail fast
set -e
# Assume PWD is root of the repo
source ./scripts/env.sh
# Make sure the test container is removed
# when the shell exits, in error or not
atExit() {
info removing test container
docker rm -f "${containerId}"
}
trap atExit EXIT
#####################
# MAIN
#########
# Get the platform on which the container will be run
architecture=$(uname -m)
if [ "$architecture" = "x86_64" ] || [ "$architecture" = "amd64" ]; then
platform=amd64
elif [ "$architecture" = "aarch64" ] || [ "$architecture" = "arm64" ] ; then
platform=arm64
else
echo "Unsupported platform: $platform"
exit 1
fi
# Based on the platform, choose the correct local image and get the container id
image=akamai/shell:local-"${platform}"
info starting test container with tag "${image}"
# In case the image is not found, fail rather than pull remote image
containerId=$(docker run -d --name test --pull=never "${image}" sleep 3600)
# Run the tests
docker cp ./test.bats "${containerId}":/test.bats
docker exec -i "${containerId}" bash <<EOF
set -e
apk add --no-cache git bash
git clone https://github.com/bats-core/bats-core.git
cd bats-core
./install.sh /usr/local
cd /
bats /test.bats
EOF