• English
  • Run in GitHub Actions

    Midscene provides midscene-action to run Midscene Test in GitHub Actions.

    • Automatically add test results to the workflow Summary.
    • Save HTML reports and test data as artifacts for download.
    • Optionally publish reports to Cloudflare Workers for online previews.

    If you do not have a test project yet, start with Create and use test projects.

    Examples

    • Basic: submit a greeting form with AI and check the result.
    • TodoMVC: manage todos with AI and verify the results with custom Nodes.

    Add the Action to your workflow

    Before running the Action, install test dependencies, prepare browsers or devices, and configure your model. Then add this step to your workflow:

    - name: Run Midscene tests
      id: midscene
      uses: web-infra-dev/midscene-action@v1
      with:
        working-directory: tests/midscene
        command: pnpm test
    • working-directory: The test project path relative to the repository root. Use . if the project is at the root.
    • command: The command to run in the test project directory. It defaults to npx midscene-test; you can use your project's test command, such as pnpm test.

    Complete workflow example

    This example uses a test project in tests/midscene. Before integrating, verify that the project runs locally.

    1. Configure the model

    In your GitHub repository's Settings → Secrets and variables → Actions, add:

    TypeNamePurpose
    SecretMIDSCENE_MODEL_API_KEYAPI Key for the model service.
    VariableMIDSCENE_MODEL_NAMEModel name.
    VariableMIDSCENE_MODEL_BASE_URLModel service URL.
    VariableMIDSCENE_MODEL_FAMILYModel family, according to the selected model.

    Use the same model settings as for local runs; see Supported models & setup for specific values.

    2. Add a workflow file

    Create .github/workflows/midscene.yml:

    name: Midscene E2E Tests
    
    on:
      push:
      workflow_dispatch:
    
    permissions:
      contents: read
    
    jobs:
      test:
        runs-on: ubuntu-24.04
        timeout-minutes: 20
        env:
          MIDSCENE_MODEL_API_KEY: ${{ secrets.MIDSCENE_MODEL_API_KEY }}
          MIDSCENE_MODEL_NAME: ${{ vars.MIDSCENE_MODEL_NAME }}
          MIDSCENE_MODEL_BASE_URL: ${{ vars.MIDSCENE_MODEL_BASE_URL }}
          MIDSCENE_MODEL_FAMILY: ${{ vars.MIDSCENE_MODEL_FAMILY }}
        steps:
          - uses: actions/checkout@v6
          - uses: pnpm/action-setup@v4
            with:
              version: 9.3.0
          - uses: actions/setup-node@v6
            with:
              node-version: '24'
          - name: Install dependencies and browser
            working-directory: tests/midscene
            run: |
              pnpm install --frozen-lockfile
              pnpm exec playwright install --with-deps chromium
          - name: Run Midscene tests
            id: midscene
            uses: web-infra-dev/midscene-action@v1
            with:
              working-directory: tests/midscene
              command: pnpm test

    Adjust working-directory and command for your project. See the midscene-action documentation for the full list of parameters.

    3. Publish reports to Cloudflare Workers (optional)

    Set publish-pages: true to publish reports to Cloudflare Workers. Each run gets its own preview URL in the workflow Summary.

    Hosting costs and limits
    • Free hosting: no charge for static asset storage or requests. Billing details
    • Retention: up to 100 Previews per Worker on the free plan. Cloudflare removes the least recently deployed Preview when the limit is reached. Preview limits
    • Limits: up to 20,000 files per Worker version and 25 MiB per file on the free plan. Platform limits

    Create an API token

    Choose the token permissions for your Worker setup:

    Worker setupPreparationAPI token permissions
    ⭐ Use an existing Worker (recommended)
    • Create a Worker in Workers & Pages and set cloudflare-worker-name to its name.
    • Enable Preview under Domains → Worker URL.
    Worker Preview toggle
    Choose Specified Workers, select your Worker, and grant Individual Workers → Editor.

    Editor permissions for a specific Worker
    Let the Action create a WorkerSet cloudflare-worker-name to the name you want to use.Choose Entire Account and grant Workers → Admin. This allows access to all Workers in the account.

    Workers product-level Admin permissions

    Save the API token and Account ID from the confirmation dialog. The token is shown only once.

    Enable publishing

    In Settings → Secrets and variables → Actions, add:

    • CLOUDFLARE_API_TOKEN as a repository secret.
    • CLOUDFLARE_ACCOUNT_ID as a repository variable.

    Update the test Action step from the workflow above:

    - name: Run tests and publish reports
      id: midscene
      uses: web-infra-dev/midscene-action@v1
      with:
        working-directory: tests/midscene
        command: pnpm test
        publish-pages: true
        cloudflare-api-token: ${{ secrets.CLOUDFLARE_API_TOKEN }}
        cloudflare-account-id: ${{ vars.CLOUDFLARE_ACCOUNT_ID }}

    To use an existing Worker, set cloudflare-worker-name to its name. The default is midscene-reports.

    4. View test reports

    After the tests finish, view test results and report links in the workflow Summary.

    Test summary, report download, and online preview links in the workflow Summary

    Read Action outputs

    Set id: midscene on the Action step, then read its outputs through ${{ steps.midscene.outputs.<name> }}:

    OutputPurpose
    test-resultOutcome of the test command.
    artifact-urlDownload page for the uploaded artifact.
    report-artifact-nameUploaded artifact name; empty if no files were uploaded.
    page-urlOnline report URL; empty if publishing did not succeed.
    publication-resultPublishing step outcome: success, failure, skipped, or cancelled.