Skip to content

Combined store Tests (vector+storage) #25197

Combined store Tests (vector+storage)

Combined store Tests (vector+storage) #25197

name: Combined store Tests (vector+storage)
on:
workflow_run:
workflows: ['Quality assurance']
types:
- completed
concurrency:
group: ${{ github.workflow }}-${{ github.event.workflow_run.head_sha }}
cancel-in-progress: true
jobs:
check-changes:
if: ${{ github.repository == 'mastra-ai/mastra' }}
runs-on: ubuntu-latest
outputs:
stores-changed: ${{ steps.changes.outputs.stores }}
permissions:
contents: read
statuses: write
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
ref: ${{ github.event.workflow_run.head_sha }}
- name: Set pending status
uses: ./.github/workflows/shared-actions/set-pr-status
with:
status: 'pending'
context: 'Combined store Tests (vector+storage)'
description: 'Checking for changes'
sha: ${{ github.event.workflow_run.head_sha }}
github_token: ${{ secrets.GITHUB_TOKEN }}
target_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
- name: Check for stores package changes
uses: dorny/paths-filter@v3
id: changes
with:
base: main
ref: ${{ github.event.workflow_run.head_sha }}
filters: |
stores:
- 'stores/**'
- 'packages/core/**'
skip-tests:
needs: check-changes
if: needs.check-changes.outputs.stores-changed == 'false'
runs-on: ubuntu-latest
permissions:
statuses: write
steps:
- uses: actions/checkout@v5
- name: Set success status for unchanged stores
uses: ./.github/workflows/shared-actions/set-pr-status
with:
status: 'success'
context: 'Combined store Tests (vector+storage)'
description: 'Store packages unchanged - skipping tests'
sha: ${{ github.event.workflow_run.head_sha }}
github_token: ${{ secrets.GITHUB_TOKEN }}
target_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
setup:
needs: check-changes
if: needs.check-changes.outputs.stores-changed == 'true'
runs-on: ubuntu-latest
outputs:
stores: ${{ steps.set-stores.outputs.stores }}
steps:
- uses: actions/checkout@v5
with:
ref: ${{ github.event.workflow_run.head_sha }}
- id: set-stores
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
STORES=$(ls -d stores/*/ | grep -v '_test-utils' | cut -f2 -d'/' | jq -R -s -c 'split("\n")[:-1]')
# Check if we should include vectorize tests
# Only run vectorize tests for dane-ai-mastra bot's version packages PRs
PR_DATA=$(gh api "/repos/${{ github.repository }}/commits/${{ github.event.workflow_run.head_sha }}/pulls" --jq '.[0] | {user: .user.login, title: .title}' 2>/dev/null || echo '{}')
PR_USER=$(echo "$PR_DATA" | jq -r '.user // ""')
PR_TITLE=$(echo "$PR_DATA" | jq -r '.title // ""')
IS_VERSIONING_PR=false
if [[ "$PR_USER" == "dane-ai-mastra" ]] && [[ "$PR_TITLE" == "chore: version packages" || "$PR_TITLE" == "chore: version packages (alpha)" ]]; then
IS_VERSIONING_PR=true
fi
if [[ "$IS_VERSIONING_PR" == "true" ]]; then
echo "✓ This is a version packages PR from dane-ai-mastra bot - vectorize tests will run"
else
echo "✗ Not a version packages PR from dane-ai-mastra bot - filtering out vectorize tests"
STORES=$(echo "$STORES" | jq -c '[.[] | select(. != "vectorize")]')
fi
echo "stores=$STORES" >> $GITHUB_OUTPUT
test:
needs: [check-changes, setup]
if: ${{ github.repository == 'mastra-ai/mastra' && needs.check-changes.outputs.stores-changed == 'true' }}
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
fail-fast: false
matrix:
store: ${{fromJson(needs.setup.outputs.stores)}}
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
TURBO_CACHE: remote:r
GITHUB_REF_NAME: ${{ github.event.workflow_run.head_branch }}
steps:
- uses: actions/checkout@v5
with:
ref: ${{ github.event.workflow_run.head_sha }}
- name: Setup pnpm and Node.js
uses: ./.github/actions/setup-pnpm-node
- name: Build combined storage packages
run: pnpm turbo --filter "@mastra/${{ matrix.store }}" build
env:
NODE_OPTIONS: '--max_old_space_size=6144'
- name: Run ${{ matrix.store }} tests
run: pnpm test
working-directory: stores/${{ matrix.store }}
env:
NODE_OPTIONS: '--max_old_space_size=6144'
PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }}
ASTRA_DB_ENDPOINT: ${{ secrets.ASTRA_DB_ENDPOINT }}
ASTRA_DB_TOKEN: ${{ secrets.ASTRA_DB_TOKEN }}
CLOUDFLARE_API_TOKEN: ${{ secrets.ABHI_CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.ABHI_CLOUDFLARE_ACCOUNT_ID }}
test-success:
needs: [check-changes, setup, test]
if: ${{ always() && needs.check-changes.outputs.stores-changed == 'true' && needs.test.result == 'success' }}
runs-on: ubuntu-latest
permissions:
statuses: write
steps:
- uses: actions/checkout@v5
- name: Set success status for completed tests
uses: ./.github/workflows/shared-actions/set-pr-status
with:
status: 'success'
context: 'Combined store Tests (vector+storage)'
description: 'All combined store tests passed'
sha: ${{ github.event.workflow_run.head_sha }}
github_token: ${{ secrets.GITHUB_TOKEN }}
target_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
test-failure:
needs: [check-changes, setup, test]
if: ${{ always() && needs.check-changes.outputs.stores-changed == 'true' && needs.test.result == 'failure' }}
runs-on: ubuntu-latest
permissions:
statuses: write
steps:
- uses: actions/checkout@v5
- name: Set failure status for failed tests
uses: ./.github/workflows/shared-actions/set-pr-status
with:
status: 'failure'
context: 'Combined store Tests (vector+storage)'
description: 'One or more combined store tests failed'
sha: ${{ github.event.workflow_run.head_sha }}
github_token: ${{ secrets.GITHUB_TOKEN }}
target_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}