diff --git a/.gitea/workflows/test.yaml b/.gitea/workflows/test.yaml index f8f492d..be38184 100644 --- a/.gitea/workflows/test.yaml +++ b/.gitea/workflows/test.yaml @@ -2,6 +2,12 @@ name: Unit tests run-name: ${{ gitea.actor }} is testing on: push +env: + POSTGRES_HOST: persistence-cicd-test-postgres-db + POSTGRES_PORT: 5442 + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + jobs: test: runs-on: ubuntu-latest @@ -13,22 +19,22 @@ jobs: # Docker Hub image image: postgres # Provide the password for postgres + hostname: ${{ env.POSTGRES_HOST }} env: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres + POSTGRES_USER: ${{ env.POSTGRES_USER }} + POSTGRES_PASSWORD: ${{ env.POSTGRES_PASSWORD }} # Set health checks to wait until postgres has started options: >- --health-cmd pg_isready --health-interval 10s --health-timeout 5s - --health-retries 5 + --health-retries 5 ports: # Maps tcp port 5432 on service container to the host - - 5442:5432 + - '${{ env.POSTGRES_PORT }}:5432' steps: - name: Setup dotnet - if: ${{ steps.cache-dotnet.outputs.cache-hit != 'true' }} uses: actions/setup-dotnet@v4 with: dotnet-version: 8.0.x @@ -36,6 +42,6 @@ jobs: uses: actions/checkout@v4 - name: Run integration tests env: - POSTGRES_HOST: postgres - POSTGRES_PORT: ${{ job.services.postgres.ports[5442] }} - run: dotnet test DD.Persistence.IntegrationTests \ No newline at end of file + POSTGRES_HOST: ${{ env.POSTGRES_HOST }} + POSTGRES_PORT: ${{ env.POSTGRES_PORT }} + run: dotnet test DD.Persistence.IntegrationTests diff --git a/DD.Persistence.App/appsettings.Tests.json b/DD.Persistence.App/appsettings.Tests.json index 5bd5c2e..9a07d74 100644 --- a/DD.Persistence.App/appsettings.Tests.json +++ b/DD.Persistence.App/appsettings.Tests.json @@ -1,6 +1,6 @@ { "DbConnection": { - "Host": "postgres", + "Host": "persistence-cicd-test-postgres-db", "Port": 5442, "Username": "postgres", "Password": "postgres"