Skip to content

Commit

Permalink
fix: add workflow for integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
graytonio committed May 29, 2024
1 parent b438392 commit 69cec91
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 13 deletions.
19 changes: 17 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
- main

jobs:
tests:
unit-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -29,4 +29,19 @@ jobs:
with:
name: FlagOps-Tests
path: TestResults.log


integration-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22.3'
- name: Install Dependencies
run: go get .
- name: Build Binary
run: make build-test
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.21

require (
github.com/Flagsmith/flagsmith-go-client/v3 v3.3.0
github.com/Masterminds/sprig/v3 v3.2.3
github.com/go-git/go-git/v5 v5.11.0
github.com/open-feature/go-sdk v1.9.0
github.com/open-feature/go-sdk-contrib/providers/flagsmith v0.1.4
Expand All @@ -17,7 +18,6 @@ require (
dario.cat/mergo v1.0.0 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.2.0 // indirect
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect
github.com/cloudflare/circl v1.3.3 // indirect
Expand Down Expand Up @@ -50,7 +50,7 @@ require (
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-git/go-billy/v5 v5.5.0
github.com/go-logr/logr v1.3.0 // indirect
github.com/go-logr/logr v1.3.0
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
Expand All @@ -69,5 +69,5 @@ require (
golang.org/x/sys v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gopkg.in/yaml.v3 v3.0.1
)
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
Expand Down
4 changes: 3 additions & 1 deletion lib/templ/templ.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,19 @@ func (te *TemplateEngine) executeFileTemplate(path string) error {
}

if te.path.Destination.Header != "" {
logrus.Info("Adding header")
data = append([]byte(fmt.Sprintf("%s\n", te.path.Destination.Header)), data...)
}

if te.path.Destination.Footer != "" {
logrus.Info("Adding footer")
data = append(data, []byte(fmt.Sprintf("\n%s", te.path.Destination.Footer))...)
}

templ, err := template.New(path).
Delims("[{", "}]").
Funcs(te.funcMap).
Parse(fmt.Sprintf("%s\n%s\n%s", te.path.Destination.Header, string(data), te.path.Destination.Footer))
Parse(string(data))
if err != nil {
return err
}
Expand Down
6 changes: 5 additions & 1 deletion makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
build:
goreleaser build --snapshot --clean --single-target
goreleaser build --snapshot --clean --single-target

build-test:
goreleaser build --snapshot --clean --single-target --output tests/flagops
$(MAKE) -C tests
1 change: 1 addition & 0 deletions tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
flagops
12 changes: 6 additions & 6 deletions tests/makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.PHONY: clean
clean:
@rm -f basic/output.txt

.PHONY: test
test: clean
@flagops
@./flagops
@cmp basic/output.txt basic/expected.txt --silent || (echo "Basic Test Failed output != expected" && exit 1)
@echo "All Tests Passed"
@echo "All Tests Passed"

.PHONY: clean
clean:
@rm -f basic/output.txt

0 comments on commit 69cec91

Please sign in to comment.