-
Notifications
You must be signed in to change notification settings - Fork 5
/
.drone.yml
190 lines (180 loc) · 5.24 KB
/
.drone.yml
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
# Copyright (c) 2017-present SIGHUP s.r.l All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
kind: pipeline
type: docker
name: main
steps:
- name: prepare
image: quay.io/sighup/golang:1.23.2
pull: always
depends_on:
- clone
commands:
- mkdir -p .go/cache .go/modcache .go/tmp
- go mod download
environment:
CGO_ENABLED: 0
GOCACHE: /drone/src/.go/cache
GOMODCACHE: /drone/src/.go/modcache
GOTMPDIR: /drone/src/.go/tmp
- name: license
image: quay.io/sighup/golang:1.23.2
pull: always
depends_on:
- prepare
commands:
- make license-check
environment:
CGO_ENABLED: 0
GOCACHE: /drone/src/.go/cache
GOMODCACHE: /drone/src/.go/modcache
GOTMPDIR: /drone/src/.go/tmp
- name: lint
image: quay.io/sighup/golang:1.23.2
pull: always
depends_on:
- prepare
commands:
- make lint
environment:
CGO_ENABLED: 0
GOCACHE: /drone/src/.go/cache
GOMODCACHE: /drone/src/.go/modcache
GOTMPDIR: /drone/src/.go/tmp
- name: test-unit
image: quay.io/sighup/golang:1.23.2
pull: always
depends_on:
- prepare
commands:
- make test-unit
environment:
CGO_ENABLED: 0
GOCACHE: /drone/src/.go/cache
GOMODCACHE: /drone/src/.go/modcache
GOTMPDIR: /drone/src/.go/tmp
- name: test-integration
image: quay.io/sighup/golang:1.23.2
pull: always
depends_on:
- prepare
commands:
- echo $${NETRC_FILE} > /root/.netrc
- make test-integration
environment:
CGO_ENABLED: 0
GOCACHE: /drone/src/.go/cache
GOMODCACHE: /drone/src/.go/modcache
GOTMPDIR: /drone/src/.go/tmp
NETRC_FILE:
from_secret: NETRC_FILE
- name: test-e2e
image: debian:bookworm-slim # using debian to install aws-cli as go:1.22.0 images have issues with aws-cli
depends_on:
- prepare
commands:
- apt update
- apt install -y curl git make ssh unzip
# Install Golang & deps
- curl -sL https://go.dev/dl/go1.23.2.linux-amd64.tar.gz -o go1.23.2.tar.gz
- rm -rf /usr/local/go && tar -C /usr/local -xzf go1.23.2.tar.gz
- echo 'export PATH=$$PATH:/usr/local/go/bin:/root/go/bin' >> /etc/profile
- export PATH=$$PATH:/usr/local/go/bin:/root/go/bin
- go install github.com/onsi/ginkgo/v2/ginkgo@v2.15.0
# Install aws-cli
- curl -sL https://awscli.amazonaws.com/awscli-exe-linux-x86_64-$${AWSCLI_VERSION}.zip -o awscliv2.zip
- unzip awscliv2.zip
- aws/install
- rm -rf aws/
# Setup SSH
- mkdir -p /root/.ssh
- echo "$${GITHUB_SSH}" | tr -d '\r' | sed -e '$a\' > /root/.ssh/id_rsa
- echo $${NETRC_FILE} > /root/.netrc
- chmod 600 /root/.ssh/id_rsa
- touch /root/.ssh/known_hosts
- chmod 600 /root/.ssh/known_hosts
- mkdir -p /etc/ssh
- ssh-keyscan -H github.com > /etc/ssh/ssh_known_hosts 2> /dev/null
# Create required s3 bucket if it doesn't exist
- (test ! $(aws s3api get-bucket-location --bucket $${TERRAFORM_TF_STATES_BUCKET_NAME} --output text --no-cli-pager 2>/dev/null | grep "$${AWS_DEFAULT_REGION}")) && aws s3 mb s3://$${TERRAFORM_TF_STATES_BUCKET_NAME} --region $${AWS_DEFAULT_REGION}
# Run tests
- make test-e2e
# Cleanup
- rm go1.23.2.tar.gz
- rm awscliv2.zip
environment:
CGO_ENABLED: 0
GOCACHE: /drone/src/.go/cache
GOMODCACHE: /drone/src/.go/modcache
GOTMPDIR: /drone/src/.go/tmp
AWSCLI_VERSION: 2.15.17
AWS_ACCESS_KEY_ID:
from_secret: AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY:
from_secret: AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION:
from_secret: AWS_REGION
FURYCTL_MIXPANEL_TOKEN:
from_secret: FURYCTL_MIXPANEL_TOKEN
NETRC_FILE:
from_secret: NETRC_FILE
GITHUB_SSH:
from_secret: GITHUB_SSH
TERRAFORM_TF_STATES_BUCKET_NAME:
from_secret: TERRAFORM_TF_STATES_BUCKET_NAME
- name: build
image: quay.io/sighup/golang:1.23.2
pull: always
depends_on:
- lint
- test-unit
- test-integration
- test-e2e
commands:
- git reset --hard
- git fetch --tags
- make build
when:
ref:
exclude:
- refs/tags/v**
environment:
CGO_ENABLED: 0
GOCACHE: /drone/src/.go/cache
GOMODCACHE: /drone/src/.go/modcache
GOTMPDIR: /drone/src/.go/tmp
FURYCTL_MIXPANEL_TOKEN:
from_secret: FURYCTL_MIXPANEL_TOKEN
GITHUB_TOKEN:
from_secret: GITHUB_TOKEN
- name: build-release
image: quay.io/sighup/golang:1.23.2
pull: always
depends_on:
- lint
- test-unit
- test-integration
- test-e2e
commands:
- git reset --hard
- git fetch --tags
- make release
when:
ref:
include:
- refs/tags/v**
environment:
CGO_ENABLED: 0
GOCACHE: /drone/src/.go/cache
GOMODCACHE: /drone/src/.go/modcache
GOTMPDIR: /drone/src/.go/tmp
FURYCTL_MIXPANEL_TOKEN:
from_secret: FURYCTL_MIXPANEL_TOKEN
GITHUB_TOKEN:
from_secret: GITHUB_TOKEN
trigger:
event:
exclude:
- pull_request
- promote