Skip to content

Commit

Permalink
ROX-9160: Add basic CI checks (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
kovayur authored and Malte Isberner committed Feb 3, 2022
1 parent 17b5d4d commit d74ae72
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 14 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: helmtest CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
test:
runs-on: ubuntu-20.04
steps:
- name: Checkout VCS
uses: actions/checkout@v2

- name: Prepare environment
run: |
go_version=$(cat EXPECTED_GO_VERSION)
echo "GO_VERSION=$go_version" >> $GITHUB_ENV
echo "CI=true" >> $GITHUB_ENV
- name: Setup GO
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}

- name: Test
run: make test

- name: Lint
run: make golangci-lint
1 change: 1 addition & 0 deletions EXPECTED_GO_VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.17.2
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ require (
k8s.io/apimachinery v0.22.2
k8s.io/kube-openapi v0.0.0-20211025214626-d9a0cc0561b2
k8s.io/kubectl v0.22.2
k8s.io/utils v0.0.0-20211208161948-7d6a63dca704 // indirect
k8s.io/utils v0.0.0-20211208161948-7d6a63dca704
sigs.k8s.io/yaml v1.3.0
)
1 change: 0 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1831,7 +1831,6 @@ k8s.io/metrics v0.22.2/go.mod h1:GUcsBtpsqQD1tKFS/2wCKu4ZBowwRncLOJH1rgWs3uw=
k8s.io/utils v0.0.0-20201110183641-67b214c5f920/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
k8s.io/utils v0.0.0-20210707171843-4b05e18ac7d9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
k8s.io/utils v0.0.0-20210819203725-bdf08cb9a70a h1:8dYfu/Fc9Gz2rNJKB9IQRGgQOh2clmRzNIPPY1xLY5g=
k8s.io/utils v0.0.0-20210819203725-bdf08cb9a70a/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
k8s.io/utils v0.0.0-20211208161948-7d6a63dca704 h1:ZKMMxTvduyf5WUtREOqg5LiXaN1KO/+0oOQPRFrClpo=
k8s.io/utils v0.0.0-20211208161948-7d6a63dca704/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
Expand Down
2 changes: 1 addition & 1 deletion internal/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ func ParseQuery(src string) (*gojq.Query, error) {
return nil, err
}
return query, nil
}
}
9 changes: 5 additions & 4 deletions pkg/framework/loader.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package framework

import (
"k8s.io/utils/strings/slices"
"os"
"path/filepath"
"strings"

"github.com/pkg/errors"
"k8s.io/utils/strings/slices"
)

const (
Expand All @@ -19,7 +19,7 @@ type Loader struct {
additionalTestDirs []string
}

// NewLoader returns a a loader and applies options to it.
// NewLoader returns a loader and applies options to it.
func NewLoader(rootDir string, opts ...LoaderOpt) *Loader {
loader := Loader{
rootDir: rootDir,
Expand All @@ -31,7 +31,7 @@ func NewLoader(rootDir string, opts ...LoaderOpt) *Loader {
return &loader
}

// LoaderOpts allows to set custom options.
// LoaderOpt allows setting custom options.
type LoaderOpt func(loader *Loader)

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

dirs := append(loader.additionalTestDirs, loader.rootDir)
dirs := []string{loader.rootDir}
dirs = append(dirs, loader.additionalTestDirs...)
for _, dir := range dirs {
if slices.Contains(scannedDirs, dir) {
continue
Expand Down
13 changes: 7 additions & 6 deletions pkg/framework/loader_test.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
package framework

import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
)

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

tests := map[string]struct {
opts []LoaderOpt
expectedFunc func(*testing.T, *Test)
additionalDir string
}{
opts []LoaderOpt
expectedFunc func(*testing.T, *Test)
additionalDir string
}{
"With root dir": {
expectedFunc: func(t *testing.T, helmTest *Test) {
assert.Len(t, helmTest.Tests, 2)
Expand All @@ -24,7 +25,7 @@ func TestLoader(t *testing.T) {
require.Len(t, test.Tests[1].Tests, 1)
childTest := test.findFirst([]string{testdataPath, "helm.test.yaml", "test in helm.test.yaml", "with overwrites"})
assert.Equal(t, "with overwrites", childTest.Name)
assert.Equal(t, map[string]interface {}{"testValue":"value overwrite"}, childTest.Values)
assert.Equal(t, map[string]interface{}{"testValue": "value overwrite"}, childTest.Values)
},
},
"Loader loads additional dir": {
Expand Down
3 changes: 2 additions & 1 deletion pkg/framework/test_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package framework

import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
)

func TestFind(t *testing.T) {
Expand Down

0 comments on commit d74ae72

Please sign in to comment.