Skip to content
Latchkey

Playwright Tests workflow (eidolon-ai/eidolon)

The Playwright Tests workflow from eidolon-ai/eidolon, explained and optimized by Latchkey.

F

CI health: F - at risk

Point runs-on at Latchkey and get caching, run de-duplication, job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.

Grade your own workflow free or run it on Latchkey →
Source: eidolon-ai/eidolon.github/workflows/e2e.ymlLicense Apache-2.0View source

What it does

This is the Playwright Tests workflow from the eidolon-ai/eidolon repository, a real project running GitHub Actions. It is shown here with attribution under its Apache-2.0 license.

Below, Latchkey shows a faster, safer version produced by its optimization engine.

The workflow

workflow (.yml)
name: Playwright Tests

on:
  workflow_dispatch:
  push:
    branches: [main]
    paths:
      - '**'
      - '!k8s-operator/**'
      - '!webui/apps/docs/**'
      - '!.all-contributorsrc'
      - '!README.md'
  pull_request_target:
    types: [ opened, synchronize ]
    paths:
      - '**'
      - '!k8s-operator/**'
      - '!webui/apps/docs/**'
      - '!.all-contributorsrc'
      - '!README.md'

jobs:
  test-e2e:
    runs-on: ubuntu-latest

    services:
      mongo:
        image: mongo:latest
        ports:
          - 27017:27017
        options: >-
          --health-cmd="echo 'db.runCommand({ ping: 1 })' | mongosh localhost:27017/test --quiet"
          --health-interval=30s
          --health-timeout=10s
          --health-retries=10

    env:
      AUTH_TRUST_HOST: ${{ secrets.AUTH_TRUST_HOST }}
      EIDOLON_SERVER: ${{ secrets.EIDOLON_SERVER }}
      NEXTAUTH_SECRET: ${{ secrets.NEXTAUTH_SECRET }}
      NEXT_PUBLIC_API_URL: ${{ secrets.NEXT_PUBLIC_API_URL }}
      NEXT_PUBLIC_DEBUG: ${{ secrets.NEXT_PUBLIC_DEBUG }}
      NEXT_PUBLIC_LOG_LEVEL: ${{ secrets.NEXT_PUBLIC_LOG_LEVEL }}
      OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
      CI: true

    steps:
      #     https://michaelheap.com/access-secrets-from-forks/
      #     Allow contributors to run the tests with secret access if it is kicked off by a maintainer
      - name: Get User Permission
        id: checkAccess
        uses: actions-cool/check-user-permission@v2
        with:
          require: write
          username: ${{ github.triggering_actor }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      - name: Check User Permission
        if: steps.checkAccess.outputs.require-result == 'false'
        run: |
          echo "${{ github.triggering_actor }} does not have permissions on this repo."
          echo "Current permission level is ${{ steps.checkAccess.outputs.user-permission }}"
          echo "Job originally triggered by ${{ github.actor }}"
          exit 1
      - name: Checkout code
        uses: actions/checkout@v4
        with:
          ref: ${{  github.event.pull_request.head.sha }} # This is dangerous without the first access check

      - name: Check for OPENAI_API_KEY
        run: |
          if [ -z "${{ secrets.OPENAI_API_KEY }}" ]; then
            echo "OPENAI_API_KEY is not set. Failing the job."
            exit 1
          fi

      - name: Set up Node.js
        uses: actions/setup-node@v3
        with:
          node-version: 18

      - name: Install PNPM
        run: npm install -g pnpm

      - name: Stop conflicting MongoDB containers
        run: |
          CONFLICTING_CONTAINERS=$(docker ps -q --filter "ancestor=mongo:latest" --filter "status=running")
          if [ -n "$CONFLICTING_CONTAINERS" ]; then
            echo "Stopping conflicting MongoDB containers"
            docker stop $CONFLICTING_CONTAINERS
          else
            echo "No conflicting MongoDB containers"
          fi
      - name: Install dependencies
        run: pnpm install
        working-directory: ./webui/apps/eidolon-ui2

      - name: Build Docker images
        run: pnpm run docker:build
        working-directory: ./webui/apps/eidolon-ui2

      - name: Start Docker containers
        run: pnpm run docker:up
        working-directory: ./webui/apps/eidolon-ui2

      - name: Save MongoDB logs
        run: docker logs $(docker ps -q --filter name=mongo) > mongodb-logs.txt

      - name: List Docker containers
        run: docker ps -a

      - name: Install Playwright dependencies
        run: pnpm exec playwright install
        working-directory: ./webui/apps/eidolon-ui2

      - name: Install browsers Playwright
        run: pnpm dlx playwright install
        working-directory: ./webui/apps/eidolon-ui2

      - name: Run Playwright tests
        run: pnpm exec playwright test
        working-directory: ./webui/apps/eidolon-ui2

      - name: Stop Docker containers
        run: pnpm run docker:down
        working-directory: ./webui/apps/eidolon-ui2
        if: always()

      - name: Upload MongoDB logs
        uses: actions/upload-artifact@v3
        if: always()
        with:
          name: mongodb-logs
          path: mongodb-logs.txt

      - name: Upload Playwright test results
        uses: actions/upload-artifact@v3
        if: always()
        with:
          name: playwright-results
          path: |
            webui/apps/eidolon-ui2/tests/test-results
          if-no-files-found: ignore

      - name: Upload Playwright screenshots
        uses: actions/upload-artifact@v3
        if: always()
        with:
          name: playwright-screenshots
          path: webui/apps/eidolon-ui2/tests/screenshots
          if-no-files-found: ignore

The same workflow, on Latchkey

Estimated ~20% faster on cache hits, plus fewer wasted runs and a safer supply chain. Added and changed lines are highlighted.

name: Playwright Tests
 
on:
  workflow_dispatch:
  push:
    branches: [main]
    paths:
      - '**'
      - '!k8s-operator/**'
      - '!webui/apps/docs/**'
      - '!.all-contributorsrc'
      - '!README.md'
  pull_request_target:
    types: [ opened, synchronize ]
    paths:
      - '**'
      - '!k8s-operator/**'
      - '!webui/apps/docs/**'
      - '!.all-contributorsrc'
      - '!README.md'
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  test-e2e:
    timeout-minutes: 30
    runs-on: latchkey-small
 
    services:
      mongo:
        image: mongo:latest
        ports:
          - 27017:27017
        options: >-
          --health-cmd="echo 'db.runCommand({ ping: 1 })' | mongosh localhost:27017/test --quiet"
          --health-interval=30s
          --health-timeout=10s
          --health-retries=10
 
    env:
      AUTH_TRUST_HOST: ${{ secrets.AUTH_TRUST_HOST }}
      EIDOLON_SERVER: ${{ secrets.EIDOLON_SERVER }}
      NEXTAUTH_SECRET: ${{ secrets.NEXTAUTH_SECRET }}
      NEXT_PUBLIC_API_URL: ${{ secrets.NEXT_PUBLIC_API_URL }}
      NEXT_PUBLIC_DEBUG: ${{ secrets.NEXT_PUBLIC_DEBUG }}
      NEXT_PUBLIC_LOG_LEVEL: ${{ secrets.NEXT_PUBLIC_LOG_LEVEL }}
      OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
      CI: true
 
    steps:
      #     https://michaelheap.com/access-secrets-from-forks/
      #     Allow contributors to run the tests with secret access if it is kicked off by a maintainer
      - name: Get User Permission
        id: checkAccess
        uses: actions-cool/check-user-permission@v2
        with:
          require: write
          username: ${{ github.triggering_actor }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      - name: Check User Permission
        if: steps.checkAccess.outputs.require-result == 'false'
        run: |
          echo "${{ github.triggering_actor }} does not have permissions on this repo."
          echo "Current permission level is ${{ steps.checkAccess.outputs.user-permission }}"
          echo "Job originally triggered by ${{ github.actor }}"
          exit 1
      - name: Checkout code
        uses: actions/checkout@v4
        with:
          ref: ${{  github.event.pull_request.head.sha }} # This is dangerous without the first access check
 
      - name: Check for OPENAI_API_KEY
        run: |
          if [ -z "${{ secrets.OPENAI_API_KEY }}" ]; then
            echo "OPENAI_API_KEY is not set. Failing the job."
            exit 1
          fi
 
      - name: Set up Node.js
        uses: actions/setup-node@v3
        with:
          cache: 'npm'
          node-version: 18
 
      - name: Install PNPM
        run: npm install -g pnpm
 
      - name: Stop conflicting MongoDB containers
        run: |
          CONFLICTING_CONTAINERS=$(docker ps -q --filter "ancestor=mongo:latest" --filter "status=running")
          if [ -n "$CONFLICTING_CONTAINERS" ]; then
            echo "Stopping conflicting MongoDB containers"
            docker stop $CONFLICTING_CONTAINERS
          else
            echo "No conflicting MongoDB containers"
          fi
      - name: Install dependencies
        run: pnpm install
        working-directory: ./webui/apps/eidolon-ui2
 
      - name: Build Docker images
        run: pnpm run docker:build
        working-directory: ./webui/apps/eidolon-ui2
 
      - name: Start Docker containers
        run: pnpm run docker:up
        working-directory: ./webui/apps/eidolon-ui2
 
      - name: Save MongoDB logs
        run: docker logs $(docker ps -q --filter name=mongo) > mongodb-logs.txt
 
      - name: List Docker containers
        run: docker ps -a
 
      - name: Install Playwright dependencies
        run: pnpm exec playwright install
        working-directory: ./webui/apps/eidolon-ui2
 
      - name: Install browsers Playwright
        run: pnpm dlx playwright install
        working-directory: ./webui/apps/eidolon-ui2
 
      - name: Run Playwright tests
        run: pnpm exec playwright test
        working-directory: ./webui/apps/eidolon-ui2
 
      - name: Stop Docker containers
        run: pnpm run docker:down
        working-directory: ./webui/apps/eidolon-ui2
        if: always()
 
      - name: Upload MongoDB logs
        uses: actions/upload-artifact@v3
        if: always()
        with:
          name: mongodb-logs
          path: mongodb-logs.txt
 
      - name: Upload Playwright test results
        uses: actions/upload-artifact@v3
        if: always()
        with:
          name: playwright-results
          path: |
            webui/apps/eidolon-ui2/tests/test-results
          if-no-files-found: ignore
 
      - name: Upload Playwright screenshots
        uses: actions/upload-artifact@v3
        if: always()
        with:
          name: playwright-screenshots
          path: webui/apps/eidolon-ui2/tests/screenshots
          if-no-files-found: ignore

What changed

1 third-party action is referenced by a movable tag. Pin it to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.

What Latchkey heals here

This workflow has steps that commonly fail on transient issues (network, registries, flaky browsers). On Latchkey managed runners they are detected, retried, and self-healed instead of failing your build:

This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow