Improving playwright GitHub Actions

This commit is contained in:
rockstardev 2025-10-16 09:44:03 -05:00
parent 87bb60ebed
commit 8b4cf378c9
No known key found for this signature in database
GPG Key ID: 4F224698945A6EE7
4 changed files with 70 additions and 44 deletions

63
.github/workflows/playwright.yml vendored Normal file
View File

@ -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

View File

@ -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

View File

@ -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'] }}

View File

@ -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