Skip to content

ci/cd

ci/cd #1

Workflow file for this run

name: Go API Tests
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: librarymanagementsystem_test
ports:
- 5432:5432
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: "^1.22.2"
- name: Install dependencies
run: go mod download
- name: Start PostgreSQL and wait for connection
run: |
sudo apt-get update
sudo apt-get install -y netcat
until nc -z localhost 5432; do
echo "Waiting for PostgreSQL..."
sleep 1
done
- name: Run tests
run: go test -v ./...