From 2d5b0d41f1e880900f1a90bac9fd069aaa5e00c6 Mon Sep 17 00:00:00 2001 From: Samir Faci Date: Thu, 3 Oct 2024 20:28:46 -0400 Subject: [PATCH] Refactoring actions --- .github/workflows/integration_tests.yml | 137 +++++++++++++++++------- tests/mysql/generator_test.go | 11 ++ 2 files changed, 110 insertions(+), 38 deletions(-) diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index 6052baa6..fbe8747b 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -1,6 +1,7 @@ name: Go on: + workflow_call: push: branches: - master @@ -9,10 +10,12 @@ on: env: TEST_RESULTS: /tmp/test-results # path to where test results will be saved GH_ACTIONS: "1" + GO_VERSION: "1.21.6" + ACTIONS_STEP_DEBUG: true jobs: - test: + initialize_data: runs-on: ubuntu-latest steps: - name: Checkout Repository @@ -22,47 +25,105 @@ 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 - # to create test results report - - name: Install go-junit-report - run: go install github.com/jstemmer/go-junit-report@latest - - name: Setup Test Report Dir - run: mkdir -p $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/ - - name: Archive code coverage results - uses: actions/upload-artifact@v4 - with: - name: code-coverage-report - path: $TEST_RESULTS/results.xml - - name: Store cover.out - uses: actions/upload-artifact@v4 + go run ./init/init.go -testsuite mysql + # go run ./init/init.go -testsuite all + - name: CWD + run: pwd + - name: list + run: ls -lha tests + - uses: actions/upload-artifact@v4 with: - name: cover.out - path: cover.out - - name: Store test-results - uses: actions/upload-artifact@v4 + name: testData + path: tests/.gentestdata/ + validate_test: + needs: initialize_data + runs-on: ubuntu-latest + steps: + - uses: actions/download-artifact@v4 with: - name: test-results - path: /tmp/test-results \ No newline at end of file + name: testData + path: ./tests/.gentestdata + - name: CWD + run: pwd + - name: list + run: ls -lha tests +# maria_test: +# needs: initialize_data +# runs-on: ubuntu-latest +# steps: +# - uses: actions/download-artifact@v4 +# with: +# name: testData +# path: ./tests/.gentestdata +# # 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/ +# couchdb_test: +# needs: initialize_data +# runs-on: ubuntu-latest +# steps: +# - uses: actions/download-artifact@v4 +# with: +# name: generated-data +# path: tests/.gentestdata +# - name: Run cockroach DB +# run: PG_SOURCE=COCKROACH_DB go test -v ./tests/postgres/ +# standard_test: +# needs: initialize_data +# runs-on: ubuntu-latest +# steps: +# - uses: actions/download-artifact@v4 +# with: +# name: generated-data +# overwrite: true +# path: | +# tests/.gentestdata +# ./tests/.gentestdata +# ./.gentestdata +## - name: Checkout Repository +## uses: actions/checkout@v4 +## with: +## submodules: 'true' +## - name: Set up Go +## uses: actions/setup-go@v5 +## with: +## go-version: $GO_VERSION +## - name: Install GoTest +## run: go install gotest.tools/gotestsum@latest +## - uses: actions/download-artifact@master +## with: +## name: my-artifact +## path: tests/.gentestdata +# # to create test results report +# - name: Install go-junit-report +# run: go install github.com/jstemmer/go-junit-report@latest +# - name: Setup Test Report Dir +# run: mkdir -p $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 +# - name: Archive code coverage results +# uses: actions/upload-artifact@v4 +# with: +# name: code-coverage-report +# path: $TEST_RESULTS/results.xml +# - name: Store cover.out +# uses: actions/upload-artifact@v4 +# with: +# name: cover.out +# path: cover.out +# - name: Store test-results +# uses: actions/upload-artifact@v4 +# with: +# name: test-results +# path: /tmp/test-results \ No newline at end of file diff --git a/tests/mysql/generator_test.go b/tests/mysql/generator_test.go index ba61b5b0..abc2fb08 100644 --- a/tests/mysql/generator_test.go +++ b/tests/mysql/generator_test.go @@ -1,6 +1,7 @@ package mysql import ( + "fmt" "github.com/go-jet/jet/v2/tests/internal/utils/common" "os" "os/exec" @@ -245,6 +246,16 @@ func TestSQLBuilderColumnComment(t *testing.T) { if common.IsHack() { t.SkipNow() } + x := 0 + f1 := func(yield func() bool) { + + } + for range f1 { + fmt.Println(x) + x++ + + } + testutils.AssertFileContent(t, "./../.gentestdata/mysql/test_sample/table/link.go", ` // // Code generated by go-jet DO NOT EDIT.