Run Tests #8459
This file contains 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: Run Tests | |
on: | |
workflow_dispatch: | |
inputs: | |
capgo_clone_url: | |
required: true | |
type: string | |
capgo_clone_branch: | |
required: true | |
type: string | |
cli_clone_url: | |
required: true | |
type: string | |
cli_clone_branch: | |
required: true | |
type: string | |
tests_to_run: | |
required: true | |
type: string | |
commit_sha: | |
required: true | |
type: string | |
repo_owner: | |
required: true | |
type: string | |
repo_name: | |
required: true | |
type: string | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
permissions: | |
issues: write | |
name: "Run tests" | |
steps: | |
- name: Get Github App Token | |
uses: tibdex/github-app-token@v2 | |
id: get_installation_token | |
with: | |
app_id: 392564 | |
private_key: ${{ secrets.PRIVATE_KEY }} | |
- name: Change Status (start) | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{ steps.get_installation_token.outputs.token }} | |
script: | | |
const job = await github.rest.actions.listJobsForWorkflowRun({ | |
repo: 'github-bot', | |
owner: 'Cap-go', | |
run_id: context.runId, | |
}); | |
const jobId = job.data.jobs[0].id | |
if (!jobId) { | |
throw new Error('No job id') | |
} | |
const jobUrl = 'https://github.com/Cap-go/github-bot/actions/runs/RUN_ID/job/RUN_NUMBER'.replace('RUN_ID', context.runId).replace('RUN_NUMBER', jobId) | |
core.exportVariable('JOB_URL', jobUrl) | |
const commentData = `\n<!--- ${JSON.stringify({ capgo_clone_url: '${{ inputs.capgo_clone_url }}', capgo_clone_branch: '${{ inputs.capgo_clone_branch }}', cli_clone_url: '${{ inputs.cli_clone_url }}', cli_clone_branch: '${{ inputs.cli_clone_branch }}', tests_to_run: '${{ inputs.tests_to_run }}', commit_sha: '${{ inputs.commit_sha }}', repo_owner: '${{ inputs.repo_owner }}', repo_name: '${{ inputs.repo_name }}'})} -->` | |
core.exportVariable('COMMENT_DATA', commentData) | |
github.rest.checks.create({ | |
owner: '${{ inputs.repo_owner }}', | |
repo: '${{ inputs.repo_name }}', | |
name: 'E2E tests', | |
status: 'in_progress', | |
head_sha: '${{ inputs.commit_sha }}', | |
details_url: jobUrl, | |
output: { | |
summary: `The detailed output is available [here](${jobUrl})${commentData}`, | |
title: 'Testing E2E', | |
}, | |
}) | |
- name: "Checkout Capgo" | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ inputs.capgo_clone_url }} | |
ref: ${{ inputs.capgo_clone_branch }} | |
path: capgo | |
- name: "Checkout CLI" | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ inputs.cli_clone_url }} | |
ref: ${{ inputs.cli_clone_branch }} | |
path: cli | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
- name: Setup bun | |
uses: oven-sh/setup-bun@v1 | |
with: | |
bun-version: latest | |
- name: Install dependencies | |
run: cd ./capgo && bun install && cd ../cli && bun install && cd .. | |
- name: Install Supabase CLI | |
uses: supabase/setup-cli@v1 | |
with: | |
version: 1.142.2 | |
- name: Install Deno | |
uses: denoland/setup-deno@v1 | |
with: | |
deno-version: vx.x.x | |
- name: Cache playwright binaries | |
id: playwright-cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/Library/Caches/ms-playwright | |
~/.cache/ms-playwright | |
${{ github.workspace }}/capgo/node_modules/playwright | |
key: cache-playwright-${{ hashFiles('**/bun.lockb') }} | |
restore-keys: cache-playwright- | |
- name: Install Playwright | |
shell: bash | |
if: steps.playwright-cache.outputs.cache-hit != 'true' | |
working-directory: ./capgo | |
run: bunx playwright install --with-deps chromium | |
- name: Run Supabase Start | |
working-directory: ./capgo | |
run: ENV=local supabase start -x studio,imgproxy,inbucket,logflare --ignore-health-check | |
- name: Build CLI | |
working-directory: ./cli | |
run: bun run dev | |
- name: Start minio | |
working-directory: ./capgo | |
run: bun run minio:start | |
- name: Seed minio | |
working-directory: ./capgo | |
run: bun run minio:seed | |
- name: Set env variables | |
shell: bash | |
run: | | |
echo "CLI_PATH=$(realpath ./cli)" >> $GITHUB_ENV | |
- name: Start Clickhouse | |
working-directory: ./capgo | |
run: bun run clickhouse:start | |
- name: Seed Clickhouse | |
working-directory: ./capgo | |
run: bun run clickhouse:seed | |
- name: Add Clickhouse to Supabase | |
working-directory: ./capgo | |
run: bun run clickhouse:add-local | |
- name: Show testing env | |
working-directory: ./capgo | |
run: bunx envinfo --preset playwright | |
- name: Prebuild web server | |
working-directory: ./capgo | |
run: ENV=local bun run vite build --sourcemap true --minify false --assetsDir . | |
- name: Run CLI Tests | |
working-directory: ./capgo | |
run: deno run --allow-all tests_backend/run_backend_tests.ts ${{ inputs.tests_to_run }} | |
- name: Change Status (failed) | |
if: failure() | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{ steps.get_installation_token.outputs.token }} | |
script: | | |
const { JOB_URL, COMMENT_DATA } = process.env | |
github.rest.checks.create({ | |
owner: '${{ inputs.repo_owner }}', | |
repo: '${{ inputs.repo_name }}', | |
name: 'E2E tests', | |
status: 'completed', | |
conclusion: 'failure', | |
head_sha: '${{ inputs.commit_sha }}', | |
details_url: JOB_URL, | |
output: { | |
summary: `The detailed output is available [here](${JOB_URL})${COMMENT_DATA}`, | |
title: 'E2E tests failed', | |
}, | |
}) | |
- name: Change Stats (success) | |
if: success() | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{ steps.get_installation_token.outputs.token }} | |
script: | | |
const { JOB_URL, COMMENT_DATA } = process.env | |
github.rest.checks.create({ | |
owner: '${{ inputs.repo_owner }}', | |
repo: '${{ inputs.repo_name }}', | |
name: 'E2E tests', | |
status: 'completed', | |
conclusion: 'success', | |
head_sha: '${{ inputs.commit_sha }}', | |
details_url: JOB_URL, | |
output: { | |
summary: `The detailed output is available [here](${JOB_URL})${COMMENT_DATA} `, | |
title: 'E2E tests succeeded', | |
}, | |
}) | |
- uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: playwright-report | |
path: capgo/test-results/ | |
if-no-files-found: warn | |
retention-days: 30 |