Skip to content

Moonshot Smoke Test #420

Moonshot Smoke Test

Moonshot Smoke Test #420

Workflow file for this run

# Smoke Test
name: Moonshot Smoke Test
on:
# Runs when a pull request to main is being assigned
pull_request:
types: [ assigned, synchronize ]
branches:
- 'dev_main'
# Run this workflow manually from Actions tab
workflow_dispatch:
inputs:
moonshot_branch:
description: 'Moonshot Branch / Tag Name'
required: true
default: 'dev_main'
type: string
moonshot_data_branch:
description: 'Moonshot Data Branch / Tag Name'
required: true
default: 'dev_main'
type: string
moonshot_ui_branch:
description: 'Moonshot UI Branch / Tag Name'
required: true
default: 'dev_main'
type: string
# Allow one concurrent deployment
concurrency:
group: ${{ github.repository }}-${{ github.workflow }}
cancel-in-progress: true
jobs:
smoke-test:
if: (github.event_name == 'pull_request' && github.event.pull_request.assignee != null) || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
# [WS-299] Remove pre-installed tools to free up space for installation of moonshot-data
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@v1.3.1
with:
# Required for Python
tool-cache: false
# Remove tools
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: true
- name: Checkout Moonshot (Pull Request)
if: github.event_name == 'pull_request'
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
- name: Checkout Moonshot (Workflow Dispatch)
if: github.event_name == 'workflow_dispatch'
uses: actions/checkout@v4
with:
repository: aiverify-foundation/moonshot
ref: ${{ inputs.moonshot_branch }}
- name: Setup Python 3.11
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Setup Moonshot
run: |
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
touch .env
echo "${{ secrets.ENVIRONMENT_VARS }}" >> .env
- name: Checkout Moonshot Data (Pull Request Review)
if: github.event_name == 'pull_request'
uses: actions/checkout@v4
with:
repository: aiverify-foundation/moonshot-data
ref: ${{ vars.MOONSHOT_DATA_BRANCH }}
path: moonshot-data
- name: Checkout Moonshot Data (Workflow Dispatch)
if: github.event_name == 'workflow_dispatch'
uses: actions/checkout@v4
with:
repository: aiverify-foundation/moonshot-data
ref: ${{ inputs.moonshot_data_branch }}
path: moonshot-data
- name: Setup Moonshot Data
run: |
source venv/bin/activate
cd moonshot-data
pip install -r requirements.txt
- name: Checkout Moonshot UI (Pull Request Review)
if: github.event_name == 'pull_request'
uses: actions/checkout@v4
with:
repository: aiverify-foundation/moonshot-ui
ref: ${{ vars.MOONSHOT_UI_BRANCH }}
path: moonshot-ui
- name: Checkout Moonshot UI (Workflow Dispatch)
if: github.event_name == 'workflow_dispatch'
uses: actions/checkout@v4
with:
repository: aiverify-foundation/moonshot-ui
ref: ${{ inputs.moonshot_ui_branch }}
path: moonshot-ui
# Download NLTK stopwords
- name: Download NLTK stopwords
run: |
source venv/bin/activate
pip install nltk
python -c "import nltk; nltk.download('stopwords');nltk.download('punkt');nltk.download('punkt_tab');nltk.download('averaged_perceptron_tagger_eng')"
- name: Setup Moonshot UI
run: |
cd moonshot-ui
npm install
npm run build
cd ../
source venv/bin/activate
python -m moonshot web &
- name: Checkout Smoke Test
uses: actions/checkout@v4
with:
repository: aiverify-foundation/moonshot-smoke-testing
path: moonshot-smoke-testing
- name: Run Smoke Test
env:
AZURE_OPENAI_URI: ${{ secrets.AZURE_OPENAI_URI }}
AZURE_OPENAI_TOKEN: ${{ secrets.AZURE_OPENAI_TOKEN }}
ADDITIONAL_PARAMETERS: ${{ secrets.ADDITIONAL_PARAMETERS }}
MOONSHOT_URL: ${{ secrets.MOONSHOT_URL }}
MOONSHOT_PORT_NUMBER: ${{ secrets.MOONSHOT_PORT_NUMBER }}
run: |
source venv/bin/activate
cd moonshot-smoke-testing
npm ci
npx playwright install
npx playwright install-deps
npm install dotenv --save
AZURE_OPENAI_URI="$AZURE_OPENAI_URI" AZURE_OPENAI_TOKEN="$AZURE_OPENAI_TOKEN" ADDITIONAL_PARAMETERS="$ADDITIONAL_PARAMETERS" MOONSHOT_URL="$MOONSHOT_URL" MOONSHOT_PORT_NUMBER="$MOONSHOT_PORT_NUMBER" DEBUG=pw:api npx playwright test tests/smoke-test.spec.ts --trace on
- name: Upload Playwright Traces
if: always()
uses: actions/upload-artifact@v4
with:
name: playwright-trace-integration-ui-test-redteaming-${{ github.run_id }}
path: |
/home/runner/work/moonshot/moonshot/moonshot-smoke-testing/test-results