This repository has been archived by the owner on Apr 28, 2022. It is now read-only.
forked from coreos/etcd-operator
-
Notifications
You must be signed in to change notification settings - Fork 18
/
.gitlab-ci.yml
124 lines (118 loc) · 3.64 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
include:
- project: cloudbear/ci
ref: master
file: /base/base.yml
- project: cloudbear/ci
ref: master
file: /base/image.yml
- project: cloudbear/ci
ref: master
file: /templates/prepare-release/semantic-release.yml
dependencies:
stage: dependencies
image: golang
variables:
GOPATH: $CI_PROJECT_DIR/.go
interruptible: true
rules:
- if: '$CI_COMMIT_TAG'
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_COMMIT_TITLE !~ /chore\(release\)\: version/'
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: '$CI_PIPELINE_SOURCE == "external_pull_request_event"'
script: go mod vendor
cache:
key:
files:
- go.mod
- go.sum
paths:
- .go/pkg/mod/
- vendor
artifacts:
expire_in: 1h
paths:
- vendor
build:
extends:
- .base-build-image
needs:
- dependencies
build:e2e:
extends:
- .base-build-image
needs:
- dependencies
variables:
BUILD_CONTEXT: $CI_PROJECT_DIR
BUILD_FILE: $CI_PROJECT_DIR/test/pod/Dockerfile
BUILD_IMAGE_NAME: "$CI_REGISTRY_IMAGE/e2e:$CI_COMMIT_SHA"
unit-tests:
stage: test
image: golang:1.14.14-alpine
interruptible: true
rules:
- if: '$CI_COMMIT_TAG'
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_COMMIT_TITLE !~ /chore\(release\)\: version/'
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: '$CI_PIPELINE_SOURCE == "external_pull_request_event"'
variables:
CGO_ENABLED: 0
script: go test -v -coverprofile .testCoverage.txt github.com/coreos/etcd-operator/pkg/... 2>&1 | tee output
after_script:
- go get -u github.com/jstemmer/go-junit-report
- cat output | go-junit-report > report.xml
coverage: /^coverage:\s(\d+(?:\.\d+)?%)/
needs:
- dependencies
artifacts:
when: always
reports:
junit: report.xml
e2e:
stage: test
extends:
- .dind
interruptible: true
resource_group: e2e
rules:
- if: '$CI_COMMIT_TAG'
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_COMMIT_TITLE !~ /chore\(release\)\: version/'
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: '$CI_PIPELINE_SOURCE == "external_pull_request_event"'
needs:
- build
- build:e2e
variables:
CGO_ENABLED: 0
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
- apk add -U wget bash git sudo go
- wget -O /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/v1.17.0/bin/linux/amd64/kubectl
- chmod +x /usr/local/bin/kubectl
- kubectl get nodes -o wide
- kubectl get pods --all-namespaces -o wide
- kubectl get services --all-namespaces -o wide
- export OPERATOR_IMAGE=$BUILD_IMAGE_NAME
- export TEST_IMAGE="$CI_REGISTRY_IMAGE/e2e:$CI_COMMIT_SHA"
- export TEST_AWS_SECRET=na
- export TEST_S3_BUCKET=na
- export TEST_NAMESPACE=etcd-operator-e2e
- export BUILD_IMAGE=false
- export BUILD_E2E=false
- export PASSES=e2e
- kubectl create ns $TEST_NAMESPACE --dry-run -o yaml | kubectl apply -f -
- kubectl -n $TEST_NAMESPACE create secret docker-registry pull-secret --docker-server=$CI_REGISTRY --docker-username=$CI_REGISTRY_USER --docker-password=$CI_REGISTRY_PASSWORD --dry-run -o yaml | kubectl apply -f -
- "kubectl -n $TEST_NAMESPACE patch serviceaccount default -p '{\"imagePullSecrets\": [{\"name\": \"pull-secret\"}]}' --dry-run -o yaml | kubectl apply -f -"
script: hack/ci/run_e2e
after_script:
- cat _output/logs/*
environment:
name: staging/e2e
action: prepare
kubernetes:
namespace: etcd-operator-e2e
release:
extends:
- .base-release-image
needs:
- build