Skip to content

Try out namespace.so GitHub actions runners #917

Try out namespace.so GitHub actions runners

Try out namespace.so GitHub actions runners #917

Workflow file for this run

name: E2E Tests
on:
push:
branches: ['trunk']
pull_request:
permissions:
contents: read
jobs:
e2e:
name: Run E2E test
runs-on: namespace-profile-playwright
env:
# renovate: datasource=node-version depName=node
NODE_VERSION: 20
COMMENT_TAG: 'playwright-report-link'
defaults:
run:
working-directory: e2e-test
steps:
- name: Checkout
uses: namespacelabs/nscloud-checkout-action@v5
- name: Setup cache
uses: namespacelabs/nscloud-cache-action@v1
with:
path: |
~/.npm
~/.cache/ms-playwright
./node_modules
- name: Stop apt cleaning cache
run: rm /etc/apt/apt.conf.d/docker-clean
- uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4
with:
node-version: '${{env.NODE_VERSION}}'
- name: Install playwright deps
run: |
npm ci
npx playwright install --with-deps
- name: list apt cache
run: |
ls -lah /etc/apt/apt.conf.d/
echo '-----'
ls -lah /var/cache/apt
echo '-----'
tree /var/cache/apt || echo 'treeless'
- name: Breakpoint if tests failed
uses: namespacelabs/breakpoint-action@v0
with:
duration: 10m
authorized-users: annervisser
- name: Run e2e tests
id: run-e2e-tests
env:
PW_WORKERS: '100%'
run: ../bin/e2e
- name: Output docker compose logs
if: ${{ !cancelled() }}
run: docker compose logs | tee playwright-report/docker.log
- name: Upload HTML report to S3
if: ${{ !cancelled() }}
id: upload-html-report-to-s3
env:
AWS_ACCESS_KEY_ID: ${{ secrets.PW_REPORTS_BUCKET_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.PW_REPORTS_BUCKET_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: 'auto'
TIGRIS_ENDPOINT: 'https://fly.storage.tigris.dev'
BUCKET_NAME: 'pr-cli-playwright-reports'
BUCKET_PUBLIC_ENDPOINT: 'https://pr-cli-playwright-reports.fly.storage.tigris.dev'
run: |
CONTEXT="${{ github.event.pull_request.number || github.event.issue.number || github.sha }}"
S3_FOLDER="$(date +%Y%m%d)-$CONTEXT-$(uuidgen | cut -c1-8)"
echo "::debug::Folder: $S3_FOLDER"
LOCAL_FOLDER="playwright-report"
REPORT_URL="$BUCKET_PUBLIC_ENDPOINT/$S3_FOLDER"
echo "::notice::Playwright report: $REPORT_URL/index.html"
echo "REPORT_URL=$REPORT_URL" >> "$GITHUB_OUTPUT"
# Add PR number to title in index.html
sed -i -r "s%<title>(.*)</title>%<title>pr $CONTEXT - \1</title>%" "$LOCAL_FOLDER/index.html"
aws s3 cp --endpoint-url "$TIGRIS_ENDPOINT" \
"$LOCAL_FOLDER" "s3://$BUCKET_NAME/$S3_FOLDER" \
--recursive \
--no-progress
# Generate a GH_TOKEN for the PW Comment App
# This allows commenting on PRs from forks
# and adds a profile picture and name to the comments
- name: Generate a token
if: ${{ github.event_name == 'pull_request' && !cancelled() }}
id: generate-comment-app-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ vars.PW_REPORTS_COMMENT_APP_ID }}
private-key: ${{ secrets.PW_REPORTS_COMMENT_APP_PRIVATE_KEY }}
- name: Comment link to HTML report
if: ${{ !cancelled() && steps.generate-comment-app-token.outcome == 'success' && steps.upload-html-report-to-s3.outcome == 'success' }}
uses: thollander/actions-comment-pull-request@v3
with:
message: |
${{ steps.run-e2e-tests.outcome == 'success' && ':white_check_mark: Playwright tests passed' || ':x: Playwright tests failed' }}
[🎭 Report](${{ steps.upload-html-report-to-s3.outputs.REPORT_URL }}/index.html)
[🐋 Docker logs](${{ steps.upload-html-report-to-s3.outputs.REPORT_URL }}/docker.log)
comment-tag: ${{ env.COMMENT_TAG }}
create-if-not-exists: '${{ steps.run-e2e-tests.outcome }}' # Don't post comment for success, but update if commented before
github-token: ${{ steps.generate-comment-app-token.outputs.token }}
- name: Comment link to HTML report (On failure)
if: ${{ !cancelled() && steps.generate-comment-app-token.outcome == 'success' && steps.upload-html-report-to-s3.outcome == 'failure'}}
uses: thollander/actions-comment-pull-request@v3
with:
message: 🎭 Latest playwright run was cancelled or failed
comment-tag: ${{ env.COMMENT_TAG }}
github-token: ${{ steps.generate-comment-app-token.outputs.token }}
- name: Store HTML report as GitHub Artifact
if: ${{ !cancelled() }}
uses: namespace-actions/upload-artifact@v0
with:
name: playwright-html-report
path: e2e-test/playwright-report
retention-days: 5