diff --git a/.github/workflows/docker-build-publish.yml b/.github/workflows/docker-build-publish.yml index a83ecbb76..a0230f14b 100644 --- a/.github/workflows/docker-build-publish.yml +++ b/.github/workflows/docker-build-publish.yml @@ -12,6 +12,8 @@ jobs: permissions: contents: write packages: write + issues: read + checks: write pull-requests: write steps: @@ -39,6 +41,52 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + # Set up Java for backend tests + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + java-version: '21' + distribution: 'temurin' + + # Run backend tests with testcontainers + - name: Run Backend Tests + id: backend_tests + working-directory: ./booklore-api + run: | + echo "Running backend tests with testcontainers..." + ./gradlew test + continue-on-error: true + + # Publish test results + - name: Publish Test Results + uses: EnricoMi/publish-unit-test-result-action@v2 + if: always() + with: + files: | + booklore-api/build/test-results/**/*.xml + check_name: Backend Test Results + comment_title: Backend Test Results + report_individual_runs: true + report_suite_logs: 'any' + + # Upload test reports as artifacts + - name: Upload Test Reports + uses: actions/upload-artifact@v4 + if: always() + with: + name: test-reports + path: | + booklore-api/build/reports/tests/ + booklore-api/build/test-results/ + retention-days: 30 + + # Fail the workflow if tests failed + - name: Check Test Results + if: steps.backend_tests.outcome == 'failure' + run: | + echo "❌ Backend tests failed! Check the test results above." + exit 1 + - name: Get Latest Master Version id: get_version run: | @@ -119,8 +167,8 @@ jobs: docker buildx build \ --platform linux/amd64,linux/arm64 \ --build-arg APP_VERSION=${{ env.image_tag }} \ - --tag booklore/booklore:${{ env.image_tag }} \ - --tag ghcr.io/booklore-app/booklore:${{ env.image_tag }} \ + --tag ${{ secrets.DOCKER_USERNAME }}/booklore:${{ env.image_tag }} \ + --tag ghcr.io/${{ github.actor }}/booklore:${{ env.image_tag }} \ --push . - name: Push Latest Tag (Only for Master) @@ -129,8 +177,8 @@ jobs: docker buildx build \ --platform linux/amd64,linux/arm64 \ --build-arg APP_VERSION=${{ env.new_tag }} \ - --tag booklore/booklore:latest \ - --tag ghcr.io/booklore-app/booklore:latest \ + --tag ${{ secrets.DOCKER_USERNAME }}/booklore:latest \ + --tag ghcr.io/${{ github.actor }}/booklore:latest \ --push . - name: Create Git Tag (Only for Master) @@ -151,6 +199,7 @@ jobs: - name: Notify Discord of New Release if: github.ref == 'refs/heads/master' + continue-on-error: true shell: bash env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -193,4 +242,4 @@ jobs: echo "$payload" echo "=======================" - curl -H "Content-Type: application/json" -d "$payload" "$DISCORD_WEBHOOK_URL" \ No newline at end of file + curl -H "Content-Type: application/json" -d "$payload" "$DISCORD_WEBHOOK_URL" diff --git a/Dockerfile b/Dockerfile index 581e0792b..bf59ab194 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,7 +22,7 @@ ARG APP_VERSION RUN apk add --no-cache yq && \ yq eval '.app.version = strenv(APP_VERSION)' -i /springboot-app/src/main/resources/application.yaml -RUN gradle clean build +RUN gradle clean build -x test # Stage 3: Final image FROM eclipse-temurin:21-jre-alpine