Skip to content

Commit 046f374

Browse files
committed
Refactoring actions
1 parent 96b447a commit 046f374

File tree

3 files changed

+100
-29
lines changed

3 files changed

+100
-29
lines changed
Lines changed: 89 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
name: Go
22

33
on:
4+
workflow_call:
45
push:
56
branches:
67
- master
78
pull_request:
89

910
env:
1011
TEST_RESULTS: /tmp/test-results # path to where test results will be saved
11-
GH_ACTIONS: "1"
12+
GH_ACTIONS: "0"
13+
TEST_SKIP_COMMENTS: "1"
14+
GO_VERSION: "1.22.5"
1215

1316

1417
jobs:
15-
test:
18+
initialize_data:
19+
name: Initialize Test Data
1620
runs-on: ubuntu-latest
1721
steps:
1822
- name: Checkout Repository
@@ -22,40 +26,59 @@ jobs:
2226
- name: Set up Go
2327
uses: actions/setup-go@v5
2428
with:
25-
go-version: "1.21.6"
29+
go-version: ${{ env.GO_VERSION }}
2630
- name: Verify go version
2731
run: go version
28-
- name: Install GoTest
29-
run: go install gotest.tools/gotestsum@latest
30-
# - name: Install jet generator
31-
# run: cd tests && make install-jet-gen
3232
- name: Init database
3333
run: |
3434
cd tests
35-
go run ./init/init.go -testsuite all
35+
go run ./init/init.go -testsuite postgres
36+
go run ./init/init.go -testsuite mariadb
37+
go run ./init/init.go -testsuite mysql
38+
# go run ./init/init.go -testsuite all
39+
- uses: actions/upload-artifact@v4
40+
with:
41+
name: testData
42+
include-hidden-files: true
43+
path: ${{ github.workspace }}/tests/.gentestdata/
44+
standard_tests:
45+
name: Run Standard Tests
46+
needs: initialize_data
47+
runs-on: ubuntu-latest
48+
steps:
49+
- name: Checkout Repository
50+
uses: actions/checkout@v4
51+
with:
52+
submodules: 'true'
53+
- name: Set up Go
54+
uses: actions/setup-go@v5
55+
with:
56+
go-version: ${{ env.GO_VERSION }}
57+
- uses: actions/download-artifact@v4
58+
with:
59+
name: testData
60+
path: ./tests/.gentestdata
3661
# to create test results report
3762
- name: Install go-junit-report
38-
run: go install github.com/jstemmer/go-junit-report@latest
63+
run: go install github.com/jstemmer/go-junit-report/v2@latest
64+
- name: locate binary
65+
run: which go-junit-report
66+
- name: Install jet
67+
run: go install ./cmd/jet
3968
- name: Setup Test Report Dir
40-
run: mkdir -p $TEST_RESULTS
69+
run: mkdir -p ${{ env.TEST_RESULTS }}
4170
# this will run all tests and exclude test files from code coverage report
4271
- name: Run Tests
4372
run: |
4473
go test -v ./... \
4574
-covermode=atomic \
4675
-coverpkg=github.com/go-jet/jet/v2/postgres/...,github.com/go-jet/jet/v2/mysql/...,github.com/go-jet/jet/v2/sqlite/...,github.com/go-jet/jet/v2/qrm/...,github.com/go-jet/jet/v2/generator/...,github.com/go-jet/jet/v2/internal/... \
47-
-coverprofile=cover.out 2>&1 | go-junit-report > $TEST_RESULTS/results.xml
48-
49-
# run mariaDB and cockroachdb tests. No need to collect coverage, because coverage is already included with mysql and postgres tests
50-
- name: Run MariaDB tests
51-
run: MY_SQL_SOURCE=MariaDB go test -v ./tests/mysql/
52-
- name: Run cockroach DB
53-
run: PG_SOURCE=COCKROACH_DB go test -v ./tests/postgres/
76+
-coverprofile=cover.out 2>&1 | go-junit-report > ${{ env.TEST_RESULTS }}/results.xml
5477
- name: Archive code coverage results
5578
uses: actions/upload-artifact@v4
5679
with:
5780
name: code-coverage-report
58-
path: $TEST_RESULTS/results.xml
81+
path: ${{ env.TEST_RESULTS }}/results.xml
5982
- name: Store cover.out
6083
uses: actions/upload-artifact@v4
6184
with:
@@ -65,4 +88,51 @@ jobs:
6588
uses: actions/upload-artifact@v4
6689
with:
6790
name: test-results
68-
path: /tmp/test-results
91+
path: /tmp/test-results
92+
maria_test:
93+
name: MariaDB Test
94+
needs: initialize_data
95+
runs-on: ubuntu-latest
96+
steps:
97+
- name: Checkout Repository
98+
uses: actions/checkout@v4
99+
with:
100+
submodules: 'true'
101+
- name: Set up Go
102+
uses: actions/setup-go@v5
103+
with:
104+
go-version: ${{ env.GO_VERSION }}
105+
- uses: actions/download-artifact@v4
106+
with:
107+
name: testData
108+
path: ./tests/.gentestdata
109+
- name: Install jet
110+
run: go install ./cmd/jet
111+
- name: Run MariaDB tests
112+
run: MY_SQL_SOURCE=MariaDB go test -v ./tests/mysql/
113+
cockroach_test:
114+
name: Cockroach Test
115+
needs: initialize_data
116+
runs-on: ubuntu-latest
117+
steps:
118+
- name: Checkout Repository
119+
uses: actions/checkout@v4
120+
with:
121+
submodules: 'true'
122+
- name: Set up Go
123+
uses: actions/setup-go@v5
124+
with:
125+
go-version: ${{ env.GO_VERSION }}
126+
- uses: actions/download-artifact@v4
127+
with:
128+
name: testData
129+
path: ./tests/.gentestdata
130+
- name: Install jet
131+
run: go install ./cmd/jet
132+
- name: Init database
133+
run: |
134+
cd tests
135+
go run ./init/init.go -testsuite cockroach
136+
go run ./init/init.go -testsuite postgres
137+
- name: Run cockroach DB
138+
run: PG_SOURCE=COCKROACH_DB go test -v ./tests/postgres/

tests/init/init.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,29 +78,29 @@ func main() {
7878
return initSQLiteDB()
7979
})
8080
case "all":
81-
err = timeMethod("postgres Schema Generation complete", func() error {
82-
return initPostgresDB(Postgres)
81+
err = timeMethod("couchDB Schema Generation complete", func() error {
82+
return initPostgresDB(Cockroach)
8383
})
8484
if err != nil {
8585
break
8686
}
8787

88-
err = timeMethod("couchDB Schema Generation complete", func() error {
89-
return initPostgresDB(Cockroach)
88+
err = timeMethod("postgres Schema Generation complete", func() error {
89+
return initPostgresDB(Postgres)
9090
})
9191
if err != nil {
9292
break
9393
}
9494

95-
err = timeMethod("Mysql Schema Generation complete", func() error {
96-
return initMySQLDB(MySql)
95+
err = timeMethod("MariaDB Schema Generation complete", func() error {
96+
return initMySQLDB(MariaDB)
9797
})
9898
if err != nil {
9999
break
100100
}
101101

102-
err = timeMethod("MariaDB Schema Generation complete", func() error {
103-
return initMySQLDB(MariaDB)
102+
err = timeMethod("Mysql Schema Generation complete", func() error {
103+
return initMySQLDB(MySql)
104104
})
105105
if err != nil {
106106
break

tests/internal/utils/common/const.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ package common
33
import "os"
44

55
const (
6-
GhActions = "GH_ACTIONS"
6+
GhActions = "GH_ACTIONS"
7+
GhSkipComments = "TEST_SKIP_COMMENTS"
78
)
89

910
func IsCICDTest() bool {
@@ -12,5 +13,5 @@ func IsCICDTest() bool {
1213

1314
// Add a hack to bypass failing tests
1415
func IsHack() bool {
15-
return true
16+
return os.Getenv(GhSkipComments) == "1"
1617
}

0 commit comments

Comments
 (0)