Skip to content

Commit 97a6c85

Browse files
authored
add GitHubActions to run lint and tests (#7)
1 parent c32b0ea commit 97a6c85

File tree

11 files changed

+2417
-17
lines changed

11 files changed

+2417
-17
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: manifests-up-to-date
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize]
6+
7+
jobs:
8+
manifests-up-to-date:
9+
name: Manifests up-to-date check
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Set up Go 1.20
13+
uses: actions/[email protected]
14+
with:
15+
go-version: "1.20"
16+
id: go
17+
- name: Check out code into the Go module directory
18+
uses: actions/checkout@v3
19+
- name: Restore cache
20+
uses: actions/[email protected]
21+
with:
22+
path: |
23+
~/.cache/go-build
24+
~/go/pkg/mod
25+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
26+
restore-keys: |
27+
${{ runner.os }}-go-
28+
- name: Get dependencies
29+
run: |
30+
go mod download
31+
- name: Generate
32+
run: make manifests
33+
- name: Check diff
34+
run: git diff --exit-code -- config

.github/workflows/test.yaml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: test
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize]
6+
7+
jobs:
8+
test:
9+
name: Test
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Set up Go 1.20
13+
uses: actions/[email protected]
14+
with:
15+
go-version: "1.20"
16+
id: go
17+
- name: Check out code into the Go module directory
18+
uses: actions/checkout@v3
19+
- name: Restore cache
20+
uses: actions/[email protected]
21+
with:
22+
path: |
23+
~/.cache/go-build
24+
~/go/pkg/mod
25+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
26+
restore-keys: |
27+
${{ runner.os }}-go-
28+
- name: Get dependencies
29+
run: |
30+
go mod download
31+
- name: Build
32+
run: make build
33+
- name: Test
34+
run: make test
35+
- name: Lint
36+
run: make lint

Makefile

+14
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,17 @@ $(CONTROLLER_GEN): $(LOCALBIN)
130130
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
131131
$(ENVTEST): $(LOCALBIN)
132132
test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
133+
134+
## Install tools
135+
.PHONY: dependencies
136+
dependencies:
137+
@./scripts/dependencies.sh
138+
139+
.PHONY: lint
140+
lint:
141+
golangci-lint run $(args) ./...
142+
143+
.PHONY: lint-fix
144+
lint-fix:
145+
# Note: gci's autofix on golangci-lint was disabled. We can remove this if that is enabled again.
146+
@make lint args='--fix -v' cons_args='-v'

go.mod

+16-14
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,20 @@ module github.com/sanposhiho/tortoise
33
go 1.18
44

55
require (
6+
github.com/google/go-cmp v0.5.9
67
github.com/onsi/ginkgo v1.16.5
7-
github.com/onsi/gomega v1.19.0
8+
github.com/onsi/gomega v1.26.0
89
k8s.io/api v0.25.0
910
k8s.io/apimachinery v0.25.0
1011
k8s.io/autoscaler/vertical-pod-autoscaler v0.13.0
1112
k8s.io/client-go v0.25.0
13+
k8s.io/klog/v2 v2.70.1
14+
k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed
1215
sigs.k8s.io/controller-runtime v0.12.3
1316
)
1417

1518
require (
16-
cloud.google.com/go v0.97.0 // indirect
19+
cloud.google.com/go/compute v1.6.1 // indirect
1720
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
1821
github.com/Azure/go-autorest/autorest v0.11.27 // indirect
1922
github.com/Azure/go-autorest/autorest/adal v0.9.20 // indirect
@@ -27,7 +30,7 @@ require (
2730
github.com/davecgh/go-spew v1.1.1 // indirect
2831
github.com/emicklei/go-restful/v3 v3.8.0 // indirect
2932
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
30-
github.com/fsnotify/fsnotify v1.5.1 // indirect
33+
github.com/fsnotify/fsnotify v1.5.4 // indirect
3134
github.com/go-logr/logr v1.2.3 // indirect
3235
github.com/go-logr/zapr v1.2.3 // indirect
3336
github.com/go-openapi/jsonpointer v0.19.5 // indirect
@@ -38,9 +41,8 @@ require (
3841
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
3942
github.com/golang/protobuf v1.5.2 // indirect
4043
github.com/google/gnostic v0.5.7-v3refs // indirect
41-
github.com/google/go-cmp v0.5.6 // indirect
4244
github.com/google/gofuzz v1.1.0 // indirect
43-
github.com/google/uuid v1.1.2 // indirect
45+
github.com/google/uuid v1.3.0 // indirect
4446
github.com/imdario/mergo v0.3.12 // indirect
4547
github.com/josharian/intern v1.0.0 // indirect
4648
github.com/json-iterator/go v1.1.12 // indirect
@@ -50,21 +52,23 @@ require (
5052
github.com/modern-go/reflect2 v1.0.2 // indirect
5153
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
5254
github.com/nxadm/tail v1.4.8 // indirect
55+
github.com/onsi/ginkgo/v2 v2.8.0 // indirect
5356
github.com/pkg/errors v0.9.1 // indirect
5457
github.com/prometheus/client_golang v1.12.1 // indirect
5558
github.com/prometheus/client_model v0.2.0 // indirect
5659
github.com/prometheus/common v0.32.1 // indirect
5760
github.com/prometheus/procfs v0.7.3 // indirect
5861
github.com/spf13/pflag v1.0.5 // indirect
62+
github.com/stretchr/testify v1.8.2 // indirect
5963
go.uber.org/atomic v1.7.0 // indirect
6064
go.uber.org/multierr v1.6.0 // indirect
61-
go.uber.org/zap v1.19.1 // indirect
62-
golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd // indirect
63-
golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect
64-
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect
65-
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect
66-
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
67-
golang.org/x/text v0.3.7 // indirect
65+
go.uber.org/zap v1.24.0 // indirect
66+
golang.org/x/crypto v0.5.0 // indirect
67+
golang.org/x/net v0.8.0 // indirect
68+
golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 // indirect
69+
golang.org/x/sys v0.6.0 // indirect
70+
golang.org/x/term v0.6.0 // indirect
71+
golang.org/x/text v0.8.0 // indirect
6872
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect
6973
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
7074
google.golang.org/appengine v1.6.7 // indirect
@@ -75,9 +79,7 @@ require (
7579
gopkg.in/yaml.v3 v3.0.1 // indirect
7680
k8s.io/apiextensions-apiserver v0.24.2 // indirect
7781
k8s.io/component-base v0.25.0 // indirect
78-
k8s.io/klog/v2 v2.70.1 // indirect
7982
k8s.io/kube-openapi v0.0.0-20220803162953-67bda5d908f1 // indirect
80-
k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed // indirect
8183
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
8284
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
8385
sigs.k8s.io/yaml v1.3.0 // indirect

0 commit comments

Comments
 (0)