Skip to content
Merged
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
91 changes: 43 additions & 48 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Go

on:
push:
branches: [ "main" ]
branches: ["main"]
pull_request:
branches: [ "main" ]
branches: ["main"]

jobs:

build:
runs-on: ubuntu-latest
services:
Expand All @@ -23,55 +19,54 @@ jobs:
ports:
- 5432:5432
options: >-
--health-cmd="pg_isready -U app -d productdb"
--health-interval=10s
--health-timeout=5s
--health-cmd="pg_isready -U app -d productdb"
--health-interval=10s
--health-timeout=5s
--health-retries=5
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24.x'
check-latest: true
cache: true
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24.x'
check-latest: true
cache: true

- name: Tidy modules
run: go mod tidy
- name: Tidy modules
run: go mod tidy

- name: Install psql client
run: |
sudo apt-get update
sudo apt-get install -y postgresql-client
- name: Install psql client
run: |
sudo apt-get update
sudo apt-get install -y postgresql-client

- name: Wait for Postgres
env:
PGPASSWORD: app_password
run: |
for i in {1..30}; do
if pg_isready -h localhost -p 5432 -U app -d productdb; then
echo "Postgres is ready"; break; fi; sleep 2; done
pg_isready -h localhost -p 5432 -U app -d productdb

- name: Apply migrations (psql)
env:
PGPASSWORD: app_password
run: |
psql -v ON_ERROR_STOP=1 -h localhost -p 5432 -U app -d productdb -f apps/product-query-svc/adapters/outbound/postgres/migrations/000001_init.up.sql
psql -v ON_ERROR_STOP=1 -h localhost -p 5432 -U app -d productdb -f apps/product-query-svc/adapters/outbound/postgres/migrations/000002_seed_test_data.up.sql
- name: Wait for Postgres
env:
PGPASSWORD: app_password
run: |
for i in {1..30}; do
if pg_isready -h localhost -p 5432 -U app -d productdb; then
echo "Postgres is ready"; break; fi; sleep 2; done
pg_isready -h localhost -p 5432 -U app -d productdb

- name: Test (integration: Postgres endpoints)
env:
DATABASE_URL: postgres://app:app_password@localhost:5432/productdb?sslmode=disable
run: |
go test -v ./test/... -run Postgres
- name: Apply migrations (psql)
env:
PGPASSWORD: app_password
run: |
psql -v ON_ERROR_STOP=1 -h localhost -p 5432 -U app -d productdb -f apps/product-query-svc/adapters/outbound/postgres/migrations/000001_init.up.sql
psql -v ON_ERROR_STOP=1 -h localhost -p 5432 -U app -d productdb -f apps/product-query-svc/adapters/outbound/postgres/migrations/000002_seed_test_data.up.sql

- name: Test (integration: Postgres endpoints)
env:
DATABASE_URL: postgres://app:app_password@localhost:5432/productdb?sslmode=disable
run: |
go test -v ./test/... -run Postgres

- name: Build
run: go build -v ./...
- name: Build
run: go build -v ./...

- name: Test (all)
env:
DATABASE_URL: postgres://app:app_password@localhost:5432/productdb?sslmode=disable
run: go test -v ./...
- name: Test (all)
env:
DATABASE_URL: postgres://app:app_password@localhost:5432/productdb?sslmode=disable
run: go test -v ./...