Overview

The TestDriver GitHub Action allows you to run tests on multiple operating systems, enabling cross-platform compatibility testing. By configuring the os parameter, you can specify the operating system for your test environment. This flexibility ensures that your application behaves consistently across platforms.


Supported operating systems

The following operating systems are currently supported:

OSVersionInstance TypeArchitectureNotes
windowsWindows Server 2022 Baset2.large64-bit (x86)Available to all users.
macmacOS Sonomamac1.metalx86_64_macAvailable to Enterprise users.
linuxUbuntu 20.04 LTSt2.large64-bit (x86)Default for most workflows.

Configuring the operating system

To specify the operating system, use the os parameter in the GitHub Action configuration. For example:

Example: Running a test on Windows

with:
  os: windows

Example: Running a test on macOS

with:
  os: mac

Example: Running a test on Linux

with:
  os: linux

Prerun scripts and OS-specific commands

Prerun scripts are executed on the specified operating system. The scripting language depends on the OS:

  • Windows: Use PowerShell.
  • macOS: Use Bash.
  • Linux: Use Bash.

Example: Installing browsers based on OS

The following example demonstrates how to install Google Chrome or Firefox on Windows, macOS, and Linux using a prerun script:

prerun: |
  if [ "${{ matrix.browser }}" == "chrome" ]; then
    if [ "${{ matrix.os }}" == "windows" ]; then
      # Install Google Chrome on Windows
      $ProgressPreference = 'SilentlyContinue'
      Invoke-WebRequest -Uri "https://dl.google.com/chrome/install/latest/chrome_installer.exe" -OutFile "$env:TEMP\chrome_installer.exe"
      Start-Process -FilePath "$env:TEMP\chrome_installer.exe" -ArgumentList "/silent", "/install" -Wait
    elif [ "${{ matrix.os }}" == "mac" ]; then
      # Install Google Chrome on macOS
      brew install --cask google-chrome
    else
      # Install Google Chrome on Linux
      wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
      sudo apt install ./google-chrome-stable_current_amd64.deb -y
    fi
  else
    if [ "${{ matrix.os }}" == "windows" ]; then
      # Install Firefox on Windows
      $ProgressPreference = 'SilentlyContinue'
      Invoke-WebRequest -Uri "https://download.mozilla.org/?product=firefox-latest&os=win64&lang=en-US" -OutFile "$env:TEMP\firefox_installer.exe"
      Start-Process -FilePath "$env:TEMP\firefox_installer.exe" -ArgumentList "/S" -Wait
    elif [ "${{ matrix.os }}" == "mac" ]; then
      # Install Firefox on macOS
      brew install --cask firefox
    else
      # Install Firefox on Linux
      sudo apt update
      sudo apt install firefox -y
    fi
  fi

Testing multiple operating systems and browsers

You can use the GitHub matrix strategy to test your application across multiple operating systems and browsers. This ensures comprehensive coverage for your tests.

Example: Matrix strategy for OS and browser testing

strategy:
  matrix:
    os: [windows, mac, linux]
    browser: [chrome, firefox]

Full workflow example

name: Test Action

permissions:
  actions: read
  contents: read
  statuses: write
  pull-requests: write

on:
  pull_request:
    types: [opened, synchronize, reopened, ready_for_review, labeled, unlabeled]

jobs:
  test-action:
    name: Test Action
    runs-on: ubuntu-latest
    strategy:
      matrix:
        os: [windows, mac, linux]
        browser: [chrome, firefox]
    steps:
      - name: Set up Node.js
        uses: actions/setup-node@v3
        with:
          node-version: '16'

      - name: Install Dashcam Chrome
        run: |
          npm init -y
          npm install dashcam-chrome

      - uses: replayableio/testdriver-action@main
        with:
          prompt: |
            1. open youtube
            2. find a cat video
            3. quit the browser
            4. /summarize
          os: ${{ matrix.os }}
          prerun: |
            # Add prerun script here
          key: ${{ secrets.TD_API_KEY }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          FORCE_COLOR: "3"

Notes

  • macOS Availability: macOS testing is only available to Enterprise customers.
  • Prerun Scripts: Ensure your prerun scripts are compatible with the specified operating system.
  • Cross-Platform Testing: Use the matrix strategy to test across multiple OS and browser combinations for maximum coverage.
  • Linux Default: Linux is the default operating system for most workflows and is ideal for lightweight, fast testing.