|
28 | 28 | pr_id: ${{ steps.extract.outputs.pr_id }} |
29 | 29 | original_run_id: ${{ steps.extract.outputs.original_run_id }} |
30 | 30 | pr_sha: ${{ steps.extract.outputs.pr_sha }} |
| 31 | + pr_base_ref: ${{ steps.extract.outputs.pr_base_ref }} |
31 | 32 | hv: ${{ steps.extract.outputs.hv }} |
32 | 33 | arch: ${{ steps.extract.outputs.arch }} |
33 | 34 | platform: ${{ steps.extract.outputs.platform }} |
|
64 | 65 | if: ${{ steps.check_gate.outputs.skip_run == 'false' }} |
65 | 66 | env: |
66 | 67 | RUN_CONTEXT_FILE: ${{ env.RUN_CONTEXT_FILE }} |
67 | | - REQUIRED_FIELDS: pr_id, original_run_id, pr_sha, hv, arch, platform, gate_run_id, gate_status_name |
| 68 | + REQUIRED_FIELDS: pr_id, original_run_id, pr_sha, pr_base_ref, hv, arch, platform, gate_run_id, gate_status_name |
68 | 69 | run: | |
69 | 70 | if [[ ! -f "$RUN_CONTEXT_FILE" ]]; then |
70 | 71 | echo "$RUN_CONTEXT_FILE file not found" |
|
95 | 96 | if: ${{ steps.check_gate.outputs.skip_run == 'false' }} |
96 | 97 | id: extract |
97 | 98 | env: |
98 | | - FIELDS: pr_id, original_run_id, pr_sha, hv, arch, platform, gate_run_id, gate_status_name |
| 99 | + FIELDS: pr_id, original_run_id, pr_sha, pr_base_ref, hv, arch, platform, gate_run_id, gate_status_name |
99 | 100 | run: | |
100 | 101 | # Extract fields from the JSON file |
101 | 102 | for field in $(echo "$FIELDS" | tr ',' ' '); do |
@@ -175,18 +176,134 @@ jobs: |
175 | 176 | } |
176 | 177 |
|
177 | 178 |
|
| 179 | + select_eden_version: |
| 180 | + name: Select Eden Version |
| 181 | + runs-on: ubuntu-latest |
| 182 | + needs: context |
| 183 | + if: needs.context.outputs.skip_run == 'false' |
| 184 | + outputs: |
| 185 | + eden_version: ${{ steps.select.outputs.eden_version }} |
| 186 | + steps: |
| 187 | + - name: Checkout repository |
| 188 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 189 | + |
| 190 | + - name: Select Eden version based on target branch |
| 191 | + id: select |
| 192 | + env: |
| 193 | + BASE_REF: ${{ needs.context.outputs.pr_base_ref }} |
| 194 | + run: | |
| 195 | + MAPPING_FILE=".github/eden-version-map.yml" |
| 196 | +
|
| 197 | + if [[ ! -f "$MAPPING_FILE" ]]; then |
| 198 | + echo "::error::Eden version mapping file not found: $MAPPING_FILE" |
| 199 | + exit 1 |
| 200 | + fi |
| 201 | +
|
| 202 | + echo "PR target branch: $BASE_REF" |
| 203 | +
|
| 204 | + # Try to get the mapping for the specific branch |
| 205 | + eden_version=$(yq eval ".\"$BASE_REF\".eden_version" "$MAPPING_FILE") |
| 206 | +
|
| 207 | + # If no specific mapping exists, use the default |
| 208 | + if [[ "$eden_version" == "null" || -z "$eden_version" ]]; then |
| 209 | + echo "No specific mapping found for branch '$BASE_REF', using default" |
| 210 | + eden_version=$(yq eval '.default.eden_version' "$MAPPING_FILE") |
| 211 | + fi |
| 212 | +
|
| 213 | + # Verify that we have valid values |
| 214 | + if [[ "$eden_version" == "null" || -z "$eden_version" ]]; then |
| 215 | + echo "::error::Failed to determine eden_version for branch '$BASE_REF'" |
| 216 | + exit 1 |
| 217 | + fi |
| 218 | +
|
| 219 | + echo "Selected Eden version: $eden_version" |
| 220 | +
|
| 221 | + echo "eden_version=$eden_version" >> "$GITHUB_OUTPUT" |
| 222 | +
|
| 223 | +
|
178 | 224 | tests: |
179 | 225 | name: ${{ needs.context.outputs.eden_parent_job_title }} |
180 | | - needs: context |
| 226 | + needs: [context, select_eden_version] |
181 | 227 | if: needs.context.outputs.skip_run == 'false' |
182 | | - uses: lf-edge/eden/.github/workflows/test.yml@1.0.13 |
183 | | - secrets: inherit |
184 | | - with: |
185 | | - eve_image: "evebuild/pr:${{ needs.context.outputs.pr_id }}" |
186 | | - eve_log_level: "debug" |
187 | | - eve_artifact_name: "eve-${{ needs.context.outputs.hv }}-${{ needs.context.outputs.arch }}-${{ needs.context.outputs.platform }}" |
188 | | - artifact_run_id: ${{ needs.context.outputs.original_run_id }} |
189 | | - eden_version: "1.0.13" |
| 228 | + runs-on: ubuntu-latest |
| 229 | + steps: |
| 230 | + - name: Trigger Eden tests via repository dispatch |
| 231 | + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 |
| 232 | + env: |
| 233 | + EDEN_VERSION: ${{ needs.select_eden_version.outputs.eden_version }} |
| 234 | + EVE_IMAGE: "evebuild/pr:${{ needs.context.outputs.pr_id }}" |
| 235 | + EVE_ARTIFACT_NAME: "eve-${{ needs.context.outputs.hv }}-${{ needs.context.outputs.arch }}-${{ needs.context.outputs.platform }}" |
| 236 | + ARTIFACT_RUN_ID: ${{ needs.context.outputs.original_run_id }} |
| 237 | + with: |
| 238 | + script: | |
| 239 | + const [owner, repo] = 'lf-edge/eden'.split('/'); |
| 240 | + const dispatchResponse = await github.rest.actions.createWorkflowDispatch({ |
| 241 | + owner, |
| 242 | + repo, |
| 243 | + workflow_id: 'test.yml', |
| 244 | + ref: process.env.EDEN_VERSION, |
| 245 | + inputs: { |
| 246 | + eve_image: process.env.EVE_IMAGE, |
| 247 | + eve_log_level: 'debug', |
| 248 | + eve_artifact_name: process.env.EVE_ARTIFACT_NAME, |
| 249 | + artifact_run_id: process.env.ARTIFACT_RUN_ID, |
| 250 | + eden_version: process.env.EDEN_VERSION |
| 251 | + } |
| 252 | + }); |
| 253 | +
|
| 254 | + // Wait briefly for the workflow run to be created |
| 255 | + await new Promise(resolve => setTimeout(resolve, 2000)); |
| 256 | +
|
| 257 | + // Get the workflow run that was just triggered |
| 258 | + const { data: runs } = await github.rest.actions.listWorkflowRuns({ |
| 259 | + owner, |
| 260 | + repo, |
| 261 | + workflow_id: 'test.yml', |
| 262 | + branch: process.env.EDEN_VERSION, |
| 263 | + per_page: 1 |
| 264 | + }); |
| 265 | +
|
| 266 | + const triggeredRunId = runs.workflow_runs[0]?.id; |
| 267 | + if (triggeredRunId) { |
| 268 | + core.setOutput('eden_run_id', triggeredRunId); |
| 269 | + console.log(`Triggered Eden workflow run ID: ${triggeredRunId}`); |
| 270 | + } else { |
| 271 | + console.log('Warning: Could not retrieve triggered workflow run ID'); |
| 272 | + } |
| 273 | + }); |
| 274 | +
|
| 275 | + // Wait for the Eden workflow to complete |
| 276 | + console.log('Waiting for Eden workflow to complete...'); |
| 277 | + let workflowCompleted = false; |
| 278 | + let conclusion = null; |
| 279 | + const maxWaitTime = 4 * 60 * 60 * 1000; // 4 hours |
| 280 | + const pollInterval = 30000; // 30 seconds |
| 281 | + const startTime = Date.now(); |
| 282 | +
|
| 283 | + while (!workflowCompleted && (Date.now() - startTime) < maxWaitTime) { |
| 284 | + const { data: run } = await github.rest.actions.getWorkflowRun({ |
| 285 | + owner, |
| 286 | + repo, |
| 287 | + run_id: triggeredRunId |
| 288 | + }); |
| 289 | +
|
| 290 | + if (run.status === 'completed') { |
| 291 | + workflowCompleted = true; |
| 292 | + conclusion = run.conclusion; |
| 293 | + console.log(`Eden workflow completed with conclusion: ${conclusion}`); |
| 294 | + } else { |
| 295 | + console.log(`Eden workflow status: ${run.status}, waiting...`); |
| 296 | + await new Promise(resolve => setTimeout(resolve, pollInterval)); |
| 297 | + } |
| 298 | + } |
| 299 | +
|
| 300 | + if (!workflowCompleted) { |
| 301 | + core.setFailed('Eden workflow did not complete within the timeout period'); |
| 302 | + } else if (conclusion !== 'success') { |
| 303 | + core.setFailed(`Eden workflow completed with conclusion: ${conclusion}`); |
| 304 | + } |
| 305 | +
|
| 306 | + core.setOutput('eden_conclusion', conclusion); |
190 | 307 |
|
191 | 308 | finalize: |
192 | 309 | name: Finalize Eden Runner status |
|
0 commit comments