From 4d3bea512053191326e032be8ad66f2eced17559 Mon Sep 17 00:00:00 2001 From: Shiipou Date: Wed, 27 Aug 2025 17:37:12 +0200 Subject: [PATCH] feat: allow compose-file into spring-test --- .github/workflows/test-springboot.yml | 30 ++++++++++++++------------- 1 file changed, 16 insertions(+), 14 deletions(-) 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 }}