Skip to content

Commit 320def8

Browse files
committed
Enable make ci (#21)
Signed-off-by: Tamal Saha <tamal@appscode.com>
1 parent 9a7b843 commit 320def8

File tree

104 files changed

+552
-253
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+552
-253
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919

2020
- name: Set up Docker Buildx
2121
id: buildx
22-
uses: crazy-max/ghaction-docker-buildx@master
22+
uses: crazy-max/ghaction-docker-buildx@v1
2323
with:
2424
version: latest
2525

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
2424
- name: Set up Docker Buildx
2525
id: buildx
26-
uses: crazy-max/ghaction-docker-buildx@master
26+
uses: crazy-max/ghaction-docker-buildx@v1
2727
with:
2828
version: latest
2929

Makefile

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515

1616
SHELL=/bin/bash -o pipefail
1717

18-
# The binary to build (just the basename).
18+
GO_PKG := stash.appscode.dev
19+
REPO := $(notdir $(shell pwd))
1920
BIN := stash-postgres
2021
COMPRESS ?= no
2122

@@ -50,7 +51,8 @@ NEW_RESTIC_VER := 0.9.5
5051
### These variables should not need tweaking.
5152
###
5253

53-
SRC_DIRS := cmd pkg # directories which hold app source (not vendored)
54+
SRC_PKGS := cmd pkg
55+
SRC_DIRS := $(SRC_PKGS) # directories which hold app source (not vendored)
5456

5557
DOCKER_PLATFORMS := linux/amd64 linux/arm linux/arm64
5658
BIN_PLATFORMS := $(DOCKER_PLATFORMS)
@@ -81,6 +83,7 @@ endif
8183
BUILD_DIRS := bin/$(OS)_$(ARCH) \
8284
.go/bin/$(OS)_$(ARCH) \
8385
.go/cache \
86+
hack/config \
8487
$(HOME)/.credentials \
8588
$(HOME)/.kube \
8689
$(HOME)/.minikube
@@ -144,7 +147,10 @@ fmt: $(BUILD_DIRS)
144147
--env HTTP_PROXY=$(HTTP_PROXY) \
145148
--env HTTPS_PROXY=$(HTTPS_PROXY) \
146149
$(BUILD_IMAGE) \
147-
./hack/fmt.sh $(SRC_DIRS)
150+
/bin/bash -c " \
151+
REPO_PKG=$(GO_PKG) \
152+
./hack/fmt.sh $(SRC_DIRS) \
153+
"
148154

149155
build: $(OUTBIN)
150156

@@ -234,7 +240,10 @@ docker-manifest-%:
234240
DOCKER_CLI_EXPERIMENTAL=enabled docker manifest create -a $(IMAGE):$(VERSION_$*) $(foreach PLATFORM,$(DOCKER_PLATFORMS),$(IMAGE):$(VERSION_$*)_$(subst /,_,$(PLATFORM)))
235241
DOCKER_CLI_EXPERIMENTAL=enabled docker manifest push $(IMAGE):$(VERSION_$*)
236242

237-
test: $(BUILD_DIRS)
243+
.PHONY: test
244+
test: unit-tests
245+
246+
unit-tests: $(BUILD_DIRS)
238247
@docker run \
239248
-i \
240249
--rm \
@@ -273,16 +282,33 @@ lint: $(BUILD_DIRS)
273282
--env GO111MODULE=on \
274283
--env GOFLAGS="-mod=vendor" \
275284
$(BUILD_IMAGE) \
276-
golangci-lint run --enable $(ADDTL_LINTERS) --deadline=10m --skip-files="generated.*\.go$\" --skip-dirs-use-default --skip-dirs=client,vendor
285+
golangci-lint run --enable $(ADDTL_LINTERS) --deadline=10m --skip-files="generated.*\.go$\" --skip-dirs-use-default
277286

278287
$(BUILD_DIRS):
279288
@mkdir -p $@
280289

281290
.PHONY: dev
282291
dev: gen fmt push
283292

293+
.PHONY: verify
294+
verify: verify-modules verify-gen
295+
296+
.PHONY: verify-modules
297+
verify-modules:
298+
GO111MODULE=on go mod tidy
299+
GO111MODULE=on go mod vendor
300+
@if !(git diff --exit-code HEAD); then \
301+
echo "go module files are out of date"; exit 1; \
302+
fi
303+
304+
.PHONY: verify-gen
305+
verify-gen: gen fmt
306+
@if !(git diff --exit-code HEAD); then \
307+
echo "files are out of date, run make gen fmt"; exit 1; \
308+
fi
309+
284310
.PHONY: ci
285-
ci: lint test build #cover
311+
ci: verify lint build unit-tests #cover
286312

287313
.PHONY: qa
288314
qa:

cmd/stash-postgres/main.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ import (
44
"os"
55
"runtime"
66

7+
"stash.appscode.dev/postgres/pkg"
8+
_ "stash.appscode.dev/stash/client/clientset/versioned/fake"
9+
710
"github.com/appscode/go/log"
811
_ "k8s.io/client-go/kubernetes/fake"
912
_ "k8s.io/client-go/plugin/pkg/client/auth"
1013
"kmodules.xyz/client-go/logs"
11-
"stash.appscode.dev/postgres/pkg"
12-
_ "stash.appscode.dev/stash/client/clientset/versioned/fake"
1314
)
1415

1516
func main() {

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ require (
77
github.com/spf13/cobra v0.0.5
88
k8s.io/apimachinery v0.0.0-20190508063446-a3da69d3723c
99
k8s.io/client-go v11.0.0+incompatible
10-
kmodules.xyz/client-go v0.0.0-20191016085444-3044854ca625
10+
kmodules.xyz/client-go v0.0.0-20191023042933-b12d1ccfaf57
1111
kmodules.xyz/custom-resources v0.0.0-20190927035424-65fe358bb045
12-
stash.appscode.dev/stash v0.9.0-rc.1.0.20191018180359-9ef3cfeba2a2
12+
stash.appscode.dev/stash v0.9.0-rc.2
1313
)
1414

1515
replace (
@@ -26,6 +26,6 @@ replace (
2626
k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30
2727
k8s.io/kubernetes => k8s.io/kubernetes v1.14.0
2828
k8s.io/metrics => k8s.io/metrics v0.0.0-20190314001731-1bd6a4002213
29-
k8s.io/utils => k8s.io/utils v0.0.0-20190221042446-c2654d5206da
29+
k8s.io/utils => k8s.io/utils v0.0.0-20190514214443-0a167cbac756
3030
sigs.k8s.io/structured-merge-diff => sigs.k8s.io/structured-merge-diff v0.0.0-20190302045857-e85c7b244fd2
3131
)

go.sum

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAm
264264
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
265265
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
266266
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
267+
github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
267268
github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
268269
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
269270
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
@@ -370,6 +371,7 @@ gomodules.xyz/envsubst v0.1.0/go.mod h1:2o5f7bd13XIITbE2ZKieE05YkqB2KDoZkqKccGeb
370371
gomodules.xyz/jsonpatch/v2 v2.0.0 h1:OyHbl+7IOECpPKfVK42oFr6N7+Y2dR+Jsb/IiDV3hOo=
371372
gomodules.xyz/jsonpatch/v2 v2.0.0/go.mod h1:IhYNNY4jnS53ZnfE4PAmpKtDpTCj1JFXc+3mwe7XcUU=
372373
gomodules.xyz/stow v0.2.0/go.mod h1:YDDPM4nmJgQhxq4I5aGtLM/xrvJzDSVM/fbc7NGizpY=
374+
gomodules.xyz/stow v0.2.2/go.mod h1:YDDPM4nmJgQhxq4I5aGtLM/xrvJzDSVM/fbc7NGizpY=
373375
gomodules.xyz/version v0.0.0-20190507203204-7cec7ee542d3/go.mod h1:Y8xuV02mL/45psyPKG3NCVOwvAOy6T5Kx0l3rCjKSjU=
374376
gomodules.xyz/version v0.1.0 h1:inGItCg/egI0jPMeIE0SQkiDIJaodOMoCrxYqasQLR0=
375377
gomodules.xyz/version v0.1.0/go.mod h1:Y8xuV02mL/45psyPKG3NCVOwvAOy6T5Kx0l3rCjKSjU=
@@ -433,11 +435,12 @@ k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30 h1:TRb4wNWoBVrH9plmkp2q86
433435
k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc=
434436
k8s.io/kubernetes v1.14.0 h1:6T2iAEoOYQnzQb3WvPlUkcczEEXZ7+YPlAO8olwujRw=
435437
k8s.io/kubernetes v1.14.0/go.mod h1:ocZa8+6APFNC2tX1DZASIbocyYT5jHzqFVsY5aoB7Jk=
436-
k8s.io/utils v0.0.0-20190221042446-c2654d5206da h1:ElyM7RPonbKnQqOcw7dG2IK5uvQQn3b/WPHqD5mBvP4=
437-
k8s.io/utils v0.0.0-20190221042446-c2654d5206da/go.mod h1:8k8uAuAQ0rXslZKaEWd0c3oVhZz7sSzSiPnVZayjIX0=
438+
k8s.io/utils v0.0.0-20190514214443-0a167cbac756 h1:2XBbostlqrw13zVYimyqcj/Om2P4B26oMzv+m2cj//k=
439+
k8s.io/utils v0.0.0-20190514214443-0a167cbac756/go.mod h1:8k8uAuAQ0rXslZKaEWd0c3oVhZz7sSzSiPnVZayjIX0=
438440
kmodules.xyz/client-go v0.0.0-20190808141354-bbb9e14f60ab/go.mod h1:1GI6h5D31op/2D+Hrn9DhXW6iUd5wsHBQRoLeY7fndM=
439-
kmodules.xyz/client-go v0.0.0-20191016085444-3044854ca625 h1:A/ceKV+HXdheKSpaY2CF7Q70E/iDKoysxiWtAuYMXyE=
440-
kmodules.xyz/client-go v0.0.0-20191016085444-3044854ca625/go.mod h1:wFUBDofZzgkLW1sFJT5SSt6/G3ph2P8zUi5v81q5BKQ=
441+
kmodules.xyz/client-go v0.0.0-20191023042933-b12d1ccfaf57 h1:4IsITvsVOl0W8IRABEMOqEMyJYwTCmhmfpJVIpwD4lM=
442+
kmodules.xyz/client-go v0.0.0-20191023042933-b12d1ccfaf57/go.mod h1:BChXGI3zd3lNSjUUfDcGmvufMdqrofLI/nrndcZ4LUo=
443+
kmodules.xyz/constants v0.0.0-20191009183447-fbd33067b8a6/go.mod h1:DbiFk1bJ1KEO94t1SlAn7tzc+Zz95rSXgyUKa2nzPmY=
441444
kmodules.xyz/custom-resources v0.0.0-20190927035424-65fe358bb045 h1:DuvD64ouPDbv3egAUUCy5rBqs/vc218DeVVivcqfa+U=
442445
kmodules.xyz/custom-resources v0.0.0-20190927035424-65fe358bb045/go.mod h1:vlKyFcCXC+2Kfn3Fa5Z7RnBWyp4t46FSeEutNqpqMm8=
443446
kmodules.xyz/objectstore-api v0.0.0-20191014210450-ac380fa650a3 h1:64QSexLk/Dio4+L8Ge1tb4c44aBiwmUwTNP2kCu6YQU=
@@ -453,5 +456,5 @@ sigs.k8s.io/kustomize v2.0.3+incompatible/go.mod h1:MkjgH3RdOWrievjo6c9T245dYlB5
453456
sigs.k8s.io/structured-merge-diff v0.0.0-20190302045857-e85c7b244fd2/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI=
454457
sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs=
455458
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
456-
stash.appscode.dev/stash v0.9.0-rc.1.0.20191018180359-9ef3cfeba2a2 h1:H2a7zLOI7Q6OxHuI8gzQKYJx/BPREOgQjbkVCLVUXYY=
457-
stash.appscode.dev/stash v0.9.0-rc.1.0.20191018180359-9ef3cfeba2a2/go.mod h1:N8pJqTaV01TZpspiGEGfRBkJTNHkJ0ihflN0LYx3wPw=
459+
stash.appscode.dev/stash v0.9.0-rc.2 h1:oZTmaDDTjANefmsNWYjqb0cqZYGl4JAeiewAlJJPnlE=
460+
stash.appscode.dev/stash v0.9.0-rc.2/go.mod h1:DgbSJa5P8tV+V9dX/CxURZDnudLvgnKyuZksJF/Fp7Q=

hack/fmt.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export GOFLAGS="-mod=vendor"
2323
TARGETS="$@"
2424

2525
echo "Running reimport.py"
26-
cmd="reimport.py ${TARGETS}"
26+
cmd="reimport3.py ${REPO_PKG} ${TARGETS}"
2727
$cmd
2828
echo
2929

pkg/backup.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@ import (
44
"path/filepath"
55
"strings"
66

7+
api_v1beta1 "stash.appscode.dev/stash/apis/stash/v1beta1"
8+
"stash.appscode.dev/stash/pkg/restic"
9+
"stash.appscode.dev/stash/pkg/util"
10+
711
"github.com/appscode/go/flags"
812
"github.com/spf13/cobra"
913
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1014
"k8s.io/client-go/kubernetes"
1115
"k8s.io/client-go/tools/clientcmd"
1216
appcatalog_cs "kmodules.xyz/custom-resources/client/clientset/versioned"
13-
api_v1beta1 "stash.appscode.dev/stash/apis/stash/v1beta1"
14-
"stash.appscode.dev/stash/pkg/restic"
15-
"stash.appscode.dev/stash/pkg/util"
1617
)
1718

1819
func NewCmdBackup() *cobra.Command {

pkg/restore.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@ import (
44
"path/filepath"
55
"strings"
66

7+
api_v1beta1 "stash.appscode.dev/stash/apis/stash/v1beta1"
8+
"stash.appscode.dev/stash/pkg/restic"
9+
"stash.appscode.dev/stash/pkg/util"
10+
711
"github.com/appscode/go/flags"
812
"github.com/spf13/cobra"
913
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1014
"k8s.io/client-go/kubernetes"
1115
"k8s.io/client-go/tools/clientcmd"
1216
appcatalog_cs "kmodules.xyz/custom-resources/client/clientset/versioned"
13-
api_v1beta1 "stash.appscode.dev/stash/apis/stash/v1beta1"
14-
"stash.appscode.dev/stash/pkg/restic"
15-
"stash.appscode.dev/stash/pkg/util"
1617
)
1718

1819
func NewCmdRestore() *cobra.Command {

pkg/root.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ package pkg
33
import (
44
"flag"
55

6+
"stash.appscode.dev/stash/client/clientset/versioned/scheme"
7+
"stash.appscode.dev/stash/pkg/util"
8+
69
"github.com/appscode/go/flags"
710
v "github.com/appscode/go/version"
811
"github.com/spf13/cobra"
912
clientsetscheme "k8s.io/client-go/kubernetes/scheme"
1013
"kmodules.xyz/client-go/logs"
1114
"kmodules.xyz/client-go/tools/cli"
12-
"stash.appscode.dev/stash/client/clientset/versioned/scheme"
13-
"stash.appscode.dev/stash/pkg/util"
1415
)
1516

1617
func NewRootCmd() *cobra.Command {

0 commit comments

Comments
 (0)