forked from argoproj/argo-workflows
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathci-workflowtemplate.yaml
195 lines (182 loc) · 5.4 KB
/
ci-workflowtemplate.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
apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
name: ci
annotations:
workflows.argoproj.io/description: |
This workflows builds and tests Argo Workflows.
It demonstrates:
* Cache restore and store.
* Publishing test reports.
spec:
arguments:
parameters:
- name: branch
value: master
entrypoint: main
onExit: cache-store
volumeClaimTemplates:
- metadata:
name: work
spec:
accessModes: [ ReadWriteOnce ]
resources:
requests:
storage: 64Mi
templates:
- name: main
dag:
tasks:
- name: cache-restore
template: cache-restore
- name: clone
template: clone
- name: deps
template: deps
dependencies:
- clone
- cache-restore
- name: build
template: build
dependencies:
- deps
- name: test
template: test
dependencies:
- build
- name: cache-restore
inputs:
artifacts:
- name: GOMODCACHE
path: /mnt/GOMODCACHE
optional: true
s3:
key: "github.com/golang/examples/{{workflow.parameters.branch}}/GOMODCACHE"
- name: GOCACHE
path: /mnt/GOCACHE
optional: true
s3:
key: "github.com/golang/examples/{{workflow.parameters.branch}}/GOCACHE"
container:
volumeMounts:
- mountPath: /go/pkg/mod
name: work
subPath: mod
- mountPath: /root/.cache/go-build
name: work
subPath: cache
image: golang:1.18
workingDir: /go/src/github.com/golang/example
command: [ sh, -euxc ]
args:
- |
mkdir -p $(go env GOMODCACHE)
[ -e /mnt/GOMODCACHE ] && cp -Rf /mnt/GOMODCACHE $(go env GOMODCACHE)
mkdir -p $(go env GOCACHE)
[ -e /mnt/GOCACHE ] && cp -Rf /mnt/GOCACHE $(go env GOCACHE)
- name: cache-store
container:
volumeMounts:
- mountPath: /go/pkg/mod
name: work
subPath: GOMODCACHE
- mountPath: /root/.cache/go-build
name: work
subPath: GOCACHE
image: golang:1.18
workingDir: /go/src/github.com/golang/example
outputs:
artifacts:
- name: GOMODCACHE
path: /go/pkg/mod
optional: true
s3:
key: "github.com/golang/examples/{{workflow.parameters.branch}}/GOMODCACHE"
- name: GOCACHE
path: /root/.cache/go-build
optional: true
s3:
key: "github.com/golang/examples/{{workflow.parameters.branch}}/GOCACHE"
- name: clone
container:
volumeMounts:
- mountPath: /go/src/github.com/golang/example
name: work
subPath: src
- mountPath: /go/pkg/mod
name: work
subPath: GOMODCACHE
- mountPath: /root/.cache/go-build
name: work
subPath: GOCACHE
image: golang:1.18
workingDir: /go/src/github.com/golang/example
command: [ sh, -euxc ]
args:
- |
git clone -v -b "{{workflow.parameters.branch}}" --single-branch --depth 1 https://github.com/golang/example.git .
- name: deps
container:
image: golang:1.18
volumeMounts:
- mountPath: /go/src/github.com/golang/example
name: work
subPath: src
- mountPath: /go/pkg/mod
name: work
subPath: GOMODCACHE
- mountPath: /root/.cache/go-build
name: work
subPath: GOCACHE
workingDir: /go/src/github.com/golang/example
command: [ sh, -xuce ]
args:
- |
go mod download -x
- name: build
container:
image: golang:1.18
volumeMounts:
- mountPath: /go/src/github.com/golang/example
name: work
subPath: src
- mountPath: /go/pkg/mod
name: work
subPath: GOMODCACHE
- mountPath: /root/.cache/go-build
name: work
subPath: GOCACHE
workingDir: /go/src/github.com/golang/example
command: [ sh, -xuce ]
args:
- |
go build ./...
- name: test
container:
image: golang:1.18
volumeMounts:
- mountPath: /go/src/github.com/golang/example
name: work
subPath: src
- mountPath: /go/pkg/mod
name: work
subPath: GOMODCACHE
- mountPath: /root/.cache/go-build
name: work
subPath: GOCACHE
workingDir: /go/src/github.com/golang/example
command: [ sh, -euxc ]
args:
- |
go install github.com/jstemmer/go-junit-report@latest
go install github.com/alexec/[email protected]
trap 'cat test.out | go-junit-report | junit2html > test-report.html' EXIT
go test -v ./... 2>&1 > test.out
outputs:
artifacts:
- name: test-report
path: /go/src/github.com/golang/example/test-report.html
archive:
none: { }
s3:
key: "{{workflow.parameters.branch}}/test-report.html"