-
Notifications
You must be signed in to change notification settings - Fork 110
/
e2e-kind.yaml
225 lines (223 loc) · 6.56 KB
/
e2e-kind.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
# Copyright 2021 The Tekton Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: kind-e2e
labels:
app.kubernetes.io/version: "0.1"
annotations:
tekton.dev/pipelines.minVersion: "0.12.1"
tekton.dev/categories: Kubernetes
tekton.dev/displayName: "kind"
tekton.dev/tags: "kind"
tekton.dev/platforms: "linux/amd64"
spec:
description: >-
Sets up and executes commands in KinD (Kubernetes in Docker) environment.
See https://kind.sigs.k8s.io for more details.
params:
- name: arguments
type: array
description: args to pass to the kind script
workspaces:
- name: source
steps:
- name: make-artifacts-folder
image: alpine:3.15.3
env:
- name: ARTIFACTS_FOLDER
value: "$(workspaces.source.path)/artifacts"
script: |
#!/bin/sh
set -ex
mkdir -p "$ARTIFACTS_FOLDER"
echo "Created folder $ARTIFACTS_FOLDER"
- image: ghcr.io/tektoncd/plumbing/kind-e2e:latest
imagePullPolicy: Always
workingDir: $(workspaces.source.path)
name: kind
volumeMounts:
- mountPath: /var/run/
name: dind-socket
- mountPath: /lib/modules
name: modules
readOnly: true
- mountPath: /sys/fs/cgroup
name: cgroup
args: ["$(params.arguments[*])"]
sidecars:
- image: docker:20.10.11-dind
name: dind-sidecar
securityContext:
privileged: true
volumeMounts:
- mountPath: /var/lib/docker
name: dind-storage
- mountPath: /var/run/
name: dind-socket
readinessProbe:
exec:
command:
- docker
- ps
initialDelaySeconds: 5
periodSeconds: 5
volumes:
- name: dind-storage
emptyDir: {}
- name: dind-socket
emptyDir: {}
- name: modules
hostPath:
path: /lib/modules
type: Directory
- name: cgroup
hostPath:
path: /sys/fs/cgroup
type: Directory
---
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: kind-e2e
annotations:
description: |
Run e2e tests on a kind cluster on k8s
spec:
params:
- name: pullRequestNumber
description: The pullRequestNumber
- name: pullRequestBaseRef
description: The pull request base branch
- name: gitRepository
description: The git repository that hosts context and Dockerfile
- name: gitCloneDepth
description: Number of commits in the change + 1
- name: fileFilterRegex
description: Names regex to be matched in the list of modified files
- name: checkName
description: The name of the GitHub check that this pipeline is used for
- name: gitHubCommand
description: The command that was used to trigger testing
- name: k8s-version
type: string
description: The version of k8s (e.g. v1.21.x, v1.22.x or v1.23.x)
- name: e2e-script
type: string
description: the path to the e2e script in the sources
default: "test/e2e-tests.sh"
- name: e2e-env
type: string
description: |
the path to an env file that is loaded before the execution
of the e2e-script
default: ""
workspaces:
- name: sources
description: Workspace where the git repo is prepared for testing
- name: credentials
description: Credentials for uploading logs
tasks:
- name: clone-repo
taskRef:
resolver: bundles
params:
- name: bundle
value: ghcr.io/tektoncd/catalog/upstream/tasks/git-batch-merge:0.2
- name: name
value: git-batch-merge
- name: kind
value: task
params:
- name: url
value: $(params.gitRepository)
- name: mode
value: "merge"
- name: revision
value: $(params.pullRequestBaseRef)
- name: refspec
value: refs/heads/$(params.pullRequestBaseRef):refs/heads/$(params.pullRequestBaseRef)
- name: batchedRefs
value: "refs/pull/$(params.pullRequestNumber)/head"
workspaces:
- name: output
workspace: sources
- name: check-name-matches
taskRef:
name: check-name-matches
params:
- name: gitHubCommand
value: $(params.gitHubCommand)
- name: checkName
value: $(params.checkName)
- name: check-git-files-changed
runAfter: ['clone-repo']
taskRef:
name: check-git-files-changed
params:
- name: gitCloneDepth
value: $(params.gitCloneDepth)
- name: regex
value: $(params.fileFilterRegex)
workspaces:
- name: input
workspace: sources
- name: e2e-tests
when: # implicit dependency on the check tasks
- input: $(tasks.check-name-matches.results.check)
operator: in
values: ["passed"]
- input: $(tasks.check-git-files-changed.results.check)
operator: in
values: ["passed"]
taskRef:
name: kind-e2e
params:
- name: arguments
value:
- --k8s-version
- "$(params.k8s-version)"
- --cluster-suffix
- "$(params.pullRequestNumber)"
- --nodes
- "3"
- --e2e-script
- "$(params.e2e-script)"
- --e2e-env
- "$(params.e2e-env)"
workspaces:
- name: source
workspace: sources
finally:
- name: upload-logs
taskRef:
resolver: bundles
params:
- name: bundle
value: ghcr.io/tektoncd/catalog/upstream/tasks/gcs-upload:0.1
- name: name
value: gcs-upload
- name: kind
value: task
params:
- name: path
value: artifacts
- name: location
value: gs://tekton-prow/pr-logs/pull/tektoncd_pipeline/$(params.pullRequestNumber)/$(params.checkName)/$(context.pipelineRun.name)/artifacts"
workspaces:
- name: credentials
workspace: credentials
- name: source
workspace: sources