-
Notifications
You must be signed in to change notification settings - Fork 9
/
.gitlab-ci.yml
54 lines (47 loc) · 1.58 KB
/
.gitlab-ci.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
50
51
52
53
54
stages:
- run_tests
run_tests:
stage: run_tests
image: golang
variables:
SANDBOX_NAME: "gitlab-mr-${CI_MERGE_REQUEST_ID}"
NAMESPACE: hotrod-devmesh
script: |
# 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=${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME} \
--set namespace=${NAMESPACE} \
-f - \
< ${CI_PROJECT_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..."
go install github.com/jstemmer/go-junit-report/v2@latest
TEST_FRONTEND_ADDR=localhost:38080 TEST_TARGET_WORKLOAD=driver TEST_SANDBOX_NAME=${SANDBOX_NAME} go test -v \
${CI_PROJECT_DIR}/services/frontend/ | go-junit-report -set-exit-code -out 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}
artifacts:
when: always
paths:
- integration-report.xml
reports:
junit: integration-report.xml
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'