Debian Codegraph @

script/k3s-argo-workflow/go.yaml.template

raw
1 # Example golang CI based on https://github.com/argoproj/argo-workflows/blob/7dc6515ce1ef76475ac7bd2a7a3c3cdbe795a13c/examples/ci.yaml
2
3 apiVersion: argoproj.io/v1alpha1
4 kind: Workflow
5 metadata:
6 generateName: ci-example-
7 spec:
8 # entrypoint is the name of the template used as the starting point of the workflow
9 entrypoint: ci-example
10 arguments:
11 parameters:
12 - name: revision
13 value: 09c3a5e
14 # a temporary volume, named workdir, will be used as a working directory
15 # for this workflow. This volume is passed around from step to step.
16 volumeClaimTemplates:
17 - metadata:
18 name: workdir
19 spec:
20 accessModes: [ "ReadWriteOnce" ]
21 resources:
22 requests:
23 storage: 1Gi
24
25 templates:
26 - name: ci-example
27 inputs:
28 parameters:
29 - name: revision
30 steps:
31 - - name: golangci-lint
32 template: golangci-lint-example
33 arguments:
34 parameters:
35 - name: revision
36 value: "{{inputs.parameters.revision}}"
37 - - name: gosec
38 template: gosec-example
39 - - name: build
40 template: build-golang-example
41 # the test step expands into three parallel steps running
42 # different operating system images. each mounts the workdir
43 # and runs the compiled binary from the build step.
44 - - name: test
45 template: run-hello
46 arguments:
47 parameters:
48 - name: os-image
49 value: "{{item.image}}:{{item.tag}}"
50 withItems:
51 - { image: 'ghcr.io/stargz-containers/alpine', tag: '3.10.2-${IMAGE_TYPE}' }
52 - { image: 'ghcr.io/stargz-containers/ubuntu', tag: '22.04-${IMAGE_TYPE}' }
53 - { image: 'ghcr.io/stargz-containers/fedora', tag: '30-${IMAGE_TYPE}' }
54
55 - name: golangci-lint-example
56 inputs:
57 parameters:
58 - name: revision
59 artifacts:
60 - name: code
61 path: /go/src/github.com/golang/example
62 git:
63 repo: https://github.com/golang/example.git
64 revision: "{{inputs.parameters.revision}}"
65 container:
66 image: ghcr.io/stargz-containers/golangci-lint:v1.40.1-${IMAGE_TYPE}
67 command: [sh, -c]
68 args: ["
69 cd /go/src/github.com/golang/example/hello &&
70 golangci-lint run ./...
71 "]
72 volumeMounts:
73 - name: workdir
74 mountPath: /go
75
76 - name: gosec-example
77 container:
78 image: ghcr.io/stargz-containers/gosec:v2.8.0-${IMAGE_TYPE}
79 command: [sh, -c]
80 args: ["
81 cd /go/src/github.com/golang/example/hello &&
82 gosec ./...
83 "]
84 volumeMounts:
85 - name: workdir
86 mountPath: /go
87
88 - name: build-golang-example
89 container:
90 image: ghcr.io/stargz-containers/golang:1.15.3-buster-${IMAGE_TYPE}
91 command: [sh, -c]
92 args: ["
93 cd /go/src/github.com/golang/example/hello &&
94 go build -v .
95 "]
96 volumeMounts:
97 - name: workdir
98 mountPath: /go
99
100 - name: run-hello
101 inputs:
102 parameters:
103 - name: os-image
104 container:
105 image: "{{inputs.parameters.os-image}}"
106 command: [sh, -c]
107 args: ["
108 uname -a ;
109 cat /etc/os-release ;
110 /go/src/github.com/golang/example/hello/hello
111 "]
112 volumeMounts:
113 - name: workdir
114 mountPath: /go