-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample-golang-wf.yaml
156 lines (151 loc) · 3.69 KB
/
example-golang-wf.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
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: example-golang-wf-
spec:
entrypoint: example-golang
arguments:
parameters:
- name: repo
value: https://github.com/colinlabs/argo-demo.git
- name: revision
value: master
templates:
- name: example-golang
retryStrategy:
limit: 2
steps:
- - name: checkout
template: checkout
- - name: build
template: build
arguments:
artifacts:
- name: source
from: "{{steps.checkout.outputs.artifacts.source}}"
- - name: test-unit
template: test-unit
arguments:
artifacts:
- name: source
from: "{{steps.checkout.outputs.artifacts.source}}"
parameters:
- name: image
value: "{{item.image}}"
- name: tag
value: "{{item.tag}}"
withItems:
- { image: 'golang', tag: '1.14.2' }
- { image: 'golang', tag: '1.13.10' }
- { image: 'golang', tag: '1.12.17' }
- - name: test-benchmark
template: test-benchmark
arguments:
artifacts:
- name: source
from: "{{steps.checkout.outputs.artifacts.source}}"
- - name: docker-build
template: docker-build
arguments:
artifacts:
- name: source
from: "{{steps.checkout.outputs.artifacts.source}}"
- name: example-golang
from: "{{steps.build.outputs.artifacts.example-golang}}"
- name: checkout
inputs:
artifacts:
- name: source
path: /src
git:
repo: "{{workflow.parameters.repo}}"
revision: "{{workflow.parameters.revision}}"
outputs:
artifacts:
- name: source
path: /src
container:
image: golang:1.14.2
command: ['bash','-c']
workingDir: /src
args: ["ls -la && git status && git log"]
- name: build
inputs:
artifacts:
- name: source
path: /go/src
outputs:
artifacts:
- name: example-golang
path: /go/bin
container:
image: golang:1.14.2-alpine
command: ["sh", "-c"]
workingDir: /go/src/example-golang
args: ['
go install;
ls -lR;
']
- name: test-unit
inputs:
artifacts:
- name: source
path: /go/src
parameters:
- name: image
- name: tag
container:
image: "{{inputs.parameters.image}}:{{inputs.parameters.tag}}"
command: ["bash", "-c"]
workingDir: /go/src/example-golang
args: ['
go test -v
']
- name: test-benchmark
inputs:
artifacts:
- name: source
path: /go/src
container:
image: golang:1.14.2
command: ["bash", "-c"]
workingDir: /go/src/example-golang
args: ['
go test --bench=.
']
- name: docker-build
volumes:
- name: dockerhub
secret:
secretName: dockerhub
inputs:
artifacts:
- name: source
path: /go/src
- name: example-golang
path: /go/bin
script:
image: docker:17.03
command: [sh]
workingDir: /go/src/example-golang
source: |
set -x
ls -lR
ls -la /root/.docker
until docker ps; do sleep 3; done;
cp /go/bin/example-golang .
tag=`date '+%m%d%H%M'`
image="colinlabs/argo-example-golang:$tag"
docker build -t $image .
docker push $image
env:
- name: DOCKER_HOST
value: 127.0.0.1
volumeMounts:
- name: dockerhub
mountPath: "/root/.docker"
sidecars:
- name: dind
image: docker:17.03-dind
securityContext:
privileged: true