diff --git a/.github/workflows/ci_weekly_report.yaml b/.github/workflows/ci_weekly_report.yaml new file mode 100644 index 0000000000..c5c98b46b5 --- /dev/null +++ b/.github/workflows/ci_weekly_report.yaml @@ -0,0 +1,123 @@ +name: weekly CI test report +on: + schedule: + - cron: '37 9 * * 1' # 9:37AM UTC -> 2:37AM PST every monday + workflow_dispatch: + inputs: + ci_runs: + description: 'The amount of runs to trigger in CI test report' +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + setup: + if: github.repository == 'commaai/openpilot' + runs-on: ubuntu-latest + outputs: + ci_runs: ${{ steps.ci_runs_setup.outputs.value }} + steps: + - id: ci_runs_setup + run: | + CI_RUNS=${{ inputs.ci_runs || '50' }} + mylist="value=[" + + 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: + needs: [ setup ] + strategy: + fail-fast: false + matrix: + value: ${{fromJSON(needs.setup.outputs.ci_runs)}} + uses: commaai/openpilot/.github/workflows/ci_weekly_run.yaml@master + with: + run_number: ${{ matrix.value }} + + report: + needs: [ci_matrix_run] + runs-on: ubuntu-latest + if: always() + steps: + - name: Get job results + uses: actions/github-script@v7 + id: get-job-results + with: + script: | + const jobs = await github + .paginate("GET /repos/{owner}/{repo}/actions/runs/{run_id}/attempts/{attempt}/jobs", { + owner: "commaai", + repo: "${{ github.event.repository.name }}", + run_id: "${{ github.run_id }}", + attempt: "${{ github.run_attempt }}", + }) + var report = {} + jobs.slice(1, jobs.length-1).forEach(job => { + const jobName = job.name.split('/')[2].trim(); + report[jobName] = report[jobName] || { successes: [], failures: [], cancelled: [] }; + switch (job.conclusion) { + case "success": + report[jobName].successes.push(job.html_url); break; + case "failure": + report[jobName].failures.push(job.html_url); break; + case "cancelled": + report[jobName].cancelled.push(job.html_url); break; + } + }); + return JSON.stringify(report); + + - name: Add job results to summary + env: + JOB_RESULTS: ${{ fromJSON(steps.get-job-results.outputs.result) }} + run: | + echo $JOB_RESULTS > job_results.json + generate_html_table() { + echo "
Job | " + echo "Succeeded ✅ | " + echo "Failed ❌ | " + echo "Cancelled (timed out) ⏰ | " + echo "
---|---|---|---|
\($job) | ", + "",
+ " ",
+ " ",
+ " (\(.[$job].successes | length))", + " \(.[$job].successes[])", + " | ",
+ " ",
+ " ",
+ " ",
+ " (\(.[$job].failures | length))", + " \(.[$job].failures[])", + " | ",
+ " ",
+ " ",
+ " ",
+ " (\(.[$job].cancelled | length))", + " \(.[$job].cancelled[])", + " | ",
+ "