name: CI compile & test & build on: push: branches: [ "dev" ] pull_request: branches: [ "dev" ] workflow_dispatch: inputs: frontend_image: description: 'Frontend image to use in E2E tests (optional)' required: false default: 'ghcr.io/morbalint/kemkas-frontend:latest' e2e_image: description: 'E2E image to use in E2E tests (optional)' required: false default: 'ghcr.io/morbalint/kemkas-frontend:latest' jobs: test-and-build: runs-on: ubuntu-latest permissions: contents: read packages: write attestations: write id-token: write outputs: image_sha_tag: ${{ steps.image-tag.outputs.image_sha_tag }} steps: - uses: actions/checkout@v6 - uses: actions/setup-dotnet@v5 with: dotnet-version: 10.0.x - name: Run unit tests run: dotnet test Kemkas.slnx -c Release - uses: docker/setup-buildx-action@v4 - name: Log in to GitHub Container Registry uses: docker/login-action@v4 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Compute image tag id: image-tag run: | image_repo="ghcr.io/${{ github.repository_owner }}/kemkas-backend" sha_tag="${image_repo}:${GITHUB_SHA::8}" tags="$sha_tag" if [[ "${GITHUB_REF}" == "refs/heads/main" ]]; then tags+=$'\n'"${image_repo}:latest" fi echo "image_sha_tag=${sha_tag}" >> "$GITHUB_OUTPUT" { echo "tags<> "$GITHUB_OUTPUT" - uses: docker/build-push-action@v7 with: context: . file: Kemkas.Web/Dockerfile cache-from: type=gha cache-to: type=gha,mode=max push: true load: true tags: | ${{ steps.image-tag.outputs.tags }} e2e: runs-on: ubuntu-latest needs: - test-and-build permissions: contents: read packages: read env: BACKEND_IMAGE: ${{ needs.test-and-build.outputs.image_sha_tag }} FRONTEND_IMAGE: ${{ github.event.inputs.frontend_image || 'ghcr.io/morbalint/kemkas-frontend:latest' }} E2E_IMAGE: ${{ github.event.inputs.e2e_image || 'ghcr.io/morbalint/kemkas-e2e:latest' }} steps: - uses: actions/checkout@v6 - name: Log in to GitHub Container Registry uses: docker/login-action@v4 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Setup docker compose uses: docker/setup-compose-action@v2 - name: Pull images for test run run: docker compose -f e2e.docker-compose.yaml pull - name: Run Docker Compose E2E tests run: docker compose -f e2e.docker-compose.yaml up --no-build --abort-on-container-exit --exit-code-from e2e e2e - name: Print logs if: failure() run: docker compose -f e2e.docker-compose.yaml logs - name: Upload Playwright HTML report if: always() uses: actions/upload-artifact@v7 with: name: playwright-report path: e2e/playwright-report if-no-files-found: ignore - name: Upload Playwright test results if: always() uses: actions/upload-artifact@v7 with: name: playwright-test-results path: e2e/test-results if-no-files-found: ignore - name: Tear down Docker Compose stack if: always() run: docker compose -f e2e.docker-compose.yaml down -v --remove-orphans