generated from devcontainers/template-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-template.sh
executable file
·38 lines (31 loc) · 1.05 KB
/
test-template.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
#!/bin/bash
# Check if TEMPLATE-ID is provided
if [ -z "$1" ]; then
echo "Usage: $0 <TEMPLATE-ID>"
exit 1
fi
TEMPLATE_ID=$1
# Run the build script
echo "Running build script for TEMPLATE-ID: ${TEMPLATE_ID}"
./.github/actions/smoke-test/build.sh "${TEMPLATE_ID}"
# Check if build script executed successfully
if [ $? -ne 0 ]; then
echo "Build script failed for TEMPLATE-ID: ${TEMPLATE_ID}"
# clears the temporary directory
rm -rf "/tmp/${TEMPLATE_ID}"
exit 1
fi
# Run the test script
echo "Running test script for TEMPLATE-ID: ${TEMPLATE_ID}"
./.github/actions/smoke-test/test.sh "${TEMPLATE_ID}"
# Check if test script executed successfully
if [ $? -ne 0 ]; then
echo "Test script failed for TEMPLATE-ID: ${TEMPLATE_ID}"
# clears temporary files, so actual changes be reflected on the next test
rm -rf "/tmp/${TEMPLATE_ID}"
# kills container
ID_LABEL="test-container=${TEMPLATE_ID}"
docker rm -f $(docker container ls -f "label=${ID_LABEL}" -q)
exit 1
fi
echo "Both build and test scripts ran successfully for TEMPLATE-ID: ${TEMPLATE_ID}"