-
Notifications
You must be signed in to change notification settings - Fork 0
/
go-example.yaml
107 lines (107 loc) · 2.59 KB
/
go-example.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
apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
name: go-example
spec:
params:
- name: repository
- name: image-registry
- name: source-subpath
default: ""
workspaces:
- name: shared-data
tasks:
- name: git-clone
taskRef:
name: git-clone
params:
- name: url
value: $(params.repository)
workspaces:
- name: output
workspace: shared-data
- name: download-dependencies
workspaces:
- name: source
workspace: shared-data
runAfter:
- git-clone
params:
- name: source-subpath
value: $(params.source-subpath)
taskSpec:
params:
- name: source-subpath
steps:
- name: mod-download
image: golang
script: |
#!/usr/bin/env bash
cd $(workspaces.source.path)/$(params.source-subpath)
go mod download
- name: test
workspaces:
- name: source
workspace: shared-data
runAfter:
- download-dependencies
params:
- name: source-subpath
value: $(params.source-subpath)
taskSpec:
params:
- name: source-subpath
steps:
- name: go-test
image: golang
script: |
#!/usr/bin/env bash
cd $(workspaces.source.path)/$(params.source-subpath)
go test ./...
- name: lint
workspaces:
- name: source
workspace: shared-data
runAfter:
- download-dependencies
params:
- name: source-subpath
value: $(params.source-subpath)
taskSpec:
params:
- name: source-subpath
steps:
- name: go-lint
image: golangci/golangci-lint
script: |
#!/usr/bin/env bash
cd $(workspaces.source.path)/$(params.source-subpath)
golangci-lint run
- name: build-container
workspaces:
- name: source
workspace: shared-data
runAfter:
- test
- lint
taskRef:
name: kaniko
params:
- name: IMAGE
value: $(params.image-registry)
- name: CONTEXT
value: $(params.source-subpath)
- name: scan-container
runAfter:
- build-container
params:
- name: source-subpath
value: $(params.source-subpath)
taskSpec:
params:
- name: source-subpath
steps:
- name: grype-scan
image: anchore/grype
args:
- $(tasks.build-container.results.IMAGE_URL)