From 48ade5e60b133d9d5d0bf3c7c5c8ac4e85c649c3 Mon Sep 17 00:00:00 2001 From: Vladimir Milosevic <157983820+vmilosevic@users.noreply.github.com> Date: Mon, 3 Feb 2025 14:35:01 +0100 Subject: [PATCH] Add check-all job and fix job_id (#2053) Add check-all job that will be used as required check This should eliminate the need for constant updating of required checks list in repo config Getting job_id was broken for some jobs due to name changes Moving to action from tt-github-actions for fetching job_id. This should be more stable and uniform across projects. Action will fail if it can't fetch job_id, so it should also prevent us from breaking it in future. --- .github/workflows/build-and-test.yml | 65 ++++++++++++---------------- .github/workflows/on-pr.yml | 13 ++++++ .github/workflows/produce_data.yml | 1 + 3 files changed, 42 insertions(+), 37 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 4521d9ce1d..0543ee75c9 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -115,23 +115,21 @@ jobs: with: fetch-depth: 0 + - name: Fetch job id + id: fetch-job-id + uses: tenstorrent/tt-github-actions/.github/actions/job_id@main + with: + job_name: "Build and test tt-mlir (compute machine) (${{ matrix.build.runs-on }}, ${{ matrix.build.enable_perf }}, ${{ matrix.build.enable_op_model }}, ${{ matrix.build.enable_emitc }}, ${{ matrix.build.enable_async }}, ${{ matrix.build.name }})" + - name: Set reusable strings id: strings shell: bash env: - job-name: "Build tt-mlir (${{ matrix.build.runs-on }}, ${{ matrix.build.enable_perf }}, ${{ matrix.build.enable_op_model }}, ${{ matrix.build.enable_emitc }}, ${{ matrix.build.enable_async }}, ${{ matrix.build.name }})" + JOB_ID: ${{ steps.fetch-job-id.outputs.job_id }} run: | echo "work-dir=$(pwd)" >> "$GITHUB_OUTPUT" echo "build-output-dir=$(pwd)/build" >> "$GITHUB_OUTPUT" echo "install-output-dir=$(pwd)/install" >> "$GITHUB_OUTPUT" - - # Github job context unfortunately doesn't contain job_id, this is the workaround how to fetch it using GH API - echo "Expected job name: ${{ env.job-name }}" - JOB_ID=$(curl -s -H "Authorization: token ${{ secrets.GH_TOKEN }}" \ - "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}/jobs" | \ - jq -r '.jobs[] | select(.name | contains("${{ env.job-name }}")) | .id ') - echo "Current job id: $JOB_ID" - echo "job-id=$JOB_ID" >> "$GITHUB_OUTPUT" echo "test_report_path=report_$JOB_ID.xml" >> "$GITHUB_OUTPUT" - name: Git safe dir @@ -197,24 +195,21 @@ jobs: with: fetch-depth: 0 + - name: Fetch job id + id: fetch-job-id + uses: tenstorrent/tt-github-actions/.github/actions/job_id@main + with: + job_name: "run-tests (${{ matrix.build.runs-on }}, ${{ matrix.build.enable_perf }}, ${{ matrix.build.enable_emitc }}, ${{ matrix.build.enable_async }}, ${{ matrix.build.build_name }})" + - name: Set reusable strings id: strings shell: bash env: - job-name: "run-tests (${{ matrix.build.runs-on }}, ${{ matrix.build.enable_perf }}, ${{ matrix.build.enable_emitc }}, , ${{ matrix.build.enable_async }}, ${{ matrix.build.build_name }})" + JOB_ID: ${{ steps.fetch-job-id.outputs.job_id }} run: | echo "work-dir=$(pwd)" >> "$GITHUB_OUTPUT" echo "build-output-dir=$(pwd)/build" >> "$GITHUB_OUTPUT" echo "install-output-dir=$(pwd)/install" >> "$GITHUB_OUTPUT" - - # Github job context unfortunately doesn't contain job_id, this is the workaround how to fetch it using GH API - echo "Expected job name: ${{ env.job-name }}" - JOB_ID=$(curl -s -H "Authorization: token ${{ secrets.GH_TOKEN }}" \ - "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}/jobs" | \ - jq -r '.jobs[] | select(.name | contains("${{ env.job-name }}")) | .id ') - echo "Current job id: $JOB_ID" - - echo "job-id=$JOB_ID" >> "$GITHUB_OUTPUT" echo "test_report_path=report_$JOB_ID.xml" >> "$GITHUB_OUTPUT" echo "perf_report_path=perf_$JOB_ID" >> "$GITHUB_OUTPUT" @@ -367,23 +362,21 @@ jobs: with: fetch-depth: 0 + - name: Fetch job id + id: fetch-job-id + uses: tenstorrent/tt-github-actions/.github/actions/job_id@main + with: + job_name: "${{ github.job }} (${{ matrix.build.runs-on }}, ${{ matrix.build.enable_perf }}, ${{ matrix.build.name }}, ${{ matrix.build.build_name }})" + - name: Set reusable strings id: strings shell: bash env: - job-name: "${{ github.job }} (${{ matrix.build.runs-on }}, ${{ matrix.build.enable_perf }}, ${{ matrix.build.enable_emitc }}, ${{ matrix.build.build_name }})" + JOB_ID: ${{ steps.fetch-job-id.outputs.job_id }} run: | echo "work-dir=$(pwd)" >> "$GITHUB_OUTPUT" echo "build-output-dir=$(pwd)/build" >> "$GITHUB_OUTPUT" echo "install-output-dir=$(pwd)/install" >> "$GITHUB_OUTPUT" - - # Github job context unfortunately doesn't contain job_id, this is the workaround how to fetch it using GH API - echo "Expected job name: ${{ env.job-name }}" - JOB_ID=$(curl -s -H "Authorization: token ${{ secrets.GH_TOKEN }}" \ - "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}/jobs" | \ - jq -r '.jobs[] | select(.name | contains("${{ env.job-name }}")) | .id ') - echo "Current job id: $JOB_ID" - echo "job-id=$JOB_ID" >> "$GITHUB_OUTPUT" echo "test_report_path=report_$JOB_ID.xml" >> "$GITHUB_OUTPUT" - name: Git safe dir @@ -658,23 +651,21 @@ jobs: with: fetch-depth: 0 + - name: Fetch job id + id: fetch-job-id + uses: tenstorrent/tt-github-actions/.github/actions/job_id@main + with: + job_name: "Run build and test tt-mlir (TT machine) (${{ matrix.build.runs-on }}, ${{ matrix.build.enable_perf }}, ${{ matrix.build.enable_op_model }}, ${{ matrix.build.enable_emitc }}, ${{ matrix.build.enable_async }}, ${{ matrix.build.name }}, ${{ matrix.build.build_name }})" + - name: Set reusable strings id: strings shell: bash env: - job-name: "Build tt-mlir (${{ matrix.build.runs-on }}, ${{ matrix.build.enable_perf }}, ${{ matrix.build.enable_op_model }}, ${{ matrix.build.enable_emitc }}, ${{ matrix.build.enable_async }}, ${{ matrix.build.build_name }})" + JOB_ID: ${{ steps.fetch-job-id.outputs.job_id }} run: | echo "work-dir=$(pwd)" >> "$GITHUB_OUTPUT" echo "build-output-dir=$(pwd)/build" >> "$GITHUB_OUTPUT" echo "install-output-dir=$(pwd)/install" >> "$GITHUB_OUTPUT" - - # Github job context unfortunately doesn't contain job_id, this is the workaround how to fetch it using GH API - echo "Expected job name: ${{ env.job-name }}" - JOB_ID=$(curl -s -H "Authorization: token ${{ secrets.GH_TOKEN }}" \ - "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}/jobs" | \ - jq -r '.jobs[] | select(.name | contains("${{ env.job-name }}")) | .id ') - echo "Current job id: $JOB_ID" - echo "job-id=$JOB_ID" >> "$GITHUB_OUTPUT" echo "test_report_path=report_$JOB_ID.xml" >> "$GITHUB_OUTPUT" - name: Git safe dir diff --git a/.github/workflows/on-pr.yml b/.github/workflows/on-pr.yml index 0d43a97db2..6df5dd4a02 100644 --- a/.github/workflows/on-pr.yml +++ b/.github/workflows/on-pr.yml @@ -42,3 +42,16 @@ jobs: gh run list --workflow=${{ env.WORKFLOW_NAME }} --repo ${{ env.TARGET_REPO }} --limit 1 echo "Triggered ${{ env.TARGET_REPO }} with tt-mlir ${{ github.event.pull_request.head.sha }}" echo "### Triggered [${{ env.TARGET_REPO }}](https://github.com/${{ env.TARGET_REPO }}/actions/workflows/${{ env.WORKFLOW_NAME }}) with tt-mlir ${{ github.event.pull_request.head.sha }} :rocket:" >> $GITHUB_STEP_SUMMARY + + check-all-green: + if: always() + needs: + - pre-commit + - spdx + - build-and-test + runs-on: Ubuntu-latest + steps: + - name: Check if the needed jobs succeeded or failed + uses: re-actors/alls-green@release/v1 + with: + jobs: ${{ toJSON(needs) }} diff --git a/.github/workflows/produce_data.yml b/.github/workflows/produce_data.yml index e53ccc0f60..d4d149d454 100644 --- a/.github/workflows/produce_data.yml +++ b/.github/workflows/produce_data.yml @@ -1,4 +1,5 @@ name: "[internal] Collect workflow data" +run-name: "Collect data for run_id ${{ github.event.workflow_run.id }} attempt ${{ github.event.workflow_run.run_attempt }}" on: workflow_run: