From e8aa81a2a0cbdd49712d7ca06aeb5d6c6e3cbb93 Mon Sep 17 00:00:00 2001 From: Austin Date: Fri, 27 Jun 2025 17:23:24 -0400 Subject: [PATCH] summarize --- .github/workflows/update_fsc_evm_version.yml | 125 ++++++++++++++++++- 1 file changed, 124 insertions(+), 1 deletion(-) diff --git a/.github/workflows/update_fsc_evm_version.yml b/.github/workflows/update_fsc_evm_version.yml index 59de8e9b..e726599d 100644 --- a/.github/workflows/update_fsc_evm_version.yml +++ b/.github/workflows/update_fsc_evm_version.yml @@ -21,8 +21,11 @@ on: jobs: trigger-fsc-evm-update: runs-on: ubuntu-latest + outputs: + workflow_run_id: ${{ steps.trigger.outputs.workflow_run_id }} steps: - name: Trigger FSC EVM Update Workflow + id: trigger run: | echo "Triggering FSC EVM update workflow..." echo "Version: ${{ github.event.inputs.version }}" @@ -47,9 +50,129 @@ jobs: if [ "$http_code" -eq 204 ]; then echo "✅ Workflow dispatched successfully!" + + # Wait a moment for the workflow to start, then get the run ID + sleep 10 + + # Get the most recent workflow run for this workflow + run_response=$(curl -s -H "Authorization: Bearer ${{ secrets.BUILD_ACTIONS_TOKEN }}" \ + -H "Accept: application/vnd.github.v3+json" \ + "https://api.github.com/repos/FlipsideCrypto/evm-build-actions/actions/workflows/update_fsc_evm_version.yml/runs?per_page=1") + + workflow_run_id=$(echo "$run_response" | jq -r '.workflow_runs[0].id') + echo "workflow_run_id=$workflow_run_id" >> $GITHUB_OUTPUT + echo "📋 Workflow Run ID: $workflow_run_id" else echo "❌ Failed to dispatch workflow" echo "HTTP Status Code: $http_code" echo "Response Body: $body" exit 1 - fi \ No newline at end of file + fi + + wait-and-get-summary: + needs: trigger-fsc-evm-update + runs-on: ubuntu-latest + steps: + - name: Wait for workflow completion + run: | + echo "⏳ Waiting for workflow to complete..." + + while true; do + status_response=$(curl -s -H "Authorization: Bearer ${{ secrets.BUILD_ACTIONS_TOKEN }}" \ + -H "Accept: application/vnd.github.v3+json" \ + "https://api.github.com/repos/FlipsideCrypto/evm-build-actions/actions/runs/${{ needs.trigger-fsc-evm-update.outputs.workflow_run_id }}") + + status=$(echo "$status_response" | jq -r '.status') + conclusion=$(echo "$status_response" | jq -r '.conclusion') + + echo "Status: $status, Conclusion: $conclusion" + + if [ "$status" = "completed" ]; then + if [ "$conclusion" = "success" ]; then + echo "✅ Workflow completed successfully!" + else + echo "❌ Workflow completed with status: $conclusion" + fi + break + fi + + echo "⏳ Still running... waiting 30 seconds" + sleep 30 + done + + - name: Get workflow summary + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.BUILD_ACTIONS_TOKEN }} + script: | + const workflowRunId = '${{ needs.trigger-fsc-evm-update.outputs.workflow_run_id }}'; + + try { + // Get all jobs from the workflow run + const jobsResponse = await github.rest.actions.listJobsForWorkflowRun({ + owner: 'FlipsideCrypto', + repo: 'evm-build-actions', + run_id: workflowRunId + }); + + const summarizeJob = jobsResponse.data.jobs.find(job => job.name === 'summarize'); + const updateJobs = jobsResponse.data.jobs.filter(job => job.name.startsWith('update-repos')); + + // Count job results + let successful = 0; + let failed = 0; + let skipped = 0; + + for (const job of updateJobs) { + if (job.conclusion === 'success') { + successful++; + } else if (job.conclusion === 'failure') { + failed++; + } else if (job.conclusion === 'skipped') { + skipped++; + } + } + + // Get workflow run details + const runResponse = await github.rest.actions.getWorkflowRun({ + owner: 'FlipsideCrypto', + repo: 'evm-build-actions', + run_id: workflowRunId + }); + + const workflowRun = runResponse.data; + + // Create comprehensive summary + const summary = `# FSC EVM Update Workflow Summary + + **Workflow Run:** [View in evm-build-actions](https://github.com/FlipsideCrypto/evm-build-actions/actions/runs/${workflowRunId}) + **Status:** ${workflowRun.conclusion || workflowRun.status} + **Started:** ${new Date(workflowRun.created_at).toLocaleString()} + **Completed:** ${workflowRun.updated_at ? new Date(workflowRun.updated_at).toLocaleString() : 'Still running'} + + ## Job Results + | Job Type | Status | Count | + |----------|--------|-------| + | ✅ Successful Updates | ${successful} | + | ❌ Failed Updates | ${failed} | + | ⏭️ Skipped Updates | ${skipped} | + | 📊 Summary Job | ${summarizeJob ? summarizeJob.conclusion : 'Not found'} | + + ## Workflow Details + - **Total Jobs:** ${jobsResponse.data.jobs.length} + - **Update Jobs:** ${updateJobs.length} + - **Duration:** ${workflowRun.updated_at ? Math.round((new Date(workflowRun.updated_at) - new Date(workflowRun.created_at)) / 1000) : 'N/A'}s + + > 💡 **Note:** For detailed results and logs, please check the [workflow run in evm-build-actions](https://github.com/FlipsideCrypto/evm-build-actions/actions/runs/${workflowRunId}) + `; + + await core.summary.addRaw(summary).write(); + console.log('✅ Enhanced summary created in this workflow'); + + // Also log some key metrics + console.log(`📊 Job Summary: ${successful} successful, ${failed} failed, ${skipped} skipped`); + + } catch (error) { + console.error('Error fetching enhanced summary:', error); + await core.summary.addRaw('# FSC EVM Update Workflow Summary\n\nError fetching summary from the called workflow. Check the [workflow run](https://github.com/FlipsideCrypto/evm-build-actions/actions/runs/' + workflowRunId + ') for details.').write(); + } \ No newline at end of file