From dc65c7540e8d433a9aea5467d99a82df7eb6ba59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Gon=C3=A7alves?= Date: Thu, 30 Jan 2025 17:55:48 +0100 Subject: [PATCH 1/5] Separate build and test stages --- .github/workflows/build.yml | 2 +- .github/workflows/tests.yml | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 34fc0ed..388559a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,7 +1,7 @@ # This workflow will build a golang project # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go -name: Build & Test +name: Build on: push: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..d94b8d9 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,21 @@ +name: Test + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.23' + + - name: Test + run: go test -v ./... \ No newline at end of file From f2d06220c4c0ffa636a1d35894e363d43a8f0a27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Gon=C3=A7alves?= Date: Thu, 30 Jan 2025 17:58:27 +0100 Subject: [PATCH 2/5] Change workflow for releases --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b2b5945..ff8eee7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,8 +1,8 @@ name: Release on: - pull_request: push: + branches: [ "main" ] tags: - "*" From 21efb7bc0f647b1947692485ef4831b33257d759 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Gon=C3=A7alves?= Date: Thu, 30 Jan 2025 17:59:37 +0100 Subject: [PATCH 3/5] Fix - test in build stage --- .github/workflows/build.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 388559a..349cc8a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,6 +23,3 @@ jobs: - name: Build run: go build -v ./... - - - name: Test - run: go test -v ./... From 35c335ad1afda2940acd3d530468a7a687b78c38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Gon=C3=A7alves?= Date: Thu, 30 Jan 2025 18:01:53 +0100 Subject: [PATCH 4/5] Fix web editor file (typecheck) --- web_editor_converter_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_editor_converter_test.go b/web_editor_converter_test.go index 57d2774..578ac34 100644 --- a/web_editor_converter_test.go +++ b/web_editor_converter_test.go @@ -28,7 +28,7 @@ type WebEditorConverterTests []WebEditorConverterTest const WebEditorConverterTestModel = "web_editor.converter.test" // Many2One convert WebEditorConverterTest to *Many2One. -func (wct *WebEditorConverterTest) Many2One() *Many2One { +func (wct *WebEditorConverterTest) Many2OneConversion() *Many2One { return NewMany2One(wct.Id.Get(), "") } From 71a4c292dab43a1a5dcc4068ed3d77b2e2a12d20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Gon=C3=A7alves?= Date: Thu, 30 Jan 2025 18:06:00 +0100 Subject: [PATCH 5/5] Fix - remove fmt to use log --- generator/cmd/generator.go | 10 +++++----- generator/cmd/root.go | 6 ++---- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/generator/cmd/generator.go b/generator/cmd/generator.go index 8567c11..715c372 100644 --- a/generator/cmd/generator.go +++ b/generator/cmd/generator.go @@ -2,7 +2,7 @@ package cmd import ( "errors" - "fmt" + "log" "os" "os/exec" "strings" @@ -58,7 +58,7 @@ func (g *Generator) getModels(models []string) ([]*model, error) { return nil, err } if len(mfs) == 0 { - fmt.Printf("error: cannot find fields for model %s, cannot generate it.\n", model) + log.Printf("error: cannot find fields for model %s, cannot generate it.\n", model) continue } idExists := false @@ -68,8 +68,8 @@ func (g *Generator) getModels(models []string) ([]*model, error) { break } } - if idExists == false { - fmt.Printf("error: cannot find ID field for model %s, cannot generate it.\n", model) + if !idExists { + log.Printf("error: cannot find ID field for model %s, cannot generate it.\n", model) continue } mm = append(mm, newModel(model, mfs)) @@ -123,7 +123,7 @@ func (g *Generator) generateModels(models []*model) error { return err } } - fmt.Printf("%s has been generated\n", filePath) + log.Printf("%s has been generated\n", filePath) } return nil } diff --git a/generator/cmd/root.go b/generator/cmd/root.go index 4e200bd..a919568 100644 --- a/generator/cmd/root.go +++ b/generator/cmd/root.go @@ -1,8 +1,7 @@ package cmd import ( - "fmt" - "os" + "log" "strings" "text/template" @@ -85,6 +84,5 @@ func initTemplate() { } func handleError(err error) { - fmt.Println(err) - os.Exit(1) + log.Fatal(err) }