Skip to content

Commit d74ae72

Browse files
kovayurMalte Isberner
authored andcommitted
ROX-9160: Add basic CI checks (#12)
1 parent 17b5d4d commit d74ae72

File tree

8 files changed

+48
-14
lines changed

8 files changed

+48
-14
lines changed

.github/workflows/ci.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: helmtest CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-20.04
12+
steps:
13+
- name: Checkout VCS
14+
uses: actions/checkout@v2
15+
16+
- name: Prepare environment
17+
run: |
18+
go_version=$(cat EXPECTED_GO_VERSION)
19+
echo "GO_VERSION=$go_version" >> $GITHUB_ENV
20+
echo "CI=true" >> $GITHUB_ENV
21+
22+
- name: Setup GO
23+
uses: actions/setup-go@v2
24+
with:
25+
go-version: ${{ env.GO_VERSION }}
26+
27+
- name: Test
28+
run: make test
29+
30+
- name: Lint
31+
run: make golangci-lint

EXPECTED_GO_VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.17.2

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ require (
1313
k8s.io/apimachinery v0.22.2
1414
k8s.io/kube-openapi v0.0.0-20211025214626-d9a0cc0561b2
1515
k8s.io/kubectl v0.22.2
16-
k8s.io/utils v0.0.0-20211208161948-7d6a63dca704 // indirect
16+
k8s.io/utils v0.0.0-20211208161948-7d6a63dca704
1717
sigs.k8s.io/yaml v1.3.0
1818
)

go.sum

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1831,7 +1831,6 @@ k8s.io/metrics v0.22.2/go.mod h1:GUcsBtpsqQD1tKFS/2wCKu4ZBowwRncLOJH1rgWs3uw=
18311831
k8s.io/utils v0.0.0-20201110183641-67b214c5f920/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
18321832
k8s.io/utils v0.0.0-20210707171843-4b05e18ac7d9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
18331833
k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
1834-
k8s.io/utils v0.0.0-20210819203725-bdf08cb9a70a h1:8dYfu/Fc9Gz2rNJKB9IQRGgQOh2clmRzNIPPY1xLY5g=
18351834
k8s.io/utils v0.0.0-20210819203725-bdf08cb9a70a/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
18361835
k8s.io/utils v0.0.0-20211208161948-7d6a63dca704 h1:ZKMMxTvduyf5WUtREOqg5LiXaN1KO/+0oOQPRFrClpo=
18371836
k8s.io/utils v0.0.0-20211208161948-7d6a63dca704/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=

internal/parser/parser.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,4 @@ func ParseQuery(src string) (*gojq.Query, error) {
6060
return nil, err
6161
}
6262
return query, nil
63-
}
63+
}

pkg/framework/loader.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package framework
22

33
import (
4-
"k8s.io/utils/strings/slices"
54
"os"
65
"path/filepath"
76
"strings"
87

98
"github.com/pkg/errors"
9+
"k8s.io/utils/strings/slices"
1010
)
1111

1212
const (
@@ -19,7 +19,7 @@ type Loader struct {
1919
additionalTestDirs []string
2020
}
2121

22-
// NewLoader returns a a loader and applies options to it.
22+
// NewLoader returns a loader and applies options to it.
2323
func NewLoader(rootDir string, opts ...LoaderOpt) *Loader {
2424
loader := Loader{
2525
rootDir: rootDir,
@@ -31,7 +31,7 @@ func NewLoader(rootDir string, opts ...LoaderOpt) *Loader {
3131
return &loader
3232
}
3333

34-
// LoaderOpts allows to set custom options.
34+
// LoaderOpt allows setting custom options.
3535
type LoaderOpt func(loader *Loader)
3636

3737
// WithAdditionalTestDirs adds additional test source directories which are scanned for tests.
@@ -82,7 +82,8 @@ func (loader *Loader) readTestYAMLFiles() ([]string, error) {
8282
var testYAMLFiles []string
8383
var scannedDirs []string
8484

85-
dirs := append(loader.additionalTestDirs, loader.rootDir)
85+
dirs := []string{loader.rootDir}
86+
dirs = append(dirs, loader.additionalTestDirs...)
8687
for _, dir := range dirs {
8788
if slices.Contains(scannedDirs, dir) {
8889
continue

pkg/framework/loader_test.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
package framework
22

33
import (
4+
"testing"
5+
46
"github.com/stretchr/testify/assert"
57
"github.com/stretchr/testify/require"
6-
"testing"
78
)
89

910
func TestLoader(t *testing.T) {
1011
const testdataPath = "testdata/suite"
1112

1213
tests := map[string]struct {
13-
opts []LoaderOpt
14-
expectedFunc func(*testing.T, *Test)
15-
additionalDir string
16-
}{
14+
opts []LoaderOpt
15+
expectedFunc func(*testing.T, *Test)
16+
additionalDir string
17+
}{
1718
"With root dir": {
1819
expectedFunc: func(t *testing.T, helmTest *Test) {
1920
assert.Len(t, helmTest.Tests, 2)
@@ -24,7 +25,7 @@ func TestLoader(t *testing.T) {
2425
require.Len(t, test.Tests[1].Tests, 1)
2526
childTest := test.findFirst([]string{testdataPath, "helm.test.yaml", "test in helm.test.yaml", "with overwrites"})
2627
assert.Equal(t, "with overwrites", childTest.Name)
27-
assert.Equal(t, map[string]interface {}{"testValue":"value overwrite"}, childTest.Values)
28+
assert.Equal(t, map[string]interface{}{"testValue": "value overwrite"}, childTest.Values)
2829
},
2930
},
3031
"Loader loads additional dir": {

pkg/framework/test_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package framework
22

33
import (
4+
"testing"
5+
46
"github.com/stretchr/testify/assert"
57
"github.com/stretchr/testify/require"
6-
"testing"
78
)
89

910
func TestFind(t *testing.T) {

0 commit comments

Comments
 (0)