Skip to content

Commit 3916f7b

Browse files
authored
move tests to gh actions (#9461)
1 parent 2db8552 commit 3916f7b

File tree

8 files changed

+72
-11
lines changed

8 files changed

+72
-11
lines changed

.github/workflows/ci.yaml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,63 @@ jobs:
7575
# G307 TODO: Deferring unsafe method "Close"
7676
args: -exclude=G109,G601,G104,G204,G304,G306,G307 -tests=false -exclude-dir=test -exclude-dir=images/ -exclude-dir=docs/ ./...
7777

78+
lint:
79+
runs-on: ubuntu-latest
80+
needs: changes
81+
if: |
82+
(needs.changes.outputs.go == 'true')
83+
steps:
84+
- name: Checkout
85+
uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3.2.0
86+
87+
- name: Set up Go
88+
id: go
89+
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0
90+
with:
91+
go-version: '1.19'
92+
check-latest: true
93+
94+
- name: Run Lint
95+
run: ./hack/verify-golint.sh
96+
97+
gofmt:
98+
runs-on: ubuntu-latest
99+
needs: changes
100+
if: |
101+
(needs.changes.outputs.go == 'true')
102+
steps:
103+
- name: Checkout
104+
uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3.2.0
105+
106+
- name: Set up Go
107+
id: go
108+
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0
109+
with:
110+
go-version: '1.19'
111+
check-latest: true
112+
113+
- name: Run go-fmt
114+
run: ./hack/verify-gofmt.sh
115+
116+
test-go:
117+
runs-on: ubuntu-latest
118+
needs: changes
119+
if: |
120+
(needs.changes.outputs.go == 'true')
121+
steps:
122+
- name: Checkout
123+
uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3.2.0
124+
125+
- name: Set up Go
126+
id: go
127+
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0
128+
with:
129+
go-version: '1.19'
130+
check-latest: true
131+
132+
- name: Run test
133+
run: make test
134+
78135
build:
79136
name: Build
80137
runs-on: ubuntu-latest

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ test: ## Run go unit tests.
141141
COMMIT_SHA=$(COMMIT_SHA) \
142142
REPO_INFO=$(REPO_INFO) \
143143
TAG=$(TAG) \
144+
GOFLAGS="-buildvcs=false" \
144145
test/test.sh
145146

146147
.PHONY: lua-test

internal/ingress/annotations/authreq/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ func ValidHeader(header string) bool {
149149
// ValidCacheDuration checks if the provided string is a valid cache duration
150150
// spec: [code ...] [time ...];
151151
// with: code is an http status code
152-
// time must match the time regex and may appear multiple times, e.g. `1h 30m`
152+
//
153+
// time must match the time regex and may appear multiple times, e.g. `1h 30m`
153154
func ValidCacheDuration(duration string) bool {
154155
elements := strings.Split(duration, " ")
155156
seenDuration := false

internal/ingress/controller/template/template.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ type Template struct {
7575
bp *BufferPool
7676
}
7777

78-
//NewTemplate returns a new Template instance or an
79-
//error if the specified template file contains errors
78+
// NewTemplate returns a new Template instance or an
79+
// error if the specified template file contains errors
8080
func NewTemplate(file string) (*Template, error) {
8181
data, err := os.ReadFile(file)
8282
if err != nil {
@@ -287,9 +287,10 @@ var (
287287
// escapeLiteralDollar will replace the $ character with ${literal_dollar}
288288
// which is made to work via the following configuration in the http section of
289289
// the template:
290-
// geo $literal_dollar {
291-
// default "$";
292-
// }
290+
//
291+
// geo $literal_dollar {
292+
// default "$";
293+
// }
293294
func escapeLiteralDollar(input interface{}) string {
294295
inputStr, ok := input.(string)
295296
if !ok {

internal/ingress/resolver/mock.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ func (m Mock) GetSecret(string) (*apiv1.Secret, error) {
4141

4242
// GetAuthCertificate resolves a given secret name into an SSL certificate.
4343
// The secret must contain 3 keys named:
44-
// ca.crt: contains the certificate chain used for authentication
44+
//
45+
// ca.crt: contains the certificate chain used for authentication
4546
func (m Mock) GetAuthCertificate(string) (*AuthSSLCert, error) {
4647
return nil, nil
4748
}

pkg/util/runtime/cpu_linux.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ import (
3333
// NumCPU returns the number of logical CPUs usable by the current process.
3434
// If CPU cgroups limits are configured, use cfs_quota_us / cfs_period_us
3535
// as formula
36-
// https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt
36+
//
37+
// https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt
3738
func NumCPU() int {
3839
cpus := runtime.NumCPU()
3940

rootfs/chroot.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ for dir in "${writeDirs[@]}"; do
4040
chown -R www-data.www-data ${dir};
4141
done
4242

43-
4443
mkdir -p /chroot/lib /chroot/proc /chroot/usr /chroot/bin /chroot/dev /chroot/run
4544
cp /etc/passwd /etc/group /chroot/etc/
4645
cp -a /usr/* /chroot/usr/

test/e2e/framework/util.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ func CreateIngressClass(namespace string, c kubernetes.Interface) (string, error
189189
return ic.Name, nil
190190
}
191191

192-
//deleteIngressClass deletes an IngressClass and its related ClusterRole* objects
192+
// deleteIngressClass deletes an IngressClass and its related ClusterRole* objects
193193
func deleteIngressClass(c kubernetes.Interface, ingressclass string) error {
194194
var err error
195195
grace := int64(0)
@@ -215,7 +215,7 @@ func deleteIngressClass(c kubernetes.Interface, ingressclass string) error {
215215
return nil
216216
}
217217

218-
//GetIngressClassName returns the default IngressClassName given a namespace
218+
// GetIngressClassName returns the default IngressClassName given a namespace
219219
func GetIngressClassName(namespace string) *string {
220220
icname := fmt.Sprintf("ic-%s", namespace)
221221
return &icname

0 commit comments

Comments
 (0)