Skip to content

📝 (.github/changes-filter.yaml): Update paths in changes-filter.yaml … #1041

📝 (.github/changes-filter.yaml): Update paths in changes-filter.yaml …

📝 (.github/changes-filter.yaml): Update paths in changes-filter.yaml … #1041

name: Run Frontend Tests
on:
workflow_call:
secrets:
OPENAI_API_KEY:
required: true
STORE_API_KEY:
required: true
inputs:
tests_folder:
description: "(Optional) Tests to run"
required: false
type: string
default: "tests"
ref:
description: "(Optional) ref to checkout"
required: false
type: string
workflow_dispatch:
inputs:
tests_folder:
description: "(Optional) Tests to run"
required: false
type: string
default: "tests"
env:
NODE_VERSION: "21"
PYTHON_VERSION: "3.12"
# Define the directory where Playwright browsers will be installed.
# Adjust if your project uses a different path.
PLAYWRIGHT_BROWSERS_PATH: "ms-playwright"
jobs:
determine-test-suite:
runs-on: ubuntu-latest
outputs:
suites: ${{ steps.set-matrix.outputs.matrix }}
steps:

Check failure on line 40 in .github/workflows/typescript_test.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/typescript_test.yml

Invalid workflow file

You have an error in your yaml syntax on line 40
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || github.ref }}
fetch-depth: 0
- name: Paths Filter
id: filter
uses: dorny/paths-filter@v2
with:
filters: .github/filters.yml
base: ${{ github.event.before }}
head: ${{ github.sha }}
- name: Set Matrix
id: set-matrix
run: |
SUITES="[]"
# Check components changes (excluding starter projects)
if [[ "${{ steps.filter.outputs.components }}" == "true" ]]; then
SUITES=$(echo $SUITES | jq '. += ["components"]')
fi
# Check starter-projects changes (including components in starter projects)
if [[ "${{ steps.filter.outputs.starter-projects }}" == "true" ]]; then
SUITES=$(echo $SUITES | jq '. += ["starter-projects"]')
fi
# Check workspace changes
if [[ "${{ steps.filter.outputs.workspace }}" == "true" ]]; then
SUITES=$(echo $SUITES | jq '. += ["workspace"]')
fi
# Check API changes
if [[ "${{ steps.filter.outputs.api }}" == "true" ]]; then
SUITES=$(echo $SUITES | jq '. += ["api"]')
fi
# Check database changes
if [[ "${{ steps.filter.outputs.database }}" == "true" ]]; then
SUITES=$(echo $SUITES | jq '. += ["database"]')
fi
# If release changes or no specific changes detected, run all suites
if [[ "${{ steps.filter.outputs.release }}" == "true" || "$SUITES" == "[]" ]]; then
SUITES='["starter-projects", "components", "workspace", "api", "database"]'
fi
echo "suites=$SUITES" >> $GITHUB_OUTPUT
setup-and-test:
name: Playwright Tests - Group ${{ matrix.shardIndex }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
shardIndex: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
shardTotal: [10]
env:
OPENAI_API_KEY: ${{ inputs.openai_api_key || secrets.OPENAI_API_KEY }}
STORE_API_KEY: ${{ inputs.store_api_key || secrets.STORE_API_KEY }}
SEARCH_API_KEY: "${{ secrets.SEARCH_API_KEY }}"
ASTRA_DB_APPLICATION_TOKEN: "${{ secrets.ASTRA_DB_APPLICATION_TOKEN }}"
ASTRA_DB_API_ENDPOINT: "${{ secrets.ASTRA_DB_API_ENDPOINT }}"
outputs:
failed: ${{ steps.check-failure.outputs.failed }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
# If ref is passed as input, checkout that ref
# else checkout the default ref
ref: ${{ inputs.ref || github.ref }}
- name: Setup Node.js
uses: actions/setup-node@v4
id: setup-node
with:
node-version: ${{ env.NODE_VERSION }}
- name: Cache Node.js dependencies
uses: actions/cache@v4
id: npm-cache
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('src/frontend/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install Node.js dependencies
run: |
cd src/frontend
npm ci
if: ${{ steps.setup-node.outputs.cache-hit != 'true' }}
- name: Get Playwright version
run: echo "PLAYWRIGHT_VERSION=$(jq '.devDependencies["@playwright/test"]' src/frontend/package.json -r)" >> $GITHUB_ENV
- name: Cache Playwright binaries
id: playwright-cache
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: playwright-browsers-${{ runner.os }}-${{ env.PLAYWRIGHT_VERSION }}
- name: Install Frontend dependencies
run: |
cd src/frontend
npm ci
- name: Install Playwright's browser binaries
run: |
cd src/frontend
npx playwright install --with-deps
if: steps.playwright-cache.outputs.cache-hit != 'true'
- name: Install Playwright's dependencies
run: |
cd src/frontend
npx playwright install-deps
if: steps.playwright-cache.outputs.cache-hit != 'true'
- name: "Setup Environment"
uses: ./.github/actions/setup-uv
- name: Install the project
run: uv sync --dev
- name: create .env
run: |
touch .env
echo "${{ secrets.ENV_VARS }}" > .env
- name: Run Playwright Tests
uses: nick-fields/retry@v3
with:
timeout_minutes: 12
max_attempts: 2
command: |
cd src/frontend
npx playwright test ${{ inputs.tests_folder }} --shard ${{ matrix.shardIndex }}/${{ matrix.shardTotal }} --list
npx playwright test ${{ inputs.tests_folder }} --trace on --shard ${{ matrix.shardIndex }}/${{ matrix.shardTotal }} --workers 2
- name: Upload blob report to GitHub Actions Artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: blob-report-${{ matrix.shardIndex }}
path: src/frontend/blob-report
retention-days: 1
- name: Minimize uv cache
run: uv cache prune --ci
merge-reports:
# We need to repeat the condition at every step
# https://github.com/actions/runner/issues/662
needs: setup-and-test
runs-on: ubuntu-latest
if: always()
env:
EXIT_CODE: ${{!contains(needs.setup-and-test.result, 'failure') && !contains(needs.setup-and-test.result, 'cancelled') && '0' || '1'}}
steps:
- name: "Should Merge Reports"
# If the CI was successful, we don't need to merge the reports
# so we can skip all the steps below
id: should_merge_reports
run: |
if [ "$EXIT_CODE" == "0" ]; then
echo "should_merge_reports=false" >> $GITHUB_OUTPUT
else
echo "should_merge_reports=true" >> $GITHUB_OUTPUT
fi
- name: Checkout code
if: ${{ steps.should_merge_reports.outputs.should_merge_reports == 'true' }}
uses: actions/checkout@v4
- name: Setup Node.js
if: ${{ steps.should_merge_reports.outputs.should_merge_reports == 'true' }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Download blob reports from GitHub Actions Artifacts
if: ${{ steps.should_merge_reports.outputs.should_merge_reports == 'true' }}
uses: actions/download-artifact@v4
with:
path: all-blob-reports
pattern: blob-report-*
merge-multiple: true
- name: Merge into HTML Report
if: ${{ steps.should_merge_reports.outputs.should_merge_reports == 'true' }}
run: |
npx playwright merge-reports --reporter html ./all-blob-reports
- name: Upload HTML report
if: ${{ steps.should_merge_reports.outputs.should_merge_reports == 'true' }}
uses: actions/upload-artifact@v4
with:
name: html-report--attempt-${{ github.run_attempt }}
path: playwright-report
retention-days: 14