-
Notifications
You must be signed in to change notification settings - Fork 11
/
screwdriver.yaml
127 lines (119 loc) · 5.15 KB
/
screwdriver.yaml
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
shared:
environment:
# Docker hub repo
DOCKER_REPO: screwdrivercd/buildcluster-queue-worker
DOCKER_MULTI_PLATFORM_BUILDS_ENABLED: 1
jobs:
main:
environment:
SD_SONAR_OPTS: "-Dsonar.sources=index.js,lib -Dsonar.tests=test -Dsonar.javascript.lcov.reportPaths=artifacts/coverage/lcov.info -Dsonar.testExecutionReportPaths=artifacts/report/test.xml"
requires: [~pr, ~commit]
image: node:18
steps:
- install: npm install
- test: npm test
publish:
requires: main
template: screwdriver-cd/semantic-release
secrets:
# Publishing to NPM
- NPM_TOKEN
# Pushing tags to Git
- GH_TOKEN
docker-publish:
requires: publish
template: sd/dind@latest
# Deploy to beta environment
beta:
requires: docker-publish
image: node:18
steps:
- setup-ci: git clone https://github.com/screwdriver-cd/toolbox.git ci
- get-tag: ./ci/git-latest.sh
- wait-docker: DOCKER_TAG=`cat VERSION` ./ci/docker-wait.sh
- deploy-k8s: K8S_TAG=`cat VERSION` ./ci/k8s-deploy.sh
- test: echo Put acceptance tests here
environment:
K8S_CONTAINER: screwdriver-buildcluster-queue-worker
K8S_IMAGE: screwdrivercd/buildcluster-queue-worker
K8S_HOST: kubernetes.default.svc
K8S_DEPLOYMENT: buildcluster-queue-worker-beta
secrets:
# Talking to Kubernetes
- K8S_TOKEN
# functional test
functional-test:
requires: beta
image: centos:centos7
environment:
PIPELINE_ID: 8188
INSTANCE: "https://beta.api.screwdriver.cd"
NAMESPACE: v4
TIMEOUT: 30
steps:
- install_jq: yum install epel-release -y && yum update -y && yum install jq -y && jq -Version
- trigger_beta_functional_test: |
TOKEN=$(curl -s -S -m ${TIMEOUT} --fail ${INSTANCE}/${NAMESPACE}/auth/token?api_token=${BETA_FT_ACCESS_TOKEN} | jq -r '.token')
[[ -z "$TOKEN" ]] && echo "empty Token" && exit 1
JOB_ID=$(curl -s -S -m ${TIMEOUT} --fail -H 'Accept: application/json' -H "Authorization: Bearer ${TOKEN}" ${INSTANCE}/${NAMESPACE}/pipelines/${PIPELINE_ID}/jobs | jq -r '.[0].id')
[[ -z "$JOB_ID" ]] && echo "empty Job Id" && exit 1
BUILD_ID=$(curl -s -S -m ${TIMEOUT} --fail -d "jobId=${JOB_ID}" -H "Content-Type: application/x-www-form-urlencoded" -H "Authorization: Bearer ${TOKEN}" -X POST ${INSTANCE}/${NAMESPACE}/builds | jq -r '.id')
[[ -z "$BUILD_ID" ]] && echo "empty Build Id" && exit 1
echo "Build ${BUILD_ID} started, polling status..."
for attempts in {1..10}; do
STATUS=$(curl -s -S -m ${TIMEOUT} --fail -H "Authorization: Bearer ${TOKEN}" ${INSTANCE}/${NAMESPACE}/builds/${BUILD_ID} | jq -r '.status')
if [[ "${STATUS}" == "SUCCESS" ]]; then
echo "Build ${BUILD_ID} ${STATUS}"
break
fi
if [[ "${STATUS}" == "FAILURE" ]] || [[ "${STATUS}" == "ABORTED" ]]; then
echo "Build ${BUILD_ID} ${STATUS}"
break
fi
if [[ "${STATUS}" == "RUNNING" ]] || [[ "${STATUS}" == "QUEUED" ]]; then
echo "Build ${BUILD_ID} ${STATUS}, wait 30s..."
sleep 30s
fi
done
if [[ "${STATUS}" != "SUCCESS" ]]; then
echo "Build ${BUILD_ID} monitoring timed out"
exit 1
fi
secrets:
- BETA_FT_ACCESS_TOKEN
# Deploy to our prod environment and run tests
prod:
requires: functional-test
image: node:18
steps:
- setup-ci: git clone https://github.com/screwdriver-cd/toolbox.git ci
- get-tag: ./ci/git-latest.sh
- wait-docker: DOCKER_TAG=`cat VERSION` ./ci/docker-wait.sh
- deploy-k8s: K8S_TAG=`cat VERSION` ./ci/k8s-deploy.sh
- test: echo Put acceptance tests here
environment:
K8S_CONTAINER: screwdriver-buildcluster-queue-worker
K8S_IMAGE: screwdrivercd/buildcluster-queue-worker
K8S_HOST: kubernetes.default.svc
K8S_DEPLOYMENT: buildcluster-queue-worker
secrets:
# Talking to Kubernetes
- K8S_TOKEN
# Deploy to our prod environment and run tests
prod-bf1:
requires: functional-test
image: node:18
steps:
- setup-ci: git clone https://github.com/screwdriver-cd/toolbox.git ci
- get-tag: ./ci/git-latest.sh
- wait-docker: DOCKER_TAG=`cat VERSION` ./ci/docker-wait.sh
- deploy-k8s: K8S_TAG=`cat VERSION` ./ci/k8s-deploy.sh
- test: echo Put acceptance tests here
environment:
K8S_CONTAINER: screwdriver-buildcluster-queue-worker
K8S_IMAGE: screwdrivercd/buildcluster-queue-worker
K8S_HOST: kubernetes.default.svc
K8S_DEPLOYMENT: buildcluster-queue-worker-bf1
secrets:
# Talking to Kubernetes
- K8S_TOKEN