Run Tests #53
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Run Tests | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| branches: | |
| - "main" | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| age_image: | |
| - release_PG16_1.5.0 | |
| - release_PG16_1.6.0 | |
| - dev_snapshot_PG17 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Start PostgreSQL with AGE extension | |
| run: | | |
| docker run --name postgres-test-${{ matrix.age_image }} \ | |
| -e POSTGRES_USER=postgres \ | |
| -e POSTGRES_PASSWORD=postgres \ | |
| -e POSTGRES_DB=agedotnet_tests \ | |
| -p 5432:5432 \ | |
| -d apache/age:${{ matrix.age_image }} | |
| - name: Wait for PostgreSQL to be ready | |
| run: | | |
| for i in {1..30}; do | |
| if docker exec postgres-test-${{ matrix.age_image }} pg_isready -U postgres -d agedotnet_tests; then | |
| echo "PostgreSQL is ready"; | |
| sleep 5; | |
| exit 0; | |
| fi; | |
| echo "Waiting for PostgreSQL..."; | |
| sleep 5; | |
| done | |
| echo "PostgreSQL did not become ready in time"; | |
| exit 1; | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: | | |
| 6.0.x | |
| 8.0.x | |
| 9.0.x | |
| - name: Restore dependencies | |
| run: dotnet restore | |
| - name: Build | |
| run: dotnet build --no-restore | |
| - name: Test with dotnet | |
| run: dotnet test --logger 'GitHubActions' --logger 'console;verbosity=normal' --blame-hang --blame-hang-timeout 5m | |
| - name: Stop PostgreSQL container | |
| if: always() | |
| run: | | |
| docker stop postgres-test-${{ matrix.age_image }} || true | |
| docker rm postgres-test-${{ matrix.age_image }} || true |