|
1 | | -local PipelineTesting = { |
2 | | - kind: "pipeline", |
3 | | - name: "testing", |
4 | | - platform: { |
5 | | - os: "linux", |
6 | | - arch: "amd64", |
7 | | - }, |
8 | | - steps: [ |
9 | | - { |
10 | | - name: "vet", |
11 | | - image: "golang:1.11", |
12 | | - pull: "always", |
13 | | - environment: { |
14 | | - GO111MODULE: "on", |
15 | | - }, |
16 | | - commands: [ |
17 | | - "go vet ./...", |
18 | | - ], |
19 | | - }, |
20 | | - { |
21 | | - name: "test", |
22 | | - image: "golang:1.11", |
23 | | - pull: "always", |
24 | | - environment: { |
25 | | - GO111MODULE: "on", |
26 | | - }, |
27 | | - commands: [ |
28 | | - "go test -cover ./...", |
29 | | - ], |
30 | | - }, |
31 | | - ], |
32 | | - trigger: { |
33 | | - branch: [ "master" ], |
34 | | - }, |
35 | | -}; |
36 | | - |
37 | | -local PipelineBuild(os="linux", arch="amd64") = { |
38 | | - kind: "pipeline", |
39 | | - name: os + "-" + arch, |
40 | | - platform: { |
41 | | - os: os, |
42 | | - arch: arch, |
43 | | - }, |
44 | | - steps: [ |
45 | | - { |
46 | | - name: "build-push", |
47 | | - image: "golang:1.11", |
48 | | - pull: "always", |
49 | | - environment: { |
50 | | - CGO_ENABLED: "0", |
51 | | - GO111MODULE: "on", |
52 | | - }, |
53 | | - commands: [ |
54 | | - "go build -v -ldflags \"-X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/" + os + "/" + arch + "/drone-matrix", |
55 | | - ], |
56 | | - when: { |
57 | | - event: [ "push", "pull_request" ], |
58 | | - }, |
59 | | - }, |
60 | | - { |
61 | | - name: "build-tag", |
62 | | - image: "golang:1.11", |
63 | | - pull: "always", |
64 | | - environment: { |
65 | | - CGO_ENABLED: "0", |
66 | | - GO111MODULE: "on", |
67 | | - }, |
68 | | - commands: [ |
69 | | - "go build -v -ldflags \"-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/" + os + "/" + arch + "/drone-matrix", |
70 | | - ], |
71 | | - when: { |
72 | | - event: [ "tag" ], |
73 | | - }, |
74 | | - }, |
75 | | - { |
76 | | - name: "executable", |
77 | | - image: "golang:1.11", |
78 | | - pull: "always", |
79 | | - commands: [ |
80 | | - "./release/" + os + "/" + arch + "/drone-matrix --help", |
81 | | - ], |
82 | | - }, |
83 | | - { |
84 | | - name: "dryrun", |
85 | | - image: "plugins/docker:" + os + "-" + arch, |
86 | | - pull: "always", |
87 | | - settings: { |
88 | | - dry_run: true, |
89 | | - tags: os + "-" + arch, |
90 | | - dockerfile: "docker/Dockerfile." + os + "." + arch, |
91 | | - repo: "plugins/matrix", |
92 | | - username: { "from_secret": "docker_username" }, |
93 | | - password: { "from_secret": "docker_password" }, |
94 | | - }, |
95 | | - when: { |
96 | | - event: [ "pull_request" ], |
97 | | - }, |
98 | | - }, |
99 | | - { |
100 | | - name: "publish", |
101 | | - image: "plugins/docker:" + os + "-" + arch, |
102 | | - pull: "always", |
103 | | - settings: { |
104 | | - auto_tag: true, |
105 | | - auto_tag_suffix: os + "-" + arch, |
106 | | - dockerfile: "docker/Dockerfile." + os + "." + arch, |
107 | | - repo: "plugins/matrix", |
108 | | - username: { "from_secret": "docker_username" }, |
109 | | - password: { "from_secret": "docker_password" }, |
110 | | - }, |
111 | | - when: { |
112 | | - event: [ "push", "tag" ], |
113 | | - }, |
114 | | - }, |
115 | | - ], |
116 | | - depends_on: [ |
117 | | - "testing", |
118 | | - ], |
119 | | - trigger: { |
120 | | - branch: [ "master" ], |
121 | | - }, |
122 | | -}; |
123 | | - |
124 | | -local PipelineNotifications = { |
125 | | - kind: "pipeline", |
126 | | - name: "notifications", |
127 | | - platform: { |
128 | | - os: "linux", |
129 | | - arch: "amd64", |
130 | | - }, |
131 | | - steps: [ |
132 | | - { |
133 | | - name: "manifest", |
134 | | - image: "plugins/manifest:1", |
135 | | - pull: "always", |
136 | | - settings: { |
137 | | - username: { "from_secret": "docker_username" }, |
138 | | - password: { "from_secret": "docker_password" }, |
139 | | - spec: "docker/manifest.tmpl", |
140 | | - ignore_missing: true, |
141 | | - }, |
142 | | - }, |
143 | | - { |
144 | | - name: "microbadger", |
145 | | - image: "plugins/webhook:1", |
146 | | - pull: "always", |
147 | | - settings: { |
148 | | - url: { "from_secret": "microbadger_url" }, |
149 | | - }, |
150 | | - }, |
151 | | - ], |
152 | | - depends_on: [ |
153 | | - "linux-amd64", |
154 | | - "linux-arm64", |
155 | | - "linux-arm", |
156 | | - ], |
157 | | - trigger: { |
158 | | - branch: [ "master" ], |
159 | | - event: [ "push", "tag" ], |
160 | | - }, |
161 | | -}; |
| 1 | +local pipeline = import 'pipeline.libsonnet'; |
| 2 | +local name = 'drone-matrix'; |
162 | 3 |
|
163 | 4 | [ |
164 | | - PipelineTesting, |
165 | | - PipelineBuild("linux", "amd64"), |
166 | | - PipelineBuild("linux", "arm64"), |
167 | | - PipelineBuild("linux", "arm"), |
168 | | - PipelineNotifications, |
| 5 | + pipeline.test('linux', 'amd64'), |
| 6 | + pipeline.build(name, 'linux', 'amd64'), |
| 7 | + pipeline.build(name, 'linux', 'arm64'), |
| 8 | + pipeline.build(name, 'linux', 'arm'), |
| 9 | + pipeline.notifications(depends_on=[ |
| 10 | + 'linux-amd64', |
| 11 | + 'linux-arm64', |
| 12 | + 'linux-arm', |
| 13 | + ]), |
169 | 14 | ] |
0 commit comments