This repository has been archived by the owner on Oct 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
137 lines (119 loc) · 3.62 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
image: golang:latest
variables:
# Please edit to your GitLab project
REPO_NAME: gitlab.com/stormforger/ci-playground
SF_ORG: "demo"
SF_DS_PREFIX: "example-gitlab-ci"
TARGET_ENV_STAGING: "staging"
TARGET_ENV_PRODUCTION: "production"
stages:
- build # build the app
- staging:deploy
- staging:test
- production:deploy
- production:test
# ==== templates ====
.forge:
image:
name: stormforger/cli:latest
entrypoint: [""]
# ===== Stage: Build ====
format:
stage: build
except: ["schedules"]
script:
- go fmt $(go list ./... | grep -v /vendor/)
- go vet $(go list ./... | grep -v /vendor/)
gotest:
stage: build
except: ["schedules"]
script:
- go test -race $(go list ./... | grep -v /vendor/)
compile:
stage: build
except: ["schedules"]
script:
- go build -race -ldflags "-extldflags '-static'" -o $CI_PROJECT_DIR/mybinary
artifacts:
paths:
- mybinary
sf:ping:
stage: build
extends: .forge
script:
- forge ping # check that we can reach the API and our token is correct
# ===== staging:deploy ====
deploy_staging:
stage: staging:deploy
except: ["schedules"]
resource_group: staging
script:
- sleep 1 # dummy step - out of scope
# ===== staging:test ====
sf:loadtest_staging:
stage: staging:test
except: ["schedules"]
resource_group: staging
extends: .forge
script:
- ./scripts/data-source.sh "${TARGET_ENV}"
- forge datasource push ${SF_ORG} ./*.csv --name-prefix-path="${SF_DS_PREFIX}/${TARGET_ENV}/" --auto-field-names
- |
forge test-case launch "${TESTCASE}" --test-case-file="loadtest/loadtest.mjs" \
--define ENV=\"${TARGET_ENV}\" \
--title="${TITLE}" --notes="${NOTES}" \
--label="git-ref=${CI_COMMIT_REF_NAME}" \
--label="gitlab-project=${CI_PROJECT_URL}" \
--label="gitlab-commit=${CI_COMMIT_SHA}" \
--label="gitlab-job=${CI_JOB_STAGE} ${CI_JOB_NAME}" \
--label="giblab-job-url=${CI_JOB_URL}" \
--label="gitlab-actor=${GITLAB_USER_LOGIN}" \
${LAUNCH_ARGS}
variables:
TARGET_ENV: "${TARGET_ENV_STAGING}"
LAUNCH_ARGS: "--validate"
NOTES: |
Message:
${CI_COMMIT_MESSAGE}
TITLE: "#${CI_CONCURRENT_ID} (${CI_COMMIT_SHORT_SHA})"
TESTCASE: "${SF_ORG}/example-gitlab-ci-${TARGET_ENV_STAGING}"
# ===== production:deploy ====
deploy_production:
stage: production:deploy
only:
refs:
- master
except: ["schedules"]
resource_group: production
script:
- sleep 1 # dummy step - out of scope
# ===== production:test ====
sf:loadtest_production:
stage: production:test
only:
refs:
- master
extends: .forge
resource_group: production
script:
- ./scripts/data-source.sh "${TARGET_ENV}"
- forge datasource push ${SF_ORG} ./*.csv --name-prefix-path="${SF_DS_PREFIX}/${TARGET_ENV}/" --auto-field-names
- |
forge test-case launch "${TESTCASE}" --test-case-file="loadtest/loadtest.mjs" \
--define ENV=\"${TARGET_ENV}\" \
--title="${TITLE}" --notes="${NOTES}" \
--label="git-ref=${CI_COMMIT_REF_NAME}" \
--label="gitlab-project=${CI_PROJECT_URL}" \
--label="gitlab-commit=${CI_COMMIT_SHA}" \
--label="gitlab-job=${CI_JOB_STAGE} ${CI_JOB_NAME}" \
--label="giblab-job-url=${CI_JOB_URL}" \
--label="gitlab-actor=${GITLAB_USER_LOGIN}" \
${LAUNCH_ARGS}
variables:
TARGET_ENV: "${TARGET_ENV_PRODUCTION}"
LAUNCH_ARGS: "--nfr-check-file=./loadtest/loadtest.nfr.yaml"
NOTES: |
Message:
${CI_COMMIT_MESSAGE}
TITLE: "#${CI_CONCURRENT_ID} (${CI_COMMIT_SHORT_SHA})"
TESTCASE: "${SF_ORG}/example-gitlab-ci-${TARGET_ENV_PRODUCTION}"