Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Go
on: [push]
jobs:

build:
name: Build
runs-on: ubuntu-latest
steps:

- name: Set up Go 1.12
uses: actions/setup-go@v1
with:
go-version: 1.12
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v1

- name: Get dependencies
run: go mod download

- name: Ensure the project is formatted
run: test -z "$(go fmt ./...)"

- name: Analyse Go code using `vet`
run: go vet ./...

- name: Ensure the project can be built without issues for tests
run: go run ./generator/cli/thoth/main.go gen --t generate

- name: Test
run: go run github.com/onsi/ginkgo/ginkgo -r -requireSuite --randomizeAllSpecs --randomizeSuites --failOnPending --cover --trace --race --compilers=2
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,14 @@

# Output of the go coverage tool, specifically when used with LiteIDE
*.out
*.coverprofile
.cover/
coverage.txt
test-results/

# Dependencies
vendor/

# IDE
.vscode/
.idea/
34 changes: 34 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
COVERDIR=$(CURDIR)/.cover
COVERAGEFILE=$(COVERDIR)/cover.out
COVERAGEREPORT=$(COVERDIR)/report.html

.PHONY: test test-watch coverage coverage-html coverage-ci vet fmt

test:
@ginkgo --failFast ./...

test-watch:
@ginkgo watch -cover -r ./...

coverage-ci:
@mkdir -p $(COVERDIR)
@ginkgo -r -covermode=count --cover --trace ./
@echo "mode: count" > "${COVERAGEFILE}"
@find . -type f -name '*.coverprofile' -exec cat {} \; -exec rm -f {} \; | grep -h -v "^mode:" >> ${COVERAGEFILE}

coverage: coverage-ci
@sed -i -e "s|_$(CURDIR)/|./|g" "${COVERAGEFILE}"
@cp "${COVERAGEFILE}" coverage.txt

coverage-html:
@go tool cover -html="${COVERAGEFILE}" -o $(COVERAGEREPORT)
@xdg-open $(COVERAGEREPORT) 2> /dev/null > /dev/null

vet:
@go vet ./...

fmt:
@go fmt ./...

generate:
@go generate ./...
4 changes: 2 additions & 2 deletions generator/cmd/thoth.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ var genCommand = &cobra.Command{
RunE: func(cmd *cobra.Command, args []string) error {

if cmd.Flag("t").Value.String() == "generate" {
cmd.Flag("d").Value.Set("tests/parse_dir")
cmd.Flag("d").Value.Set("test/parse_dir")
cmd.Flag("n").Value.Set("thothGenForTest")
cmd.Flag("s").Value.Set("./tests/gen")
cmd.Flag("s").Value.Set("./test/gen")
}

if err := gen(cmd, args); err != nil {
Expand Down
2 changes: 2 additions & 0 deletions generator/templates/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ func RenderStruct(_buffer io.StringWriter, fileName string, pkg *myasthurts.Pack
_buffer.WriteString(("\n"))
_buffer.WriteString(" ")

_buffer.WriteString(("return nil\n"))

_buffer.WriteString("}")

}
Expand Down
4 changes: 1 addition & 3 deletions generator/templates/struct.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ package @pkg.Name @raw("\n\n")
@for _, s := range structsThoth { @raw("\n")
@raw("// Thoth validate\n")
@:func(@strings.ToLower(@s.Name()[0:1]) @raw("*")@s.Name()) Thoth() error {@raw("\n")



@raw("return nil\n")
@:}
}
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/lab259/go-thoth
go 1.12

require (
github.com/lab259/go-my-ast-hurts v0.0.0-00010101000000-000000000000
github.com/lab259/go-my-ast-hurts v0.0.0-20191029192755-70e0dd09e3eb
github.com/novln/macchiato v1.0.0
github.com/onsi/ginkgo v1.10.2
github.com/onsi/gomega v1.7.0
Expand All @@ -19,5 +19,3 @@ require (
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 // indirect
gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
)

replace github.com/lab259/go-my-ast-hurts => ../go-my-ast-hurts
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/lab259/errors v2.1.0+incompatible/go.mod h1:MDDGb8dSRNqu9IVhE4C+nF2qFqPPO+n6/Nn1AqyI6rI=
github.com/lab259/go-my-ast-hurts v0.0.0-20191029192755-70e0dd09e3eb h1:O/h1tuc0B1A55PxfLdGd/wqpDBYLRYvI07eRNayyJQw=
github.com/lab259/go-my-ast-hurts v0.0.0-20191029192755-70e0dd09e3eb/go.mod h1:ezp+lyGu0NanL8HChvMz1S+G1ZavPdW9NgcD/mpPkzA=
github.com/leodido/go-urn v1.1.0 h1:Sm1gr51B1kKyfD2BlRcLSiEkffoG96g6TPv6eRoEiB8=
github.com/leodido/go-urn v1.1.0/go.mod h1:+cyI34gQWZcE1eQU7NVgKkkzdXDQHr1dBMtdAPozLkw=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
Expand Down
6 changes: 2 additions & 4 deletions go_thoth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,28 @@ var _ = Describe("GoThoth", func() {
env, err := myasthurts.NewEnvironment()
Expect(err).ToNot(HaveOccurred())

pkg, err := env.Parse("./tests/gen")
pkg, err := env.Parse("./test/gen")
Expect(err).ToNot(HaveOccurred())

Expect(pkg.Name).To(Equal("any"))

refType, ok := pkg.RefTypeByName("Home")
Expect(ok).To(BeTrue())
Expect(refType.Name()).To(Equal("Home"))

})

It("should show func User", func() {
env, err := myasthurts.NewEnvironment()
Expect(err).ToNot(HaveOccurred())

pkg, err := env.Parse("./tests/gen")
pkg, err := env.Parse("./test/gen")
Expect(err).ToNot(HaveOccurred())

Expect(pkg.Name).To(Equal("any"))

refType, ok := pkg.RefTypeByName("User")
Expect(ok).To(BeTrue())
Expect(refType.Name()).To(Equal("User"))

})
})
})
Binary file removed main
Binary file not shown.
2 changes: 2 additions & 0 deletions test/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package test contains cross-functional test suites
package test
2 changes: 2 additions & 0 deletions test/gen/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:generate gofmt -s -w thothGenForTest.go
//go:generate gofmt -s -w thothGen.go
package any

// Thoth validate
Expand Down
13 changes: 0 additions & 13 deletions tests/parse_dir/thothGen.go

This file was deleted.