Skip to content

added README

added README #25

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: ${{ secrets.DB_USER }}
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
POSTGRES_DB: ${{ secrets.DB_NAME }}
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: Create .env.test file
run: |
echo "DB_HOST=${{ secrets.DB_HOST }}" >> .env.test
echo "DB_PORT=${{ secrets.DB_PORT }}" >> .env.test
echo "DB_USER=${{ secrets.DB_USER }}" >> .env.test
echo "DB_PASSWORD=${{ secrets.DB_PASSWORD }}" >> .env.test
echo "DB_NAME=${{ secrets.DB_NAME }}" >> .env.test
- 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 3
done
- name: Make create_migrations.sh executable
run: chmod +x scripts/create_migrations.sh
- name: Run database migrations
run: ./scripts/create_migrations.sh
- name: Run tests
run: go test -v ./... -covermode=atomic