E2E Tests (Release) #74
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: E2E Tests (Release) | |
# This workflow runs end-to-end tests across multiple operating systems: | |
# - Ubuntu (Linux) | |
# - Windows | |
# - macOS | |
# Ensures cross-platform compatibility of the Motia framework | |
permissions: | |
contents: read | |
actions: write | |
on: | |
workflow_run: | |
workflows: ["Deploy Release"] | |
types: | |
- completed | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Version being tested' | |
required: true | |
tag_name: | |
description: 'Git tag name' | |
required: true | |
triggered_by: | |
description: 'Run ID that triggered this workflow' | |
required: true | |
jobs: | |
prepare: | |
runs-on: ubuntu-latest | |
if: github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' | |
outputs: | |
version: ${{ steps.extract_version.outputs.version }} | |
tag_name: ${{ steps.extract_version.outputs.tag_name }} | |
triggered_by: ${{ steps.extract_version.outputs.triggered_by }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Extract version from inputs or workflow run | |
id: extract_version | |
run: | | |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then | |
echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT | |
echo "tag_name=${{ github.event.inputs.tag_name }}" >> $GITHUB_OUTPUT | |
echo "triggered_by=${{ github.event.inputs.triggered_by }}" >> $GITHUB_OUTPUT | |
else | |
# Extract from the triggering workflow's tag | |
TAG_NAME="${{ github.event.workflow_run.head_branch }}" | |
if [[ $TAG_NAME =~ ^refs/tags/v(.+)$ ]]; then | |
VERSION="${BASH_REMATCH[1]}" | |
else | |
# If not a tag, extract from the head_sha | |
git fetch --tags | |
TAG_NAME=$(git describe --tags --exact-match ${{ github.event.workflow_run.head_sha }} 2>/dev/null || echo "") | |
if [[ $TAG_NAME =~ ^v(.+)$ ]]; then | |
VERSION="${BASH_REMATCH[1]}" | |
else | |
echo "❌ Could not extract version from workflow run" | |
exit 1 | |
fi | |
fi | |
echo "version=$VERSION" >> $GITHUB_OUTPUT | |
echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT | |
echo "triggered_by=${{ github.event.workflow_run.id }}" >> $GITHUB_OUTPUT | |
fi | |
e2e-tests: | |
needs: prepare | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, windows-2025, macos-latest] | |
runs-on: ${{ matrix.os }} | |
timeout-minutes: 30 | |
env: | |
CI: true | |
NODE_ENV: test | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.13' | |
- uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: '3.3.6' | |
- uses: pnpm/action-setup@v4 | |
- uses: actions/setup-node@v4 # Versão mais recente | |
with: | |
node-version: '20.11.1' | |
cache: 'pnpm' | |
# Cache global do npm para melhor performance | |
- name: Cache global npm packages | |
uses: actions/cache@v4 | |
with: | |
path: ~/.npm | |
key: npm-global-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
npm-global-${{ runner.os }}- | |
- name: Install pre-release packages globally | |
run: | | |
npm install -g motia@${{ needs.prepare.outputs.version }} --tag pre-release | |
- name: Get Playwright version | |
id: playwright-version | |
run: | | |
cd packages/e2e | |
echo "version=$(node -p "require('./package.json').dependencies['@playwright/test'] || require('./package.json').devDependencies['@playwright/test']")" >> $GITHUB_OUTPUT | |
- name: Cache Playwright browsers | |
uses: actions/cache@v4 | |
id: playwright-cache | |
with: | |
path: | | |
~/.cache/ms-playwright | |
~/AppData/Local/ms-playwright | |
~/Library/Caches/ms-playwright | |
key: playwright-browsers-${{ runner.os }}-${{ steps.playwright-version.outputs.version }} | |
- name: Install E2E dependencies and browsers | |
run: | | |
cd packages/e2e | |
pnpm install | |
pnpm exec playwright install | |
pnpm exec playwright install-deps | |
- name: Clean previous test artifacts | |
run: | | |
cd packages/e2e | |
pnpm clean | |
- name: Verify Motia CLI installation (Unix) | |
if: runner.os != 'Windows' | |
run: | | |
which motia || echo "Motia CLI not found in PATH" | |
npx motia --version || echo "Motia CLI version check failed" | |
node --version | |
npm --version | |
- name: Verify Motia CLI installation (Windows) | |
if: runner.os == 'Windows' | |
run: | | |
where motia 2>nul || echo "Motia CLI not found in PATH" | |
npx motia --version || echo "Motia CLI version check failed" | |
node --version | |
npm --version | |
shell: cmd | |
- name: Run Release E2E tests | |
id: run_tests | |
env: | |
MOTIA_ANALYTICS_DISABLED: true | |
MOTIA_VERSION: ${{ needs.prepare.outputs.version }} | |
MOTIA_API_URL: http://localhost:3000 | |
run: | | |
cd packages/e2e | |
echo "Starting Release E2E tests with Motia version: $MOTIA_VERSION" | |
pnpm test:release --reporter=line,html,github | |
continue-on-error: true | |
- name: Run Release E2E tests for python | |
id: run_tests_python | |
env: | |
MOTIA_ANALYTICS_DISABLED: true | |
MOTIA_VERSION: ${{ needs.prepare.outputs.version }} | |
MOTIA_API_URL: http://localhost:3000 | |
run: | | |
cd packages/e2e | |
echo "Starting Release E2E tests with Motia version: $MOTIA_VERSION" | |
pnpm test:release:python --reporter=line,html,github | |
continue-on-error: true | |
- name: Set test result | |
id: test_result | |
shell: bash | |
run: | | |
echo "📊 Test Results Summary:" | |
echo "- Node.js tests outcome: ${{ steps.run_tests.outcome }}" | |
echo "- Python tests outcome: ${{ steps.run_tests_python.outcome }}" | |
# Check both test outcomes | |
if [ "${{ steps.run_tests.outcome }}" == "success" ] && [ "${{ steps.run_tests_python.outcome }}" == "success" ]; then | |
echo "result=success" >> $GITHUB_OUTPUT | |
echo "✅ All E2E tests passed successfully" | |
elif [ "${{ steps.run_tests.outcome }}" == "success" ] || [ "${{ steps.run_tests_python.outcome }}" == "success" ]; then | |
echo "result=partial" >> $GITHUB_OUTPUT | |
echo "⚠️ Some E2E tests passed, others failed" | |
exit 1 | |
else | |
echo "result=failure" >> $GITHUB_OUTPUT | |
echo "❌ All E2E tests failed" | |
echo "Check the test results and logs for details" | |
exit 1 | |
fi | |
- name: Upload test results | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: e2e-test-results-${{ needs.prepare.outputs.version }}-${{ matrix.os }} | |
path: | | |
packages/e2e/playwright-report/ | |
packages/e2e/test-results/ | |
retention-days: 30 | |
check-results: | |
needs: e2e-tests | |
runs-on: ubuntu-latest | |
if: always() | |
outputs: | |
result: ${{ steps.final_result.outputs.result }} | |
steps: | |
- name: Check all matrix results | |
id: final_result | |
shell: bash | |
run: | | |
echo "Checking results from all OS matrix jobs..." | |
# Get the results from the matrix jobs | |
RESULTS='${{ toJSON(needs.e2e-tests.result) }}' | |
echo "Matrix job result: $RESULTS" | |
if [ "$RESULTS" == '"success"' ]; then | |
echo "result=success" >> $GITHUB_OUTPUT | |
echo "✅ All E2E tests passed successfully across all platforms" | |
else | |
echo "result=failure" >> $GITHUB_OUTPUT | |
echo "❌ E2E tests failed on one or more platforms" | |
exit 1 | |
fi |