mirrord action that triggers operator e2e workflow on release PR. #4
Workflow file for this run
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: Operator E2E Test | |
on: | |
# Run when PR is opened or has new commits | |
pull_request: | |
types: [opened, synchronize] | |
# Allow manual triggering | |
workflow_dispatch: | |
inputs: | |
mirrord_commit: | |
description: 'Mirrord commit to use for E2E tests' | |
required: true | |
type: string | |
mirrord_branch: | |
description: 'Mirrord branch to use for E2E tests' | |
required: true | |
type: string | |
jobs: | |
trigger-operator-e2e: | |
runs-on: ubuntu-latest | |
# Only run if: | |
# 1. PR is opened and not draft | |
# 2. PR has new code and not draft | |
# 3. Manually triggered | |
if: | | |
github.event_name == 'workflow_dispatch' || | |
(github.event.action == 'opened' && github.event.pull_request.draft == false) || | |
(github.event.action == 'synchronize' && github.event.pull_request.draft == false) | |
steps: | |
- name: Trigger operator E2E workflow | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
// Get the mirrord commit and branch based on the trigger type | |
const mirrord_commit = github.event_name === 'workflow_dispatch' | |
? github.event.inputs.mirrord_commit | |
: context.sha; | |
const mirrord_branch = github.event_name === 'workflow_dispatch' | |
? github.event.inputs.mirrord_branch | |
: github.event.pull_request.head.ref; | |
const { data: workflow } = await github.rest.actions.createWorkflowDispatch({ | |
owner: 'metalbear-co', | |
repo: 'operator', | |
workflow_id: 'operator-e2e.yaml', | |
ref: 'main', // Keep main as ref since we want to test against main operator | |
inputs: { | |
mirrord_commit, | |
mirrord_branch | |
} | |
}); | |
// Poll for workflow completion | |
let status = 'queued'; | |
let attempts = 0; | |
const maxAttempts = 40; // 20 minutes with 30s intervals | |
while (status === 'queued' || status === 'in_progress') { | |
if (attempts >= maxAttempts) { | |
throw new Error('Operator E2E tests timed out after 20 minutes'); | |
} | |
await new Promise(resolve => setTimeout(resolve, 30000)); // Wait 30 seconds | |
const { data: runs } = await github.rest.actions.listWorkflowRuns({ | |
owner: 'metalbear-co', | |
repo: 'operator', | |
workflow_id: 'operator-e2e.yaml', | |
branch: 'main', | |
per_page: 1 | |
}); | |
if (runs.workflow_runs.length > 0) { | |
status = runs.workflow_runs[0].conclusion; | |
if (status === 'success') { | |
console.log('Operator E2E tests passed'); | |
return; | |
} else if (status === 'failure') { | |
// Don't fail the workflow, just log the failure | |
console.log('Operator E2E tests failed'); | |
return; | |
} | |
} | |
attempts++; | |
} | |
throw new Error('Operator E2E tests timed out'); |