Skip to content

Improve ci pipeline testing #65

Improve ci pipeline testing

Improve ci pipeline testing #65

Workflow file for this run

name: ci
on:
push:
branches: ["master"]
pull_request:
branches: ["master"]
jobs:
build:
runs-on: ubuntu-latest
services:
gilgoblin-database:
image: nickreinlein/gilgoblin-database
env:
POSTGRES_DB: gilgoblin_db
POSTGRES_USER: gilgoblin
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -d gilgoblin_db -U gilgoblin"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- name: Setup .NET8
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Set DB Connection String
id: set-connection-string
run: |
if [ -z "${{ secrets.POSTGRES_PASSWORD }}" ]; then
echo "Error: POSTGRES_PASSWORD secret is not set."
exit 1
fi
echo "DB_CONNECTION_STRING=Host=gilgoblin-database;Port=5432;Database=gilgoblin_db;Username=gilgoblin;Password=${{ secrets.POSTGRES_PASSWORD }};" >> $GITHUB_ENV
- name: Wait for Database
run: |
for i in {1..10}; do
if pg_isready -h gilgoblin-database -p 5432; then
echo "Database is ready!"
exit 0
else
echo "Waiting for database... ($i/10)"
sleep 5
fi
done
echo "Database did not become ready in time."
exit 1
- name: Test
env:
ConnectionStrings__GilGoblinDbContext: ${{ env.DB_CONNECTION_STRING }}
run: dotnet test --no-build --verbosity detailed --filter "Category!=Component"