Skip to content

Running Moonshot Tests

aivf_baisheng edited this page Sep 6, 2025 · 2 revisions

image

Overview

This guide explains how to run Moonshot Tests straight out of the box. Please complete the onboarding process to set up Moonshot in your CI/CD before running the first test. You may refer to this guide.

Using Moonshot

Moonshot tests can be run with a single command. Example:

moonshot run <run_id> <test_id> <endpoint_id>

Command Parameters

  • moonshot: Fixed parameter. This is always required.
  • run: The keyword for the run action. Only this keyword is needed to run benchmark tests and red team attacks.
  • <run_id>: The run id of the run, which should come from the CI/CD runner. This run id will also be the name of the result JSON file of this run (i.e., my-run-id.json). If there is no run id, the user can specify his/her run id.

Warning

If the run id is a duplicate, an error will be thrown as we do not want to overwrite the result file with the same run id.

  • <test_id>: The test id of the test configuration to run. For example, this could be qa-tests -- a combination of multiple benchmark tests and red team attacks, or prompt_injection_jailbreak, a single benchmark test.

Tip

For a list of tests available in Moonshot, please download the latest copy from here.

  • <endpoint_id>: The name of the endpoint configuration for evaluation. For example, this could be my-gpt-4o-mini if the user wishes to evaluate against OpenAI’s o4 mini model.

Tip

For a list of models currently supported in Moonshot, please download the latest copy from here.



Specify moonshot run in your job script

A typical configuration for running tests in a Moonshot workflow might look like this:

jobs:
    run-moonshot-in-ci:
        permissions:
            id-token: write
            contents: read
            packages: read
        runs-on: ubuntu-latest
        container: <your_moonshot_image>
        steps:
          - name: Configure AWS credentials
            uses: aws-actions/configure-aws-credentials@v4
            with:
              aws-region: ap-southeast-1
              role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
              
          - name: Run Moonshot
            run: |
              cd /app
              export OPENAI_API_KEY="${{ secrets.OPENAI_TOKEN }}"
              export MS_TEST_CONFIG_PATH=${{ secrets.S3_URI }}
              export MS_CONFIG_PATH=${{ secrets.S3_URI }}
              moonshot run my-run-1 qa-tests my-gpt-4o-mini
              
          - name: Upload Moonshot Results
            uses: actions/upload-artifact@v4
            with:
              name: test-results
              path: /app/data/results/*

GitHub Actions Example


Congratulations! You have successfully learnt how to run Moonshot as a workflow action in your CI/CD!

Clone this wiki locally