Skip to content
Merged

Gha #16

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
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: Install gotestsum
run: go install gotest.tools/gotestsum@latest

- name: Run tests
run: gotestsum --format github-action
working-directory: ./dbos
env:
PGPASSWORD: a!b@c$d()e*_,/:;=?@ff[]22
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5 changes: 4 additions & 1 deletion dbos/system_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"embed"
"errors"
"fmt"
"net/url"
"os"
"strings"
"time"
Expand Down Expand Up @@ -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/dbos?sslmode=disable")
password := url.QueryEscape(os.Getenv("PGPASSWORD"))
databaseURL = fmt.Sprintf("postgres://postgres:%s@localhost:5432/dbos?sslmode=disable", password)
}

// Create the database if it doesn't exist
Expand Down
5 changes: 4 additions & 1 deletion dbos/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package dbos

import (
"context"
"fmt"
"net/url"
"os"
"sync"
"testing"
Expand All @@ -16,7 +18,8 @@ func setupDBOS(t *testing.T) {

databaseURL := os.Getenv("DBOS_DATABASE_URL")
if databaseURL == "" {
t.Skip("DBOS_DATABASE_URL not set, skipping integration test")
password := url.QueryEscape(os.Getenv("PGPASSWORD"))
databaseURL = fmt.Sprintf("postgres://postgres:%s@localhost:5432/dbos?sslmode=disable", password)
}

// Clean up the test database
Expand Down
Loading