Skip to content
This repository has been archived by the owner on Dec 13, 2024. It is now read-only.

Commit

Permalink
add ci
Browse files Browse the repository at this point in the history
  • Loading branch information
yp05327 committed Feb 9, 2024
1 parent 808fa9c commit 5f82e64
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 1 deletion.
22 changes: 22 additions & 0 deletions .github/workflows/build-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: build-tests

on:
push:
branches:
- main
pull_request:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
check-latest: true
- run: make deps
- run: make build
- run: make lint
- run: make test
timeout-minutes: 30
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ VERSION_LDFLAGS=\
COBRA_CLI_PACKAGE ?= github.com/spf13/[email protected]
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/[email protected]

TEST_TAGS ?=
GOTESTFLAGS ?=


ifeq ($(IS_WINDOWS),yes)
GOFLAGS := -v -buildmode=exe
EXECUTABLE ?= teachart.exe
Expand Down Expand Up @@ -59,4 +63,9 @@ lint:

.PHONY: lint-fix
lint-fix:
$(GO) run $(GOLANGCI_LINT_PACKAGE) run --fix
$(GO) run $(GOLANGCI_LINT_PACKAGE) run --fix

.PHONY: test
test:
@echo "Running go test with -tags '$(TEST_TAGS)'"
@$(GO) test $(GOTESTFLAGS) -tags='$(TEST_TAGS)' ./... .
25 changes: 25 additions & 0 deletions pkg/engine/engine_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package engine

import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/yp05327/teachart/pkg/app"
"helm.sh/helm/v3/pkg/cli/values"
)

const testChartDir = "../../tests/chart"

var testTeaChart = TeaChart{
ProjectName: "test",
ProjectDir: "",
TempDir: app.DefaultTemplatesDir,
}

func TestHelmRender(t *testing.T) {
e, err := NewRenderEngine(testChartDir, &testTeaChart)
assert.NoError(t, err)

_, err = e.Render(values.Options{}, false)
assert.NoError(t, err)
}
4 changes: 4 additions & 0 deletions tests/chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name: gitea
description: test chart for teachart
version: 0.0.1
appVersion: nightly
10 changes: 10 additions & 0 deletions tests/chart/templates/test_values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# should have .Values.TeaChart
{{ .Values.TeaChart.ProjectName }}
{{ .Values.TeaChart.ProjectDir }}
{{ .Values.TeaChart.TempDir }}

# helm chart metadata
{{ .Chart.Name }}
{{ .Chart.Description }}
{{ .Chart.Version }}
{{ .Chart.AppVersion }}
Empty file added tests/chart/values.yaml
Empty file.
Empty file added tests/values.yaml
Empty file.

0 comments on commit 5f82e64

Please sign in to comment.