From 8b4cf378c981036b1b177ea8d946952ceafe3d13 Mon Sep 17 00:00:00 2001 From: rockstardev <5191402+rockstardev@users.noreply.github.com> Date: Thu, 16 Oct 2025 09:44:03 -0500 Subject: [PATCH] Improving playwright GitHub Actions --- .github/workflows/playwright.yml | 63 ++++++++++++++++++++++++++++++++ .github/workflows/pr-tests.yml | 38 ------------------- .github/workflows/tag.yml | 10 ++--- btcpayserver-plugin-builder.sln | 3 +- 4 files changed, 70 insertions(+), 44 deletions(-) create mode 100644 .github/workflows/playwright.yml delete mode 100644 .github/workflows/pr-tests.yml diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml new file mode 100644 index 0000000..6012427 --- /dev/null +++ b/.github/workflows/playwright.yml @@ -0,0 +1,63 @@ +name: PluginBuilder Tests + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + test: + runs-on: ubuntu-latest + env: + CI: true + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup .NET 8 + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + + - name: Build solution + run: dotnet build --configuration Release + + - name: Cache Playwright browsers + uses: actions/cache@v4 + id: playwright-cache + with: + path: ~/.cache/ms-playwright + key: ${{ runner.os }}-playwright-${{ hashFiles('**/PluginBuilder.Tests.csproj') }} + restore-keys: | + ${{ runner.os }}-playwright- + + - name: Install Playwright CLI + browsers (full install) + if: steps.playwright-cache.outputs.cache-hit != 'true' + run: | + dotnet tool install --global Microsoft.Playwright.CLI + export PATH="$PATH:$HOME/.dotnet/tools" + playwright install --with-deps + + - name: Install Playwright CLI only (cache hit) + if: steps.playwright-cache.outputs.cache-hit == 'true' + run: | + dotnet tool install --global Microsoft.Playwright.CLI + export PATH="$PATH:$HOME/.dotnet/tools" + + - name: Start Docker containers + env: + # Enable BuildKit for faster builds and better layer caching within the run + # Note: This does NOT persist cache between GitHub Actions runs (ephemeral runners) + # but provides ~5-10s speed improvement from BuildKit's optimized build engine + DOCKER_BUILDKIT: 1 + COMPOSE_DOCKER_CLI_BUILD: 1 + run: docker compose -f PluginBuilder.Tests/docker-compose.yml up -d --build + + - name: Run tests + run: dotnet test PluginBuilder.Tests --verbosity normal + + - name: Cleanup Docker + if: always() + run: docker compose -f PluginBuilder.Tests/docker-compose.yml down --volumes diff --git a/.github/workflows/pr-tests.yml b/.github/workflows/pr-tests.yml deleted file mode 100644 index 4d63bd8..0000000 --- a/.github/workflows/pr-tests.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: PluginBuilder Tests - -on: - pull_request: - branches: [ "master" ] - -jobs: - test: - runs-on: ubuntu-latest - env: - CI: true - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Setup .NET 8 - uses: actions/setup-dotnet@v4 - with: - dotnet-version: 8.0.x - - - name: Build solution - run: dotnet build --configuration Release - - - name: Install Playwright CLI + browsers - run: | - dotnet tool install --global Microsoft.Playwright.CLI - playwright install --with-deps - - - name: Start Docker containers - run: docker compose -f PluginBuilder.Tests/docker-compose.yml up -d --build - - - name: Run tests - run: dotnet test PluginBuilder.Tests --verbosity normal - - - name: Cleanup Docker - if: always() - run: docker compose -f PluginBuilder.Tests/docker-compose.yml down --volumes diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml index d4038e7..e6f3135 100644 --- a/.github/workflows/tag.yml +++ b/.github/workflows/tag.yml @@ -15,19 +15,19 @@ jobs: uses: actions/checkout@v3 - name: Set env run: echo "VERSION=${GITHUB_REF##*/v}" >> $GITHUB_ENV - + - name: Log in to Docker Hub uses: docker/login-action@v2.1.0 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - + - name: Extract metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@v4.1.1 with: images: ${{ env.DOCKERHUB_REPO }} - + - name: Build and push Docker image uses: docker/build-push-action@v3.2.0 with: @@ -36,5 +36,5 @@ jobs: tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} build-args: | - VERSION=${{ env.VERSION }} - GIT_COMMIT=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }} + VERSION=${{ env.VERSION }} + GIT_COMMIT=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }} diff --git a/btcpayserver-plugin-builder.sln b/btcpayserver-plugin-builder.sln index f4ccea6..53106d8 100644 --- a/btcpayserver-plugin-builder.sln +++ b/btcpayserver-plugin-builder.sln @@ -11,9 +11,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Misc", "Misc", "{01892AE1-B ProjectSection(SolutionItems) = preProject Dockerfile = Dockerfile README.md = README.md - .github\workflows\tag.yml = .github\workflows\tag.yml Cleanup.md = Cleanup.md .editorconfig = .editorconfig + .github\workflows\playwright.yml = .github\workflows\playwright.yml + .github\workflows\tag.yml = .github\workflows\tag.yml EndProjectSection EndProject Global