-
Notifications
You must be signed in to change notification settings - Fork 8
251 lines (220 loc) · 7.39 KB
/
cicd-build.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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
name: Classic CI/CD
on:
push:
branches:
- "**"
tags-ignore:
- "*.*"
pull_request:
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.14
id: go
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.8"
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install MarkdownPP mkdocs
- name: Install dependencies
run: |
cd ./documentation && go run mage.go -v GenerateDocumation
- uses: EndBug/add-and-commit@v5 # You can change this to use a specific version
if: github.event_name != 'pull_request'
with:
add: 'docs --force --ignore-errors'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: EndBug/add-and-commit@v5 # You can change this to use a specific version
if: github.event_name != 'pull_request'
with:
add: 'documentation/provider_doc --force --ignore-errors'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: install golangci-lint
run: |
curl -sSfL \
https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh \
| sh -s -- -b $(go env GOPATH)/bin v1.30.0
- name: Generate Sources from Swagger Spec
run: |
make generate
- name: execute the Tests
run: |
make test
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: build --rm-dist --snapshot
- name: Upload terraform provider
uses: actions/upload-artifact@v2
with:
name: provider
path: dist/*
acc:
name: Acception Tests
runs-on: ubuntu-latest
strategy:
matrix:
harbor_deployments:
- helm_chart_version: 1.4.0
harbor_path: "/api/v2.0"
- helm_chart_version: 1.4.1
harbor_path: "/api/v2.0"
# TODO: https://github.com/nolte/terraform-provider-harbor/issues/40
#- helm_chart_version: 1.3.2
# harbor_path: "/api"
env:
HARBOR_HELM_CHART_VERSION: ${{ matrix.harbor_deployments.helm_chart_version }}
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.14
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: Generate Api Client from Swagger Spac
run: |
make generate
# https://github.com/engineerd/setup-kind
- uses: engineerd/[email protected]
with:
skipClusterCreation: true
- name: Starting the Kind Cluster
run: |
make e2e_prepare
- name: configure kind kubeconfig
run: |
kind export kubeconfig
kubectl cluster-info
kubectl get pods -n kube-system
NODEDNSNAME=$(kubectl get nodes -ojson | jq '.items[0].status.addresses[0].address' -r | sed 's/\./-/g')
echo "::set-env name=INGRESS_DOMAIN::${NODEDNSNAME}.sslip.io"
echo "current-context:" $(kubectl config current-context)
echo "environment-kubeconfig:" ${KUBECONFIG}
- name: install helm3
run: |
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
- name: install harbor
run: |
cd ./tools && go run mage.go -v testArtefacts:deploy
- name: Starting the Acc
run: |
./scripts/tst-15-execute-go-acc.sh "${{ matrix.harbor_deployments.harbor_path }}"
- name: remove the kind cluster
if: ${{ always() }}
run: |
kind delete cluster
acc_terratest:
name: acc-terratest
runs-on: ubuntu-latest
needs: build
#env:
# TF_LOG: TRACE
strategy:
# Workarround, otherwithe the the different matrix jobs faild.
# max-parallel: 1
fail-fast: false
matrix:
terraform_versions:
# - 0.11.14 Out of Support
# <0.12.29 Out of automatical test scope ...
# missing helper methodes, and v0.13 provider file system Structure.
#- version: 0.12.25
- version: 0.12.29
- version: 0.13.0
- version: 0.13.4
harbor_deployments:
- helm_chart_version: 1.4.0
harbor_path: "/api/v2.0"
- helm_chart_version: 1.4.1
harbor_path: "/api/v2.0"
- helm_chart_version: 1.3.2
harbor_path: "/api"
env:
HARBOR_HELM_CHART_VERSION: ${{ matrix.harbor_deployments.helm_chart_version }}
TF_VERSION: ${{ matrix.terraform_versions.version }}
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.14
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: Download terraform provider binary
uses: actions/download-artifact@v2
with:
name: provider
path: dist
- name: Setup Terraform
uses: hashicorp/[email protected]
with:
terraform_version: ${{ matrix.terraform_versions.version }}
- name: debuggin
run: |
terraform version -json
- name: install the provider to local terraform.d folder
run: |
make install
# https://github.com/engineerd/setup-kind
- uses: engineerd/[email protected]
with:
skipClusterCreation: true
- name: Starting the Kind Cluster
run: |
make e2e_prepare
- name: configure kind kubeconfig
run: |
kind export kubeconfig
kubectl cluster-info
kubectl get pods -n kube-system
NODEDNSNAME=$(kubectl get nodes -ojson | jq '.items[0].status.addresses[0].address' -r | sed 's/\./-/g')
echo "::set-env name=INGRESS_DOMAIN::${NODEDNSNAME}.sslip.io"
echo "current-context:" $(kubectl config current-context)
echo "environment-kubeconfig:" ${KUBECONFIG}
- name: install helm3
run: |
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
- name: install harbor
run: |
cd ./tools && go run mage.go -v testArtefacts:deploy
#- name: install harbor
# run: |
# echo "::set-env name=INGRESS_DOMAIN::harbor.${NODEDNSNAME}.sslip.io"
- name: Wait some Time
run: |
sleep 30
- name: Starting the Acc
run: |
./scripts/tst-15-execute-classic-acc.sh "${{ matrix.harbor_deployments.harbor_path }}"
- name: read harbor logs core
if: ${{ failure() }}
run: |
kubectl logs -l component=core -n harbor --tail=-1
- name: read harbor logs jobservice
if: ${{ failure() }}
run: |
kubectl logs -l component=jobservice -n harbor --tail=-1
- name: remove the kind cluster
if: ${{ always() }}
run: |
kind delete cluster