Skip to content

Commit 1c0aa0d

Browse files
authored
Merge pull request #136 from kubernetes-sigs/automated-builds
Standardizing makefile and adding automated builds
2 parents 154eed4 + 3543c69 commit 1c0aa0d

File tree

15 files changed

+1134
-203
lines changed

15 files changed

+1134
-203
lines changed

Makefile

Lines changed: 232 additions & 147 deletions
Large diffs are not rendered by default.

common.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export GOPROXY
4848
$(TOOLS_BIN_DIR)/%: $(TOOLS_DIR_DEPS)
4949
make -C $(TOOLS_DIR) $(subst $(TOOLS_DIR)/,,$@)
5050

51+
##@ Help
5152
## --------------------------------------
5253
## Help
5354
## --------------------------------------

controllers/controllers_suite_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,11 @@ var (
127127
AffinityGReconciler *csReconcilers.CloudStackAffinityGroupReconciler
128128
)
129129

130-
var projectDir = os.Getenv("PROJECT_DIR")
131-
132130
var _ = BeforeSuite(func() {
131+
repoRoot := os.Getenv("REPO_ROOT")
132+
133133
// Add ginkgo recover statements to controllers.
134-
cmd := exec.Command(projectDir+"/hack/testing_ginkgo_recover_statements.sh", "--contains")
134+
cmd := exec.Command(repoRoot+"/hack/testing_ginkgo_recover_statements.sh", "--contains")
135135
cmd.Stdout = os.Stdout
136136
if err := cmd.Run(); err != nil {
137137
fmt.Println(errors.Wrapf(err, "refusing to run test suite without ginkgo recover statements present"))
@@ -173,10 +173,11 @@ func (m *MockCtrlrCloudClientImplementation) RegisterExtension(r *csCtrlrUtils.R
173173
}
174174

175175
func SetupTestEnvironment() {
176-
crdPaths := []string{filepath.Join(projectDir, "config", "crd", "bases")}
176+
repoRoot := os.Getenv("REPO_ROOT")
177+
crdPaths := []string{filepath.Join(repoRoot, "config", "crd", "bases")}
177178

178179
// Append CAPI CRDs path
179-
if capiPath := getFilePathToCAPICRDs(projectDir); capiPath != "" {
180+
if capiPath := getFilePathToCAPICRDs(repoRoot); capiPath != "" {
180181
crdPaths = append(crdPaths, capiPath)
181182
}
182183
testEnv = &envtest.Environment{

hack/setup_for_dev.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Source this file for local dev.
44

55
export IMG=localhost:5000/cluster-api-provider-cloudstack:latest
6-
export PROJECT_DIR=`pwd`
7-
export KUBEBUILDER_ASSETS=$PROJECT_DIR/bin
8-
export PATH=$PROJECT_DIR/bin:$PATH
6+
export REPO_ROOT=`pwd`
7+
export KUBEBUILDER_ASSETS=$REPO_ROOT/bin
8+
export PATH=$REPO_ROOT/bin:$PATH
99
export ACK_GINKGO_DEPRECATIONS=1.16.4

hack/testing_ginkgo_recover_statements.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#!/bin/bash
22

33
# Copyright 2022.
4-
#
4+
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.
77
# You may obtain a copy of the License at
8-
#
8+
#
99
# http://www.apache.org/licenses/LICENSE-2.0
10-
#
10+
#
1111
# Unless required by applicable law or agreed to in writing, software
1212
# distributed under the License is distributed on an "AS IS" BASIS,
1313
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,11 +18,11 @@
1818
# This is necessary as the controllers are run in goroutines when tested under testenv.
1919
# Add to add, remove to remove, and contains exits 1 if the statements are missing.
2020

21-
CONTROLLER_DIR=${PROJECT_DIR:-$(dirname $(dirname "$0"))}/controllers
21+
CONTROLLER_DIR=${REPO_ROOT:-$(dirname $(dirname "$0"))}/controllers
2222
FILES=${CONTROLLER_DIR}/cloudstack*controller.go
2323

2424
case $1 in
25-
--add)
25+
--add)
2626
# Use grep to prevent double addition of ginkgo recover statements.
2727
grep -i ginkgo ${FILES} 2>&1> /dev/null \
2828
|| (sed -i.bak '/Reconcile(/a\'$'\n'$'\t''defer ginkgo.GinkgoRecover()'$'\n''' ${FILES} && \

hack/tools/Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,22 @@ CONVERSION_GEN := $(BIN_DIR)/conversion-gen
6767
$(CONVERSION_GEN): $(BIN_DIR) go.mod go.sum
6868
go build -tags=tools -o $@ k8s.io/code-generator/cmd/conversion-gen
6969

70+
GOLANGCI_LINT := $(BIN_DIR)/golangci-lint
71+
$(GOLANGCI_LINT): $(BIN_DIR) go.mod go.sum # Build golangci-lint from tools folder.
72+
go build -tags=tools -o $@ github.com/golangci/golangci-lint/cmd/golangci-lint
73+
74+
STATIC_CHECK := $(BIN_DIR)/staticcheck
75+
$(STATIC_CHECK): $(BIN_DIR) go.mod go.sum # Build staticcheck from tools folder.
76+
go build -tags=tools -o $@ honnef.co/go/tools/cmd/staticcheck
77+
78+
GINKGO_V1 := $(BIN_DIR)/ginkgo_v1
79+
$(GINKGO_V1): $(BIN_DIR) go.mod go.sum # Build staticcheck from tools folder.
80+
go build -tags=tools -o $@ github.com/onsi/ginkgo/ginkgo
81+
82+
GINKGO_V2 := $(BIN_DIR)/ginkgo_v2
83+
$(GINKGO_V2): $(BIN_DIR) go.mod go.sum # Build staticcheck from tools folder.
84+
go build -tags=tools -o $@ github.com/onsi/ginkgo/v2/ginkgo
85+
7086
ENVSUBST := $(BIN_DIR)/envsubst
7187
$(ENVSUBST): $(BIN_DIR) go.mod go.sum # Build envsubst from tools folder.
7288
go build -tags=tools -o $@ github.com/a8m/envsubst/cmd/envsubst

hack/tools/go.mod

Lines changed: 151 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ go 1.17
55
require (
66
github.com/a8m/envsubst v1.3.0
77
github.com/golang/mock v1.6.0
8+
github.com/golangci/golangci-lint v1.46.2
89
github.com/onsi/ginkgo v1.16.5
10+
github.com/onsi/ginkgo/v2 v2.1.3
11+
honnef.co/go/tools v0.3.1
912
k8s.io/code-generator v0.23.5
1013
sigs.k8s.io/cluster-api/hack/tools v0.0.0-20220329062511-822f046dac13
1114
sigs.k8s.io/controller-tools v0.8.0
@@ -14,57 +17,186 @@ require (
1417
)
1518

1619
require (
17-
github.com/BurntSushi/toml v0.4.1 // indirect
20+
4d63.com/gochecknoglobals v0.1.0 // indirect
21+
github.com/Antonboom/errname v0.1.6 // indirect
22+
github.com/Antonboom/nilnil v0.1.1 // indirect
23+
github.com/BurntSushi/toml v1.1.0 // indirect
24+
github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 // indirect
25+
github.com/GaijinEntertainment/go-exhaustruct/v2 v2.1.0 // indirect
26+
github.com/Masterminds/semver v1.5.0 // indirect
27+
github.com/OpenPeeDeeP/depguard v1.1.0 // indirect
1828
github.com/PuerkitoBio/purell v1.1.1 // indirect
1929
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
2030
github.com/alessio/shellescape v1.4.1 // indirect
31+
github.com/alexkohler/prealloc v1.0.0 // indirect
2132
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a // indirect
33+
github.com/ashanbrown/forbidigo v1.3.0 // indirect
34+
github.com/ashanbrown/makezero v1.1.1 // indirect
35+
github.com/beorn7/perks v1.0.1 // indirect
36+
github.com/bkielbasa/cyclop v1.2.0 // indirect
2237
github.com/blang/semver v3.5.1+incompatible // indirect
38+
github.com/blizzy78/varnamelen v0.8.0 // indirect
39+
github.com/bombsimon/wsl/v3 v3.3.0 // indirect
40+
github.com/breml/bidichk v0.2.3 // indirect
41+
github.com/breml/errchkjson v0.3.0 // indirect
42+
github.com/butuzov/ireturn v0.1.1 // indirect
43+
github.com/cespare/xxhash/v2 v2.1.2 // indirect
44+
github.com/charithe/durationcheck v0.0.9 // indirect
45+
github.com/chavacava/garif v0.0.0-20220316182200-5cad0b5181d4 // indirect
46+
github.com/daixiang0/gci v0.3.3 // indirect
2347
github.com/davecgh/go-spew v1.1.1 // indirect
48+
github.com/denis-tingaikin/go-header v0.4.3 // indirect
49+
github.com/esimonov/ifshort v1.0.4 // indirect
50+
github.com/ettle/strcase v0.1.1 // indirect
2451
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
2552
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
26-
github.com/fatih/color v1.12.0 // indirect
27-
github.com/fsnotify/fsnotify v1.5.1 // indirect
53+
github.com/fatih/color v1.13.0 // indirect
54+
github.com/fatih/structtag v1.2.0 // indirect
55+
github.com/firefart/nonamedreturns v1.0.1 // indirect
56+
github.com/fsnotify/fsnotify v1.5.4 // indirect
57+
github.com/fzipp/gocyclo v0.5.1 // indirect
58+
github.com/go-critic/go-critic v0.6.3 // indirect
2859
github.com/go-errors/errors v1.0.1 // indirect
2960
github.com/go-logr/logr v1.2.0 // indirect
3061
github.com/go-openapi/jsonpointer v0.19.5 // indirect
3162
github.com/go-openapi/jsonreference v0.19.5 // indirect
3263
github.com/go-openapi/swag v0.19.14 // indirect
3364
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect
65+
github.com/go-toolsmith/astcast v1.0.0 // indirect
66+
github.com/go-toolsmith/astcopy v1.0.0 // indirect
67+
github.com/go-toolsmith/astequal v1.0.1 // indirect
68+
github.com/go-toolsmith/astfmt v1.0.0 // indirect
69+
github.com/go-toolsmith/astp v1.0.0 // indirect
70+
github.com/go-toolsmith/strparse v1.0.0 // indirect
71+
github.com/go-toolsmith/typep v1.0.2 // indirect
72+
github.com/go-xmlfmt/xmlfmt v0.0.0-20191208150333-d5b6f63a941b // indirect
3473
github.com/gobuffalo/flect v0.2.4 // indirect
74+
github.com/gobwas/glob v0.2.3 // indirect
75+
github.com/gofrs/flock v0.8.1 // indirect
3576
github.com/gogo/protobuf v1.3.2 // indirect
36-
github.com/google/go-cmp v0.5.6 // indirect
77+
github.com/golang/protobuf v1.5.2 // indirect
78+
github.com/golangci/check v0.0.0-20180506172741-cfe4005ccda2 // indirect
79+
github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a // indirect
80+
github.com/golangci/go-misc v0.0.0-20220329215616-d24fe342adfe // indirect
81+
github.com/golangci/gofmt v0.0.0-20190930125516-244bba706f1a // indirect
82+
github.com/golangci/lint-1 v0.0.0-20191013205115-297bf364a8e0 // indirect
83+
github.com/golangci/maligned v0.0.0-20180506175553-b1d89398deca // indirect
84+
github.com/golangci/misspell v0.3.5 // indirect
85+
github.com/golangci/revgrep v0.0.0-20210930125155-c22e5001d4f2 // indirect
86+
github.com/golangci/unconvert v0.0.0-20180507085042-28b1c447d1f4 // indirect
87+
github.com/google/go-cmp v0.5.7 // indirect
3788
github.com/google/gofuzz v1.2.0 // indirect
89+
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect
3890
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
91+
github.com/gordonklaus/ineffassign v0.0.0-20210914165742-4cc7213b9bc8 // indirect
92+
github.com/gostaticanalysis/analysisutil v0.7.1 // indirect
93+
github.com/gostaticanalysis/comment v1.4.2 // indirect
94+
github.com/gostaticanalysis/forcetypeassert v0.1.0 // indirect
95+
github.com/gostaticanalysis/nilerr v0.1.1 // indirect
96+
github.com/hashicorp/errwrap v1.0.0 // indirect
97+
github.com/hashicorp/go-multierror v1.1.1 // indirect
98+
github.com/hashicorp/go-version v1.4.0 // indirect
99+
github.com/hashicorp/hcl v1.0.0 // indirect
100+
github.com/hexops/gotextdiff v1.0.3 // indirect
39101
github.com/imdario/mergo v0.3.12 // indirect
40102
github.com/inconshreveable/mousetrap v1.0.0 // indirect
103+
github.com/jgautheron/goconst v1.5.1 // indirect
104+
github.com/jingyugao/rowserrcheck v1.1.1 // indirect
105+
github.com/jirfag/go-printf-func-name v0.0.0-20200119135958-7558a9eaa5af // indirect
41106
github.com/josharian/intern v1.0.0 // indirect
42107
github.com/json-iterator/go v1.1.12 // indirect
108+
github.com/julz/importas v0.1.0 // indirect
109+
github.com/kisielk/errcheck v1.6.0 // indirect
110+
github.com/kisielk/gotool v1.0.0 // indirect
111+
github.com/kulti/thelper v0.6.2 // indirect
112+
github.com/kunwardeep/paralleltest v1.0.3 // indirect
113+
github.com/kyoh86/exportloopref v0.1.8 // indirect
114+
github.com/ldez/gomoddirectives v0.2.3 // indirect
115+
github.com/ldez/tagliatelle v0.3.1 // indirect
116+
github.com/leonklingele/grouper v1.1.0 // indirect
117+
github.com/lufeee/execinquery v1.2.1 // indirect
118+
github.com/magiconair/properties v1.8.6 // indirect
43119
github.com/mailru/easyjson v0.7.6 // indirect
44-
github.com/mattn/go-colorable v0.1.8 // indirect
120+
github.com/maratori/testpackage v1.0.1 // indirect
121+
github.com/matoous/godox v0.0.0-20210227103229-6504466cf951 // indirect
122+
github.com/mattn/go-colorable v0.1.12 // indirect
45123
github.com/mattn/go-isatty v0.0.14 // indirect
46-
github.com/mattn/go-runewidth v0.0.7 // indirect
47-
github.com/mitchellh/mapstructure v1.4.3 // indirect
124+
github.com/mattn/go-runewidth v0.0.9 // indirect
125+
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
126+
github.com/mbilski/exhaustivestruct v1.2.0 // indirect
127+
github.com/mgechev/revive v1.2.1 // indirect
128+
github.com/mitchellh/go-homedir v1.1.0 // indirect
129+
github.com/mitchellh/mapstructure v1.5.0 // indirect
48130
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
49131
github.com/modern-go/reflect2 v1.0.2 // indirect
50132
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
133+
github.com/moricho/tparallel v0.2.1 // indirect
134+
github.com/nakabonne/nestif v0.3.1 // indirect
135+
github.com/nbutton23/zxcvbn-go v0.0.0-20210217022336-fa2cb2858354 // indirect
136+
github.com/nishanths/exhaustive v0.7.11 // indirect
137+
github.com/nishanths/predeclared v0.2.2 // indirect
51138
github.com/nxadm/tail v1.4.8 // indirect
52-
github.com/olekukonko/tablewriter v0.0.4 // indirect
53-
github.com/pelletier/go-toml v1.9.4 // indirect
139+
github.com/olekukonko/tablewriter v0.0.5 // indirect
140+
github.com/pelletier/go-toml v1.9.5 // indirect
141+
github.com/pelletier/go-toml/v2 v2.0.0 // indirect
142+
github.com/phayes/checkstyle v0.0.0-20170904204023-bfd46e6a821d // indirect
54143
github.com/pkg/errors v0.9.1 // indirect
55144
github.com/pmezard/go-difflib v1.0.0 // indirect
145+
github.com/polyfloyd/go-errorlint v1.0.0 // indirect
146+
github.com/prometheus/client_golang v1.12.1 // indirect
147+
github.com/prometheus/client_model v0.2.0 // indirect
148+
github.com/prometheus/common v0.32.1 // indirect
149+
github.com/prometheus/procfs v0.7.3 // indirect
150+
github.com/quasilyte/go-ruleguard v0.3.16-0.20220213074421-6aa060fab41a // indirect
151+
github.com/quasilyte/gogrep v0.0.0-20220120141003-628d8b3623b5 // indirect
152+
github.com/quasilyte/regex/syntax v0.0.0-20200407221936-30656e2c4a95 // indirect
153+
github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 // indirect
154+
github.com/ryancurrah/gomodguard v1.2.3 // indirect
155+
github.com/ryanrolds/sqlclosecheck v0.3.0 // indirect
156+
github.com/sanposhiho/wastedassign/v2 v2.0.6 // indirect
157+
github.com/securego/gosec/v2 v2.11.0 // indirect
158+
github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c // indirect
159+
github.com/sirupsen/logrus v1.8.1 // indirect
160+
github.com/sivchari/containedctx v1.0.2 // indirect
161+
github.com/sivchari/tenv v1.5.0 // indirect
162+
github.com/sonatard/noctx v0.0.1 // indirect
163+
github.com/sourcegraph/go-diff v0.6.1 // indirect
164+
github.com/spf13/afero v1.8.2 // indirect
165+
github.com/spf13/cast v1.4.1 // indirect
56166
github.com/spf13/cobra v1.4.0 // indirect
167+
github.com/spf13/jwalterweatherman v1.1.0 // indirect
57168
github.com/spf13/pflag v1.0.5 // indirect
58-
github.com/stretchr/testify v1.7.0 // indirect
169+
github.com/spf13/viper v1.11.0 // indirect
170+
github.com/ssgreg/nlreturn/v2 v2.2.1 // indirect
171+
github.com/stbenjam/no-sprintf-host-port v0.1.1 // indirect
172+
github.com/stretchr/objx v0.2.0 // indirect
173+
github.com/stretchr/testify v1.7.1 // indirect
174+
github.com/subosito/gotenv v1.2.0 // indirect
175+
github.com/sylvia7788/contextcheck v1.0.4 // indirect
176+
github.com/tdakkota/asciicheck v0.1.1 // indirect
177+
github.com/tetafro/godot v1.4.11 // indirect
178+
github.com/timakin/bodyclose v0.0.0-20210704033933-f49887972144 // indirect
179+
github.com/tomarrell/wrapcheck/v2 v2.6.1 // indirect
180+
github.com/tommy-muehle/go-mnd/v2 v2.5.0 // indirect
181+
github.com/ultraware/funlen v0.0.3 // indirect
182+
github.com/ultraware/whitespace v0.0.5 // indirect
183+
github.com/uudashr/gocognit v1.0.5 // indirect
59184
github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca // indirect
185+
github.com/yagipy/maintidx v1.0.0 // indirect
186+
github.com/yeya24/promlinter v0.2.0 // indirect
187+
gitlab.com/bosi/decorder v0.2.1 // indirect
60188
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect
61-
golang.org/x/mod v0.6.0-dev.0.20211013180041-c96bc1413d57 // indirect
62-
golang.org/x/net v0.0.0-20211209124913-491a49abca63 // indirect
63-
golang.org/x/sys v0.0.0-20211210111614-af8b64212486 // indirect
189+
golang.org/x/exp/typeparams v0.0.0-20220218215828-6cf2b201936e // indirect
190+
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect
191+
golang.org/x/net v0.0.0-20220412020605-290c469a71a5 // indirect
192+
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
193+
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 // indirect
64194
golang.org/x/text v0.3.7 // indirect
65-
golang.org/x/tools v0.1.8-0.20211029000441-d6a9af8af023 // indirect
66-
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
195+
golang.org/x/tools v0.1.11-0.20220316014157-77aa08bb151a // indirect
196+
golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f // indirect
197+
google.golang.org/protobuf v1.28.0 // indirect
67198
gopkg.in/inf.v0 v0.9.1 // indirect
199+
gopkg.in/ini.v1 v1.66.4 // indirect
68200
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
69201
gopkg.in/yaml.v2 v2.4.0 // indirect
70202
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
@@ -75,6 +207,10 @@ require (
75207
k8s.io/klog/v2 v2.30.0 // indirect
76208
k8s.io/kube-openapi v0.0.0-20211115234752-e816edb12b65 // indirect
77209
k8s.io/utils v0.0.0-20210930125809-cb0fa318a74b // indirect
210+
mvdan.cc/gofumpt v0.3.1 // indirect
211+
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed // indirect
212+
mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b // indirect
213+
mvdan.cc/unparam v0.0.0-20211214103731-d0ef000c54e5 // indirect
78214
sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6 // indirect
79215
sigs.k8s.io/kubebuilder/docs/book/utils v0.0.0-20211028165026-57688c578b5d // indirect
80216
sigs.k8s.io/kustomize/api v0.11.4 // indirect

0 commit comments

Comments
 (0)