Update ci weekly report summary (#32911)

* update ci weekly report summary

* don't add skipped jobs to report

* uncomment job condition

* use jinja template

* add run number to failure links

* add run number to failure links

* Log for run #<num>

* use list

---------

Co-authored-by: Maxime Desroches <desroches.maxime@gmail.com>
old-commit-hash: 6745c66352
pull/33029/head
signed-long 11 months ago committed by GitHub
parent 6ffb0d5445
commit 1e6e3243ef
  1. 104
      .github/workflows/ci_weekly_report.yaml

@ -10,38 +10,30 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }} group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true cancel-in-progress: true
env:
CI_RUNS: ${{ github.event.inputs.ci_runs || '50' }}
jobs: jobs:
setup: setup:
if: github.repository == 'commaai/openpilot' if: github.repository == 'commaai/openpilot'
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs: outputs:
ci_runs: ${{ steps.ci_runs_setup.outputs.value }} ci_runs: ${{ steps.ci_runs_setup.outputs.matrix }}
steps: steps:
- id: ci_runs_setup - id: ci_runs_setup
name: CI_RUNS=${{ env.CI_RUNS }}
run: | run: |
CI_RUNS=${{ inputs.ci_runs || '50' }} matrix=$(python3 -c "import json; print(json.dumps({ 'run_number' : list(range(${{ env.CI_RUNS }})) }))")
mylist="value=[" echo "matrix=$matrix" >> $GITHUB_OUTPUT
for i in $(seq 1 $CI_RUNS);
do
if [ $i != $CI_RUNS ]; then
mylist+="\"$i\", "
else
mylist+="\"$i\"]"
fi
done
echo "$mylist" >> $GITHUB_OUTPUT
echo "Number of CI runs for report: $CI_RUNS"
ci_matrix_run: ci_matrix_run:
needs: [ setup ] needs: [ setup ]
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix: ${{fromJSON(needs.setup.outputs.ci_runs)}}
value: ${{fromJSON(needs.setup.outputs.ci_runs)}}
uses: commaai/openpilot/.github/workflows/ci_weekly_run.yaml@master uses: commaai/openpilot/.github/workflows/ci_weekly_run.yaml@master
with: with:
run_number: ${{ matrix.value }} run_number: ${{ matrix.run_number }}
report: report:
needs: [ci_matrix_run] needs: [ci_matrix_run]
@ -62,62 +54,48 @@ jobs:
}) })
var report = {} var report = {}
jobs.slice(1, jobs.length-1).forEach(job => { jobs.slice(1, jobs.length-1).forEach(job => {
const jobName = job.name.split('/')[2].trim(); if (job.conclusion === "skipped") return;
const jobName = job.name.split(" / ")[2];
const runRegex = /\((.*?)\)/;
const run = job.name.match(runRegex)[1];
report[jobName] = report[jobName] || { successes: [], failures: [], cancelled: [] }; report[jobName] = report[jobName] || { successes: [], failures: [], cancelled: [] };
switch (job.conclusion) { switch (job.conclusion) {
case "success": case "success":
report[jobName].successes.push(job.html_url); break; report[jobName].successes.push({ "run_number": run, "link": job.html_url}); break;
case "failure": case "failure":
report[jobName].failures.push(job.html_url); break; report[jobName].failures.push({ "run_number": run, "link": job.html_url }); break;
case "cancelled": case "cancelled":
report[jobName].cancelled.push(job.html_url); break; report[jobName].cancelled.push({ "run_number": run, "link": job.html_url }); break;
} }
}); });
return JSON.stringify(report); return JSON.stringify({"jobs": report});
- name: Add job results to summary - name: Add job results to summary
env: env:
JOB_RESULTS: ${{ fromJSON(steps.get-job-results.outputs.result) }} JOB_RESULTS: ${{ fromJSON(steps.get-job-results.outputs.result) }}
run: | run: |
echo $JOB_RESULTS > job_results.json cat <<EOF >> template.html
generate_html_table() { <table>
echo "<table>" <thead>
echo "<thead>" <tr>
echo " <tr>" <th></th>
echo " <th>Job</th>" <th>Job</th>
echo " <th>Succeeded ✅</th>" <th>✅ Passing</th>
echo " <th>Failed ❌</th>" <th>❌ Failure Details</th>
echo " <th>Cancelled (timed out) ⏰</th>" </tr>
echo " </tr>" </thead>
echo "</thead>" <tbody>
jq -r ' {% for key in jobs.keys() %}<tr>
"<tbody>", <td>{% for i in range(5) %}{% if i+1 <= (5 * jobs[key]["successes"]|length // ${{ env.CI_RUNS }}) %}🟩{% else %}🟥{% endif %}{% endfor%}</td>
keys[] as $job | <td>{{ key }}</td>
"<tr>", <td>{{ 100 * jobs[key]["successes"]|length // ${{ env.CI_RUNS }} }}%</td>
" <td>\($job)</td>", <td>{% if jobs[key]["failures"]|length > 0 %}<details>{% for failure in jobs[key]["failures"] %}<a href="{{ failure['link'] }}">Log for run #{{ failure['run_number'] }}</a><br>{% endfor %}</details>{% else %}{% endif %}</td>
" <td>", </td>
" <details>", </tr>{% endfor %}
" <summary>(\(.[$job].successes | length))</summary>", </table>
" \(.[$job].successes[])<br>", EOF
" </details>",
" </td>",
" <td>",
" <details>",
" <summary>(\(.[$job].failures | length))</summary>",
" \(.[$job].failures[])<br>",
" </details>",
" </td>",
" <td>",
" <details>",
" <summary>(\(.[$job].cancelled | length))</summary>",
" \(.[$job].cancelled[])<br>",
" </details>",
" </td>",
"</tr>"
' job_results.json
echo "</tbody>"
echo "</table>"
}
echo "# CI Job Summary" >> $GITHUB_STEP_SUMMARY
generate_html_table >> $GITHUB_STEP_SUMMARY
pip install jinja2-cli
echo $JOB_RESULTS | jinja2 template.html > report.html
echo "# CI Test Report - ${{ env.CI_RUNS }} Runs" >> $GITHUB_STEP_SUMMARY
cat report.html >> $GITHUB_STEP_SUMMARY

Loading…
Cancel
Save