Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
devops: add Trace Viewer deployment (#10154)
Max Schmitt51910b7a01f4
diff --git a/.github/workflows/publish_canary.yml b/.github/workflows/publish_canary.ymlindex 64847dc6b6..6baea90e0e 100644--- a/.github/workflows/publish_canary.yml+++ b/.github/workflows/publish_canary.yml@@ -53,3 +53,17 @@ jobs:--data "{\"event_type\": \"build_docker_canary\", \"client_payload\": {\"ref\": \"${{ github.sha }}\", \"package_version\": \"${VERSION}\"}}" \https://api.github.com/repos/microsoft/playwright-internal/dispatches+ publish-trace-viewer:+ name: "publish Trace Viewer to trace.playwright.dev"+ runs-on: ubuntu-20.04+ if: github.repository == 'microsoft/playwright'+ steps:+ - uses: actions/checkout@v2+ - uses: actions/setup-node@v2+ with:+ node-version: 16+ - run: npm i -g npm@7+ - name: Deploy+ run: bash utils/build/deploy-trace-viewer.sh canary+ env:+ GH_SERVICE_ACCOUNT_TOKEN: ${{ secrets.GH_SERVICE_ACCOUNT_TOKEN }}diff --git a/.github/workflows/publish_release.yml b/.github/workflows/publish_release.ymlindex e529a211a5..a7d74488a8 100644--- a/.github/workflows/publish_release.yml+++ b/.github/workflows/publish_release.yml@@ -55,3 +55,18 @@ jobs:-H "Authorization: token ${{ secrets.REPOSITORY_DISPATCH_PERSONAL_ACCESS_TOKEN }}" \--data "{\"event_type\": \"build_docker_production\", \"client_payload\": {\"ref\": \"${{ github.sha }}\"}}" \https://api.github.com/repos/microsoft/playwright-internal/dispatches++ publish-trace-viewer:+ name: "publish Trace Viewer to trace.playwright.dev"+ runs-on: ubuntu-20.04+ if: github.repository == 'microsoft/playwright'+ steps:+ - uses: actions/checkout@v2+ - uses: actions/setup-node@v2+ with:+ node-version: 16+ - run: npm i -g npm@7+ - name: Deploy+ run: bash utils/build/deploy-trace-viewer.sh canary+ env:+ GH_SERVICE_ACCOUNT_TOKEN: ${{ secrets.GH_SERVICE_ACCOUNT_TOKEN }}diff --git a/utils/build/deploy-trace-viewer.sh b/utils/build/deploy-trace-viewer.shnew file mode 100755index 0000000000..d2dfed925a--- /dev/null+++ b/utils/build/deploy-trace-viewer.sh@@ -0,0 +1,70 @@+#!/bin/bash++set -e++if [[ ($1 == '--help') || ($1 == '-h') ]]; then+ echo "usage: $(basename $0) {canary,production}"+ echo+ echo "Build the Trace Viewer and push it to the GitHub repository."+ echo+ echo "NOTE: the following env variables are required:"+ echo " GH_SERVICE_ACCOUNT_TOKEN GitHub token with access to the microsoft/playwright-trace repository"+ echo " GITHUB_SHA GitHub commit SHA - injected via GitHub Actions"+ echo+ echo "This script is designed to get executed via GitHub Actions"+ exit 0+fi++if [[ -z "${GH_SERVICE_ACCOUNT_TOKEN}" ]]; then+ echo "NOTE: GH_SERVICE_ACCOUNT_TOKEN environment variable is required"+ exit 1+fi++ENVIRONMENT="$1"++# 1. Install dependencies and build the Trace Viewer+npm ci+npm run build++# 2. Configure Git and clone the Trace Viewer repository+git config --global user.name github-actions+git config --global user.email 41898282+github-actions[bot]@users.noreply.github.com+git clone "https://${GH_SERVICE_ACCOUNT_TOKEN}@github.com/microsoft/playwright-trace.git" playwright-trace++# 3. Copy the built Trace Viewer to the repository+if [[ "${ENVIRONMENT}" == "production" ]]; then+ # 3.1 make a copy of the current next/ folder+ if [[ -d "playwright-trace/docs/next" ]]; then+ cp -r playwright-trace/docs/next .next-previous+ fi+ # 3.2 Clean it+ rm -rf playwright-trace/docs/+ mkdir playwright-trace/docs/+ # 3.3 Copy the old next/ back into the folder+ if [[ -d ".next-previous/" ]]; then+ mv .next-previous/ playwright-trace/docs/next/+ fi+ # 3.4 Copy the new production over+ cp -r packages/playwright-core/lib/webpack/traceViewer/* playwright-trace/docs/+ echo "Updated production version"+elif [[ "${ENVIRONMENT}" == "canary" ]]; then+ rm -rf playwright-trace/docs/next/+ cp -r packages/playwright-core/lib/webpack/traceViewer/ playwright-trace/docs/next/+ echo "Updated canary version"+else+ echo "ERROR: unknown environment - ${ENVIRONMENT}"+ exit 1+fi++# 4. Commit and push the changes+cd playwright-trace/+git add .+if [[ "$(git status --porcelain)" == "" ]]; then+ echo "there are no changes";+ exit 0;+fi+git commit -m "Update Trace Viewer+Upstream commit: https://github.com/microsoft/playwright/commit/$GITHUB_SHA"+git push origin++echo "Pushed changes successfully!"