Skip to content

Github action to execute a command with the mabl cli

License

Notifications You must be signed in to change notification settings

mablhq/setup-mabl-cli

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

mabl logo

setup-mabl-cli

GitHub action to configure the mabl-cli command-line client. It installs and configures the CLI with a mabl API key, if one is provided. Note that API keys should be stored as GitHub secrets.

This action requires Node.js 18+ be installed as part of your workflow. The mabl-cli will be installed into that Node.js runtime.
See below for an example of how to install Node.js.

Inputs

  • version {string} {optional} The version of the CLI to install. Defaults to the latest version if not specified.
  • workspace-id {string} {optional} A workspace id to configure. If provided, all future calls to the CLI will use this workspace by default.

Environment variables

  • MABL_API_KEY {string} {optional} If provided, this action will authenticate with the mabl CLI using the MABL_API_KEY. This is required if you also pass in a workspace-id.

    The MABL_API_KEY should be stored as a GitHub secret and passed as in the example below. Never store your MABL_API_KEY as plain text in your workflow YAML.

Requirements

  • Requires Node.js 18+ be installed as a prior step. This is most easily done with the actions/setup-node@v4 action.

Examples

Basic Example

This workflow shows how to use the mabl CLI in your workflow to export screenshots and upload them to a location.

on: [push]

name: mabl

jobs:
  test:
    name: Mabl Tests
    runs-on: ubuntu-latest
    steps:
      - uses: actions/setup-node@v4
        with:
          node-version: '18.x'

      - uses: mablhq/setup-mabl-cli@v1
        with:
          workspace-id: V2pvHBJ-rprn1n3S4ELs3A-w
        env:
          MABL_API_KEY: ${{ secrets.MABL_API_KEY }}

      - name: Download screenshots for test
        run: mabl test-runs export ar5vXBJ-rpan1nSs445s3A-jr -f screenshots.zip

      - name: Upload screenshots
        uses: actions/upload-artifact@v4
        with:
          name: screenshots
          path: screenshots.zip

Running Tests on Multiple Operating Systems in Parallel

This workflow demonstrates how to use the matrix strategy to kick off headless test runs in parallel on Ubuntu Linux, macOS, and Windows.

on: [push]

name: mabl

jobs:
  test:
    name: Mabl Test
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ ubuntu-latest, macos-latest, windows-latest ]
    steps:
      - uses: actions/setup-node@v4
        with:
          node-version: '18.x'

      - uses: mablhq/setup-mabl-cli@v1
        with:
          workspace: 8OfudHtGzLyWLU1-LBjZtQ-w
        env:
          MABL_API_KEY: ${{ secrets.MABL_API_KEY }}
      
      - name: Run tests
        run: mabl tests run --id P9BXWTEbMLeAdAPRT35jWA-j --headless --environment-id Jw7oBZlxKXVGxK3_eWxcWQ-e

You can also see how this GitHub action is tested on multiple operating systems in parallel in the workflow file in this repo.

Contributing

See here for details on contributing to this action.

License

The Dockerfile and associated scripts and documentation in this project are released under the MIT License.