Skip to content

mirrord action that triggers operator e2e workflow on release PR. #5

mirrord action that triggers operator e2e workflow on release PR.

mirrord action that triggers operator e2e workflow on release PR. #5

Workflow file for this run

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
let mirrord_commit, mirrord_branch;
if (github.event_name === 'workflow_dispatch') {
mirrord_commit = github.event.inputs.mirrord_commit;
mirrord_branch = github.event.inputs.mirrord_branch;
} else {
mirrord_commit = context.sha;
mirrord_branch = github.event.pull_request.head.ref;
}
console.log(`Using mirrord commit: ${mirrord_commit}`);
console.log(`Using mirrord branch: ${mirrord_branch}`);
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');