diff --git a/.goreleaser.yaml b/.goreleaser.yaml index d527b7b..f113ddb 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -50,6 +50,15 @@ builds: - -trimpath tags: - netgo + hooks: &hooks + pre: + - cmd: >- + {{- if and (eq .Arch .Runtime.Goarch) (eq .Os .Runtime.Goos) }} + go test -c -vet=all -tags=netgo -ldflags=-s + -o ./dist/{{ .ProjectName }}.test/ ./pkg/... + {{- else }} + echo "Skipping test binary build for non-native platform" + {{- end }} - id: kclx-darwin main: ./cmd/kclx @@ -67,6 +76,7 @@ builds: - -trimpath tags: - netgo + hooks: *hooks dockers: - goos: linux diff --git a/Taskfile.yaml b/Taskfile.yaml index f01ca1c..366b8b3 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -64,7 +64,10 @@ tasks: go-build: desc: Builds Go binaries cmds: - - goreleaser build --snapshot --clean + - |- + export HOSTNAME="{{ .HOSTNAME }}" + export SDK_PATH="{{ .SDK_PATH }}" + goreleaser build --snapshot --clean --verbose go-build-images: desc: Builds Go binaries and Docker images diff --git a/pkg/helm/plugin_test.go b/pkg/helm/plugin_test.go index 458d245..2c0be32 100644 --- a/pkg/helm/plugin_test.go +++ b/pkg/helm/plugin_test.go @@ -166,3 +166,48 @@ patch = lambda resource: {str:} -> {str:} { t.Fatalf("result is not correct, %s", string(obj0md)) } } + +func BenchmarkPluginHelmTemplate(b *testing.B) { + + code := ` +import kcl_plugin.helm + +_chart = helm.template( + chart="wakatime-exporter", + repo_url="https://jacobcolvin.com/helm-charts", + target_revision="0.1.0", + values={service.main.enabled = False}, +) + +{result = _chart} +` + + client := native.NewNativeServiceClient() + _, err := client.ExecProgram(&gpyrpc.ExecProgram_Args{ + KFilenameList: []string{"main.k"}, + KCodeList: []string{code}, + Args: []*gpyrpc.Argument{}, + }) + if err != nil { + b.Fatal(err) + } + + b.ResetTimer() + + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + client := native.NewNativeServiceClient() + result, err := client.ExecProgram(&gpyrpc.ExecProgram_Args{ + KFilenameList: []string{"main.k"}, + KCodeList: []string{code}, + Args: []*gpyrpc.Argument{}, + }) + if err != nil { + b.Fatal(err) + } + if result.GetErrMessage() != "" { + b.Fatal(result.GetErrMessage()) + } + } + }) +}