diff --git a/.github/workflows/master-pipeline.yml b/.github/workflows/master-pipeline.yml index b60182ad8..3ac999cc7 100644 --- a/.github/workflows/master-pipeline.yml +++ b/.github/workflows/master-pipeline.yml @@ -28,10 +28,119 @@ jobs: base_ref: ${{ needs.get-base-ref.outputs.base_ref }} head_ref: ${{ github.sha }} - build-and-release: + backend-tests: + name: Backend Tests needs: [ migration-check ] if: needs.migration-check.result == 'success' || needs.migration-check.result == 'skipped' runs-on: ubuntu-latest + + permissions: + contents: read + checks: write + pull-requests: write + + steps: + - name: Checkout Repository + uses: actions/checkout@v6 + + - name: Set Up JDK 21 + uses: actions/setup-java@v5 + with: + java-version: '21' + distribution: 'temurin' + cache: gradle + + - name: Execute Backend Tests + id: backend_tests + working-directory: ./booklore-api + run: | + echo "Running backend tests..." + ./gradlew test --no-daemon --parallel --build-cache + continue-on-error: true + + - name: Publish Backend 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 + + - name: Upload Backend Test Reports + uses: actions/upload-artifact@v6 + if: always() + with: + name: backend-test-reports + path: | + booklore-api/build/reports/tests/ + booklore-api/build/test-results/ + retention-days: 30 + + - name: Validate Backend Test Results + if: steps.backend_tests.outcome == 'failure' + run: | + echo "❌ Backend tests failed" + exit 1 + + frontend-tests: + name: Frontend Tests + needs: [ migration-check ] + if: needs.migration-check.result == 'success' || needs.migration-check.result == 'skipped' + runs-on: ubuntu-latest + + permissions: + contents: read + checks: write + pull-requests: write + + steps: + - name: Checkout Repository + uses: actions/checkout@v6 + + - name: Set Up Node.js + uses: actions/setup-node@v4 + with: + node-version: '22' + cache: 'npm' + cache-dependency-path: booklore-ui/package-lock.json + + - name: Install Frontend Dependencies + working-directory: ./booklore-ui + run: npm ci --force + + - name: Execute Frontend Tests + id: frontend_tests + working-directory: ./booklore-ui + run: | + echo "Running frontend tests..." + npx ng test + continue-on-error: true + + - name: Publish Frontend Test Results + uses: EnricoMi/publish-unit-test-result-action@v2 + if: always() + with: + files: booklore-ui/test-results/vitest-results.xml + check_name: Frontend Test Results + + - name: Upload Frontend Test Reports + uses: actions/upload-artifact@v6 + if: always() + with: + name: frontend-test-reports + path: | + booklore-ui/test-results/vitest-results.xml + retention-days: 30 + + - name: Validate Frontend Test Results + if: steps.frontend_tests.outcome == 'failure' + run: | + echo "❌ Frontend tests failed" + exit 1 + + build-and-release: + needs: [ backend-tests, frontend-tests ] + if: needs.backend-tests.result == 'success' && needs.frontend-tests.result == 'success' + runs-on: ubuntu-latest permissions: contents: write packages: write @@ -62,28 +171,6 @@ jobs: - name: Set Up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Set Up JDK 21 - uses: actions/setup-java@v5 - with: - java-version: '21' - distribution: 'temurin' - cache: 'gradle' - - - name: Set Up Node.js - uses: actions/setup-node@v4 - with: - node-version: '22' - cache: 'npm' - cache-dependency-path: booklore-ui/package-lock.json - - - name: Install Frontend Dependencies - working-directory: ./booklore-ui - run: npm ci --force - - - name: Execute Frontend Tests - working-directory: ./booklore-ui - run: npm run test:ci - - name: Retrieve Latest Master Version Tag id: get_version run: |