From 7bbefcf6dffd4eb8267e5a4a2131caba34a56e9f Mon Sep 17 00:00:00 2001 From: maxdml Date: Mon, 14 Jul 2025 16:02:32 -0700 Subject: [PATCH 1/9] GHA --- .github/workflow/tests.yml | 66 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 .github/workflow/tests.yml diff --git a/.github/workflow/tests.yml b/.github/workflow/tests.yml new file mode 100644 index 00000000..76d45ae8 --- /dev/null +++ b/.github/workflow/tests.yml @@ -0,0 +1,66 @@ +name: Run Go Tests + +on: + push: + branches: + - main + pull_request: + branches: + - main + types: + - ready_for_review + - opened + - reopened + - synchronize + workflow_dispatch: + +jobs: + test: + runs-on: ubuntu-latest + services: + # Postgres service container + postgres: + image: postgres:16 + env: + # Specify the password for Postgres superuser. + POSTGRES_PASSWORD: a!b@c$d()e*_,/:;=?@ff[]22 + # Set health checks to wait until postgres has started + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + # Maps tcp port 5432 on service container to the host + - 5432:5432 + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + fetch-tags: true + + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: '1.23.x' + + - name: Cache Go modules + uses: actions/cache@v4 + with: + path: | + ~/go/pkg/mod + ~/.cache/go-build + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Download dependencies + run: go mod download + + - name: Run tests + run: go test -v ./... + working-directory: ./dbos + env: + PGPASSWORD: a!b@c$d()e*_,/:;=?@ff[]22 + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From 210b8e670beab8d8c69412996c53f36f7a26a20b Mon Sep 17 00:00:00 2001 From: maxdml Date: Mon, 14 Jul 2025 16:17:06 -0700 Subject: [PATCH 2/9] fix --- .github/{workflow => workflows}/tests.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{workflow => workflows}/tests.yml (100%) diff --git a/.github/workflow/tests.yml b/.github/workflows/tests.yml similarity index 100% rename from .github/workflow/tests.yml rename to .github/workflows/tests.yml From bb759ac2c3ff113b33f5cdb69f4bfe6753d3fa26 Mon Sep 17 00:00:00 2001 From: maxdml Date: Mon, 14 Jul 2025 16:21:41 -0700 Subject: [PATCH 3/9] export DBOS_DATABASE_URL --- .github/workflows/tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 76d45ae8..77a1eb45 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -62,5 +62,6 @@ jobs: run: go test -v ./... working-directory: ./dbos env: + DBOS_DATABASE_URL: postgres://postgres:a!b@c$d()e*_,/:;=?@ff[]22@localhost:5432/postgres?sslmode=disable PGPASSWORD: a!b@c$d()e*_,/:;=?@ff[]22 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From b5c4530f1f49d38f224a94254778642294409726 Mon Sep 17 00:00:00 2001 From: maxdml Date: Mon, 14 Jul 2025 16:34:35 -0700 Subject: [PATCH 4/9] default db url --- dbos/system_database.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dbos/system_database.go b/dbos/system_database.go index ceb4a10b..927a5e34 100644 --- a/dbos/system_database.go +++ b/dbos/system_database.go @@ -5,6 +5,7 @@ import ( "embed" "errors" "fmt" + "net/url" "os" "strings" "time" @@ -121,7 +122,9 @@ func NewSystemDatabase() (SystemDatabase, error) { // TODO: pass proper config databaseURL := os.Getenv("DBOS_DATABASE_URL") if databaseURL == "" { - return nil, NewInitializationError("DBOS_DATABASE_URL environment variable is required") + fmt.Println("DBOS_DATABASE_URL not set, using default: postgres://postgres:${PGPASSWORD}@localhost:5432/postgres?sslmode=disable") + password := url.QueryEscape(os.Getenv("PGPASSWORD")) + databaseURL = fmt.Sprintf("postgres://postgres:%s@localhost:5432/postgres?sslmode=disable", password) } // Create the database if it doesn't exist From acf3371890486efef0dbce9511ec1f98c54b648f Mon Sep 17 00:00:00 2001 From: maxdml Date: Mon, 14 Jul 2025 16:36:05 -0700 Subject: [PATCH 5/9] remove env export --- .github/workflows/tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 77a1eb45..76d45ae8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -62,6 +62,5 @@ jobs: run: go test -v ./... working-directory: ./dbos env: - DBOS_DATABASE_URL: postgres://postgres:a!b@c$d()e*_,/:;=?@ff[]22@localhost:5432/postgres?sslmode=disable PGPASSWORD: a!b@c$d()e*_,/:;=?@ff[]22 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From 7f0247c5771d595d583532391c468bf3842f7a2f Mon Sep 17 00:00:00 2001 From: maxdml Date: Mon, 14 Jul 2025 16:37:48 -0700 Subject: [PATCH 6/9] update test --- dbos/utils_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dbos/utils_test.go b/dbos/utils_test.go index d1877a4b..5f2b7950 100644 --- a/dbos/utils_test.go +++ b/dbos/utils_test.go @@ -2,6 +2,8 @@ package dbos import ( "context" + "fmt" + "net/url" "os" "sync" "testing" @@ -16,7 +18,9 @@ func setupDBOS(t *testing.T) { databaseURL := os.Getenv("DBOS_DATABASE_URL") if databaseURL == "" { - t.Skip("DBOS_DATABASE_URL not set, skipping integration test") + fmt.Println("DBOS_DATABASE_URL not set, using default: postgres://postgres:${PGPASSWORD}@localhost:5432/postgres?sslmode=disable") + password := url.QueryEscape(os.Getenv("PGPASSWORD")) + databaseURL = fmt.Sprintf("postgres://postgres:%s@localhost:5432/postgres?sslmode=disable", password) } // Clean up the test database From 2f1943ba13d4c3888bed8f1a051bb8180beaa924 Mon Sep 17 00:00:00 2001 From: maxdml Date: Mon, 14 Jul 2025 16:42:23 -0700 Subject: [PATCH 7/9] db name --- dbos/system_database.go | 4 ++-- dbos/utils_test.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dbos/system_database.go b/dbos/system_database.go index 927a5e34..05399cb1 100644 --- a/dbos/system_database.go +++ b/dbos/system_database.go @@ -122,9 +122,9 @@ func NewSystemDatabase() (SystemDatabase, error) { // TODO: pass proper config databaseURL := os.Getenv("DBOS_DATABASE_URL") if databaseURL == "" { - fmt.Println("DBOS_DATABASE_URL not set, using default: postgres://postgres:${PGPASSWORD}@localhost:5432/postgres?sslmode=disable") + fmt.Println("DBOS_DATABASE_URL not set, using default: postgres://postgres:${PGPASSWORD}@localhost:5432/dbos?sslmode=disable") password := url.QueryEscape(os.Getenv("PGPASSWORD")) - databaseURL = fmt.Sprintf("postgres://postgres:%s@localhost:5432/postgres?sslmode=disable", password) + databaseURL = fmt.Sprintf("postgres://postgres:%s@localhost:5432/dbos?sslmode=disable", password) } // Create the database if it doesn't exist diff --git a/dbos/utils_test.go b/dbos/utils_test.go index 5f2b7950..2cb13faf 100644 --- a/dbos/utils_test.go +++ b/dbos/utils_test.go @@ -18,9 +18,9 @@ func setupDBOS(t *testing.T) { databaseURL := os.Getenv("DBOS_DATABASE_URL") if databaseURL == "" { - fmt.Println("DBOS_DATABASE_URL not set, using default: postgres://postgres:${PGPASSWORD}@localhost:5432/postgres?sslmode=disable") + fmt.Println("DBOS_DATABASE_URL not set, using default: postgres://postgres:${PGPASSWORD}@localhost:5432/dbos?sslmode=disable") password := url.QueryEscape(os.Getenv("PGPASSWORD")) - databaseURL = fmt.Sprintf("postgres://postgres:%s@localhost:5432/postgres?sslmode=disable", password) + databaseURL = fmt.Sprintf("postgres://postgres:%s@localhost:5432/dbos?sslmode=disable", password) } // Clean up the test database From a03b060ebff4ab055d2119e5de5fc0cb59cc08fc Mon Sep 17 00:00:00 2001 From: maxdml Date: Mon, 14 Jul 2025 16:59:53 -0700 Subject: [PATCH 8/9] output formatting --- .github/workflows/tests.yml | 2 +- dbos/utils_test.go | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 76d45ae8..a2179b83 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -59,7 +59,7 @@ jobs: run: go mod download - name: Run tests - run: go test -v ./... + run: gotestsum --format github-action working-directory: ./dbos env: PGPASSWORD: a!b@c$d()e*_,/:;=?@ff[]22 diff --git a/dbos/utils_test.go b/dbos/utils_test.go index 2cb13faf..b7c6d667 100644 --- a/dbos/utils_test.go +++ b/dbos/utils_test.go @@ -18,7 +18,6 @@ func setupDBOS(t *testing.T) { databaseURL := os.Getenv("DBOS_DATABASE_URL") if databaseURL == "" { - fmt.Println("DBOS_DATABASE_URL not set, using default: postgres://postgres:${PGPASSWORD}@localhost:5432/dbos?sslmode=disable") password := url.QueryEscape(os.Getenv("PGPASSWORD")) databaseURL = fmt.Sprintf("postgres://postgres:%s@localhost:5432/dbos?sslmode=disable", password) } From 5c119479a5a5719f7f36dfd7728e7c8f730d71af Mon Sep 17 00:00:00 2001 From: maxdml Date: Mon, 14 Jul 2025 17:02:00 -0700 Subject: [PATCH 9/9] install gotestsum --- .github/workflows/tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a2179b83..ab533fad 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -58,6 +58,9 @@ jobs: - name: Download dependencies run: go mod download + - name: Install gotestsum + run: go install gotest.tools/gotestsum@latest + - name: Run tests run: gotestsum --format github-action working-directory: ./dbos