diff --git a/.github/workflows/test-springboot.yml b/.github/workflows/test-springboot.yml index d9439d6..56b27f1 100644 --- a/.github/workflows/test-springboot.yml +++ b/.github/workflows/test-springboot.yml @@ -28,25 +28,21 @@ on: description: 'Path to the generated artifact to upload' required: false default: 'build/reports/tests/test/' - + compose-file: + type: string + description: 'Path to a composefile to run before running tests' + required: false + compose-profile: + type: string + description: 'The profile of the composefile to load' + required: false + jobs: test: runs-on: ubuntu-latest defaults: run: working-directory: ${{ inputs.working-directory }} - services: - postgres: - image: postgres - env: - POSTGRES_DB: app - POSTGRES_USER: app - POSTGRES_PASSWORD: app - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 steps: - uses: actions/checkout@v4 @@ -57,7 +53,10 @@ jobs: java-version: ${{ inputs.java-version }} distribution: ${{ inputs.java-distribution }} cache: gradle - + - name: Run compose-file + if: inputs.compose-file != '' + run: | + docker compose up -f ${{ inputs.compose-file }} --profile ${{ $inputs.compose-profile }} -d - name: Build with Gradle env: DATABASE_URL: postgresql://localhost:5432/app @@ -71,3 +70,6 @@ jobs: with: name: ${{ inputs.artifact-name }} path: ${{ inputs.working-directory }}/${{ inputs.artifact-path }} + - name: Stop compose-file + if: inputs.compose-file != '' && always() + run: docker compose down -f ${{ inputs.compose-file }} --profile ${{ $inputs.compose-profile }}