Skip to content

Commit

Permalink
Refactoring actions
Browse files Browse the repository at this point in the history
  • Loading branch information
safaci2000 committed Oct 4, 2024
1 parent 96b447a commit 046f374
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 29 deletions.
108 changes: 89 additions & 19 deletions .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
name: Go

on:
workflow_call:
push:
branches:
- master
pull_request:

env:
TEST_RESULTS: /tmp/test-results # path to where test results will be saved
GH_ACTIONS: "1"
GH_ACTIONS: "0"
TEST_SKIP_COMMENTS: "1"
GO_VERSION: "1.22.5"


jobs:
test:
initialize_data:
name: Initialize Test Data
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
Expand All @@ -22,40 +26,59 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.21.6"
go-version: ${{ env.GO_VERSION }}
- name: Verify go version
run: go version
- name: Install GoTest
run: go install gotest.tools/gotestsum@latest
# - name: Install jet generator
# run: cd tests && make install-jet-gen
- name: Init database
run: |
cd tests
go run ./init/init.go -testsuite all
go run ./init/init.go -testsuite postgres
go run ./init/init.go -testsuite mariadb
go run ./init/init.go -testsuite mysql
# go run ./init/init.go -testsuite all
- uses: actions/upload-artifact@v4
with:
name: testData
include-hidden-files: true
path: ${{ github.workspace }}/tests/.gentestdata/
standard_tests:
name: Run Standard Tests
needs: initialize_data
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: 'true'
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- uses: actions/download-artifact@v4
with:
name: testData
path: ./tests/.gentestdata
# to create test results report
- name: Install go-junit-report
run: go install github.com/jstemmer/go-junit-report@latest
run: go install github.com/jstemmer/go-junit-report/v2@latest
- name: locate binary
run: which go-junit-report
- name: Install jet
run: go install ./cmd/jet
- name: Setup Test Report Dir
run: mkdir -p $TEST_RESULTS
run: mkdir -p ${{ env.TEST_RESULTS }}
# this will run all tests and exclude test files from code coverage report
- name: Run Tests
run: |
go test -v ./... \
-covermode=atomic \
-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/... \
-coverprofile=cover.out 2>&1 | go-junit-report > $TEST_RESULTS/results.xml
# run mariaDB and cockroachdb tests. No need to collect coverage, because coverage is already included with mysql and postgres tests
- name: Run MariaDB tests
run: MY_SQL_SOURCE=MariaDB go test -v ./tests/mysql/
- name: Run cockroach DB
run: PG_SOURCE=COCKROACH_DB go test -v ./tests/postgres/
-coverprofile=cover.out 2>&1 | go-junit-report > ${{ env.TEST_RESULTS }}/results.xml
- name: Archive code coverage results
uses: actions/upload-artifact@v4
with:
name: code-coverage-report
path: $TEST_RESULTS/results.xml
path: ${{ env.TEST_RESULTS }}/results.xml
- name: Store cover.out
uses: actions/upload-artifact@v4
with:
Expand All @@ -65,4 +88,51 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: test-results
path: /tmp/test-results
path: /tmp/test-results
maria_test:
name: MariaDB Test
needs: initialize_data
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: 'true'
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- uses: actions/download-artifact@v4
with:
name: testData
path: ./tests/.gentestdata
- name: Install jet
run: go install ./cmd/jet
- name: Run MariaDB tests
run: MY_SQL_SOURCE=MariaDB go test -v ./tests/mysql/
cockroach_test:
name: Cockroach Test
needs: initialize_data
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: 'true'
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- uses: actions/download-artifact@v4
with:
name: testData
path: ./tests/.gentestdata
- name: Install jet
run: go install ./cmd/jet
- name: Init database
run: |
cd tests
go run ./init/init.go -testsuite cockroach
go run ./init/init.go -testsuite postgres
- name: Run cockroach DB
run: PG_SOURCE=COCKROACH_DB go test -v ./tests/postgres/
16 changes: 8 additions & 8 deletions tests/init/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,29 +78,29 @@ func main() {
return initSQLiteDB()
})
case "all":
err = timeMethod("postgres Schema Generation complete", func() error {
return initPostgresDB(Postgres)
err = timeMethod("couchDB Schema Generation complete", func() error {
return initPostgresDB(Cockroach)
})
if err != nil {
break
}

err = timeMethod("couchDB Schema Generation complete", func() error {
return initPostgresDB(Cockroach)
err = timeMethod("postgres Schema Generation complete", func() error {
return initPostgresDB(Postgres)
})
if err != nil {
break
}

err = timeMethod("Mysql Schema Generation complete", func() error {
return initMySQLDB(MySql)
err = timeMethod("MariaDB Schema Generation complete", func() error {
return initMySQLDB(MariaDB)
})
if err != nil {
break
}

err = timeMethod("MariaDB Schema Generation complete", func() error {
return initMySQLDB(MariaDB)
err = timeMethod("Mysql Schema Generation complete", func() error {
return initMySQLDB(MySql)
})
if err != nil {
break
Expand Down
5 changes: 3 additions & 2 deletions tests/internal/utils/common/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ package common
import "os"

const (
GhActions = "GH_ACTIONS"
GhActions = "GH_ACTIONS"
GhSkipComments = "TEST_SKIP_COMMENTS"
)

func IsCICDTest() bool {
Expand All @@ -12,5 +13,5 @@ func IsCICDTest() bool {

// Add a hack to bypass failing tests
func IsHack() bool {
return true
return os.Getenv(GhSkipComments) == "1"
}

0 comments on commit 046f374

Please sign in to comment.