Skip to content

About

Run Midscene Test tests in GitHub Actions, with reports you can download or share.

Resources

Contributing

Stars

2 stars

Watchers

0 watching

Forks

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

Midscene GitHub Action

CI Latest version MIT License

English | 简体中文

Run Midscene Test tests in GitHub Actions, with reports you can download or share.

Features

  • Test results in the workflow summary.
  • HTML reports and test data uploaded as artifacts.
  • Optional report hosting on Cloudflare Workers, with a URL for each run.
  • SIWC session preparation and parallel execution, with one refresh owner and access-only test jobs.

Examples

  • Basic: submit a greeting form with AI and check the result.
  • TodoMVC: manage todos with AI and verify the results with custom Nodes.
  • ExternalAssets: generate an html-and-external-assets report with a model-free test.

Usage

Add the Action to your workflow:

- uses: web-infra-dev/midscene-action@v1
  with:
    working-directory: tests/midscene

By default, the Action runs npx midscene-test. Set command to use a different test command, such as npm test.

Install your test dependencies and browsers, configure your model, and start any application under test before running the Action.

Example workflow

For a Playwright project in tests/midscene:

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_FAMILY: ${{ vars.MIDSCENE_MODEL_FAMILY }}
      MIDSCENE_MODEL_BASE_URL: ${{ vars.MIDSCENE_MODEL_BASE_URL }}
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-node@v6
        with:
          node-version: '24'
      - name: Install dependencies and browser
        working-directory: tests/midscene
        run: |
          npm ci
          npx playwright install --with-deps chromium
      - name: Run Midscene tests
        id: midscene
        uses: web-infra-dev/midscene-action@v1
        with:
          working-directory: tests/midscene
          command: npm test

Set the model secret and variables used above in your repository's Settings → Secrets and variables → Actions.

Inputs

See action.yml for the full definitions.

Input Required Default Description
working-directory Yes None Test project directory, relative to the workspace. Use . for the repository root.
command No npx midscene-test Command to run Midscene tests in Bash. Override it with a project script such as npm test if needed.
artifact-name No midscene-results Artifact name. Must be unique within a workflow run.
retention-days No 14 Artifact retention period in days.
publish-pages No false Set to true to publish reports to Cloudflare Workers.
cloudflare-api-token When publishing None Cloudflare API token, passed from a GitHub Actions secret.
cloudflare-account-id When publishing None Cloudflare account ID.
cloudflare-worker-name No midscene-reports Worker name. Created automatically if needed and the token has permission.

Publish reports to Cloudflare Workers

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

  • 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 setup Preparation API 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 Worker Set 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.

Then enable publishing:

- name: Run tests and publish reports
  id: midscene
  uses: web-infra-dev/midscene-action@v1
  with:
    working-directory: tests/midscene
    command: npm 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.

Reports

Open the workflow run's Summary for test results and artifact downloads. Published reports also have an online preview link.

Results are collected from midscene_run/ by default. Set MIDSCENE_RUN_DIR to use another artifact root. Relative paths resolve from working-directory; absolute paths are also supported. An unset or empty value uses the default.

To save results under artifacts/, set the environment variable:

- uses: web-infra-dev/midscene-action@v1
  with:
    working-directory: tests/midscene
  env:
    MIDSCENE_RUN_DIR: artifacts

Note

Using MIDSCENE_RUN_DIR for test outputs requires @midscene/test > 1.17.5.

Test results, report download, and online report links in the Summary

Outputs

Set id: midscene on the Action step to read its outputs with ${{ steps.midscene.outputs.<name> }}:

Output Description
test-result Outcome of the test command.
report-artifact-name Name of the uploaded artifact, or empty if no files were uploaded.
artifact-url Download page for the uploaded artifact.
page-url Published report URL, or empty if publishing did not succeed.
publication-result Deployment outcome: success, failure, skipped, or cancelled.

Contributing

See the Contributing Guide.

License

MIT.

Built with Midscene and Cloudflare Workers.

About

Run Midscene Test tests in GitHub Actions, with reports you can download or share.

Resources

Contributing

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages