-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbitbucket-pipelines.yml
49 lines (42 loc) · 1.85 KB
/
bitbucket-pipelines.yml
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
image: golang
pipelines:
pull-requests:
'**':
- step:
name: Run Tests
script:
- |
export SANDBOX_NAME="bitbucket-pr-${BITBUCKET_PR_ID}"
export NAMESPACE="hotrod-devmesh"
# Set up Signadot CLI
apt update; apt install -y jq
curl -sSLf https://raw.githubusercontent.com/signadot/cli/main/scripts/install.sh | sh
# Create a sandbox
echo "Creating sandbox ${SANDBOX_NAME}..."
signadot sandbox apply \
--set name=${SANDBOX_NAME} \
--set service=driver \
--set branch=${BITBUCKET_BRANCH} \
--set namespace=${NAMESPACE} \
-f - \
< ${BITBUCKET_CLONE_DIR}/.signadot/sbx-noop.yaml
# Run the proxy
echo "Starting signadot proxy..."
signadot local proxy --sandbox ${SANDBOX_NAME} \
--map http://frontend.${NAMESPACE}:8080@localhost:38080 > /tmp/signadot-proxy.log &
PROXY_PID=$!
sleep 1
cat /tmp/signadot-proxy.log
# Execute the tests
echo "Executing tests..."
source bitbucket-pipelines-go.sh
go install github.com/jstemmer/go-junit-report/v2@latest
mkdir test-reports
TEST_FRONTEND_ADDR=localhost:38080 TEST_TARGET_WORKLOAD=driver TEST_SANDBOX_NAME=${SANDBOX_NAME} go test -v \
${BITBUCKET_CLONE_DIR}/services/frontend/ | go-junit-report -set-exit-code -out test-reports/integration-report.xml
# Stop the proxy
echo "Stopping signadot proxy..."
cat /tmp/signadot-proxy.log
kill ${PROXY_PID}
echo "Deleting sandbox..."
signadot sandbox delete ${SANDBOX_NAME}