Skip to content

Commit

Permalink
add postgres to ci
Browse files Browse the repository at this point in the history
  • Loading branch information
NickSavage committed May 30, 2024
1 parent 3f94789 commit 3f84002
Showing 1 changed file with 35 additions and 2 deletions.
37 changes: 35 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Go CI
xiname: Go CI

on:
push:
Expand All @@ -7,10 +7,26 @@ on:
branches: [ master ]

jobs:
test:
build:

runs-on: ubuntu-latest

services:
postgres:
image: postgres:13
ports:
- 5432:5432
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres # Default database

options: >-
--health-cmd "pg_isready -U postgres"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout code
uses: actions/checkout@v2
Expand All @@ -20,12 +36,29 @@ jobs:
with:
go-version: '1.22' # Adjust this to your Go version

- name: Wait for PostgreSQL
run: |
until pg_isready -h localhost -p 5432; do
echo "Waiting for PostgreSQL to be ready..."
sleep 1
done
- name: Create the database
run: |
psql postgresql://postgres:postgres@localhost:5432/postgres -c "CREATE DATABASE zettelkasten;"
- name: Install dependencies
run: |
cd go-backend
go mod download
- name: Run tests
env:
DB_HOST: localhost
DB_PORT: 5432
DB_USER: postgres
DB_PASSWORD: postgres
DB_NAME: zettelkasten
run: |
cd go-backend
go test ./...

0 comments on commit 3f84002

Please sign in to comment.