Skip to content

Commit 302c6cb

Browse files
authored
Merge pull request #2 from Helvethink/feature/separate-build-test
Separate build and test stages
2 parents 6e79cc1 + 71a4c29 commit 302c6cb

File tree

6 files changed

+31
-15
lines changed

6 files changed

+31
-15
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This workflow will build a golang project
22
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
33

4-
name: Build & Test
4+
name: Build
55

66
on:
77
push:
@@ -23,6 +23,3 @@ jobs:
2323

2424
- name: Build
2525
run: go build -v ./...
26-
27-
- name: Test
28-
run: go test -v ./...

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
name: Release
22

33
on:
4-
pull_request:
54
push:
5+
branches: [ "main" ]
66
tags:
77
- "*"
88

.github/workflows/tests.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Set up Go
16+
uses: actions/setup-go@v5
17+
with:
18+
go-version: '1.23'
19+
20+
- name: Test
21+
run: go test -v ./...

generator/cmd/generator.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package cmd
22

33
import (
44
"errors"
5-
"fmt"
5+
"log"
66
"os"
77
"os/exec"
88
"strings"
@@ -58,7 +58,7 @@ func (g *Generator) getModels(models []string) ([]*model, error) {
5858
return nil, err
5959
}
6060
if len(mfs) == 0 {
61-
fmt.Printf("error: cannot find fields for model %s, cannot generate it.\n", model)
61+
log.Printf("error: cannot find fields for model %s, cannot generate it.\n", model)
6262
continue
6363
}
6464
idExists := false
@@ -68,8 +68,8 @@ func (g *Generator) getModels(models []string) ([]*model, error) {
6868
break
6969
}
7070
}
71-
if idExists == false {
72-
fmt.Printf("error: cannot find ID field for model %s, cannot generate it.\n", model)
71+
if !idExists {
72+
log.Printf("error: cannot find ID field for model %s, cannot generate it.\n", model)
7373
continue
7474
}
7575
mm = append(mm, newModel(model, mfs))
@@ -123,7 +123,7 @@ func (g *Generator) generateModels(models []*model) error {
123123
return err
124124
}
125125
}
126-
fmt.Printf("%s has been generated\n", filePath)
126+
log.Printf("%s has been generated\n", filePath)
127127
}
128128
return nil
129129
}

generator/cmd/root.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package cmd
22

33
import (
4-
"fmt"
5-
"os"
4+
"log"
65
"strings"
76
"text/template"
87

@@ -85,6 +84,5 @@ func initTemplate() {
8584
}
8685

8786
func handleError(err error) {
88-
fmt.Println(err)
89-
os.Exit(1)
87+
log.Fatal(err)
9088
}

web_editor_converter_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type WebEditorConverterTests []WebEditorConverterTest
2828
const WebEditorConverterTestModel = "web_editor.converter.test"
2929

3030
// Many2One convert WebEditorConverterTest to *Many2One.
31-
func (wct *WebEditorConverterTest) Many2One() *Many2One {
31+
func (wct *WebEditorConverterTest) Many2OneConversion() *Many2One {
3232
return NewMany2One(wct.Id.Get(), "")
3333
}
3434

0 commit comments

Comments
 (0)