-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
103 lines (97 loc) · 3.99 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
stages:
- compile
- build
- test
- cleanup
before_script:
- export CLUSTER_NAME=htc-operator-test-$(echo $CI_COMMIT_SHA | head -c 6)
# - export CLUSTER_NAME=cms-cvmfs-validation
- export OS_AUTH_URL="https://keystone.cern.ch/main/v3"
- export OS_IDENTITY_API_VERSION="3"
- export OS_USERNAME="$COE_USER"
- export OS_PASSWORD=`echo $COE_PASS| sed 's/=/~/g'`
- export OS_PROJECT_NAME="CMS Analysis Recast effort"
- export OS_REGION_NAME="cern"
- export OS_DEFAULT_DOMAIN_NAME="default"
- export OS_TENANT_ID="cb60f871-095e-4628-8f1b-bcd127513ef8"
- export OS_TENANT_NAME="CMS Analysis Recast effort"
build_go_binary:
stage: compile
image: golang:1.13-buster
script:
- ls
- export GO111MODULE=on
- go mod download
- echo 'Building static go binary ...'
# - sed -i "s/cms-batch/$CLUSTER_NAME/g" cloudevents/sender.go
- GOOS=linux GOARCH=amd64 go build -o build/bin/receiver -ldflags
'-extldflags "-static"' cloudevents/receiver.go
- GOOS=linux GOARCH=amd64 go build -o build/bin/sender -ldflags
'-extldflags "-static"' cloudevents/sender.go
- GOOS=linux GOARCH=amd64 go build -o build/_output/bin/htc-operator
-ldflags '-extldflags "-static"' cmd/manager/main.go
artifacts:
paths:
- build
build_operator:
stage: build
image:
# We recommend using the CERN version of the Kaniko image: gitlab-registry.cern.ch/ci-tools/docker-image-builder
name: gitlab-registry.cern.ch/ci-tools/docker-image-builder
entrypoint: [""]
script:
#- export DATE=`date -u +%Y.%m.%dT%H-%M-%SZ`
# TAG will have a different value depending on what branch the docker image is built
# If the branch is master TAG will be composed by the word "RELEASE" and the current date in UTC
# If the branch is a feature branch TAG will be the name of that branch
#- export TAG=${TAG:-"RELEASE".$DATE}
- export TAG=latest
- export CONTEXT=${CONTEXT:-$CI_PROJECT_DIR}
- export DOCKERFILE_PATH=${DOCKERFILE_PATH:-Dockerfile}
- |
export DOCKERFILE=$CONTEXT/$DOCKERFILE_PATH
if ! [ -f "$DOCKERFILE" ]; then
echo 'Dockerfile not found, please set both CONTEXT and DOCKERFILE_PATH properly' >&2
exit 1
fi
# Prepare Kaniko configuration file:
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",
\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
# Build and push the image from the Dockerfile at the root of the project.
# To push to a specific docker tag, amend the --destination parameter, e.g. --destination $CI_REGISTRY_IMAGE:$CI_BUILD_REF_NAME
# See https://docs.gitlab.com/ee/ci/variables/predefined_variables.html#variables-reference for available variables
- /kaniko/executor --context "$CONTEXT" --dockerfile "$CONTEXT/$DOCKERFILE_PATH"
--destination "$CI_REGISTRY_IMAGE:$TAG" \
--build-arg CI_PROJECT_NAMESPACE="${CI_PROJECT_NAMESPACE}"
--build-arg CI_PROJECT_NAME="${CI_PROJECT_NAME}"
variables:
DOCKERFILE_PATH: build/Dockerfile
test k8s:
stage: test
image: gitlab-registry.cern.ch/cloud/ciadm
allow_failure: true
script:
- source ci/create-cluster.sh
# - export KUBECONFIG=config
- source ci/k8s-setup.sh
- cat deploy/operator.yaml| sed "s/cms-batch.cern.ch/${CLUSTER_NAME}.cern.ch/"|
kubectl create -f -
- kubectl create -f deploy/service_account.yaml
- kubectl create -f deploy/role_binding.yaml
- kubectl create -f deploy/role.yaml
- kubectl create -f deploy/crds/htc.cern.ch_htcjobs_crd.yaml
- kubectl create -f examples/retcode/zero.yaml
- ./ci/wait-HTCJob.sh
- kubectl delete htcjob --all
cleanup test clusters:
stage: cleanup
allow_failure: true
image: gitlab-registry.cern.ch/cloud/ciadm
script:
- openstack coe cluster show ${CLUSTER_NAME};
if [ $? -eq 0 ]; then \
openstack coe cluster delete ${CLUSTER_NAME} || true; fi
- sleep 5
- while openstack coe cluster show ${CLUSTER_NAME};
[ $? -eq 0 ]; do sleep 3; done
when: always