From 80ebb563bfc658b7cab326bfb0c47a4af06551ea Mon Sep 17 00:00:00 2001 From: Alexander Dokuchaev Date: Wed, 23 Apr 2025 23:50:59 +0300 Subject: [PATCH 1/2] job link --- .github/actions/add_job_link/action.yml | 38 +++++++++++++++++++ .../conformance_weight_compression.yml | 19 ++++++++++ .github/workflows/examples.yml | 19 ++++++++++ .github/workflows/install.yml | 19 ++++++++++ .github/workflows/macos.yml | 19 ++++++++++ 5 files changed, 114 insertions(+) create mode 100644 .github/actions/add_job_link/action.yml diff --git a/.github/actions/add_job_link/action.yml b/.github/actions/add_job_link/action.yml new file mode 100644 index 00000000000..5696cc0f67d --- /dev/null +++ b/.github/actions/add_job_link/action.yml @@ -0,0 +1,38 @@ +name: 'Add job link to PR description' +inputs: + pull_request_number: + description: 'Pull Request number' + required: true + +runs: + using: "composite" + steps: + - name: Update PR description with preview link + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + with: + script: | + const prNumber = parseInt(${{ inputs.pull_request_number }}); + const newLink = `https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}`; + const newLine = `[${{ github.workflow }}](${newLink})`; + + const { data: pr } = await github.rest.pulls.get({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: prNumber + }); + + let body = pr.body || ''; + const regex = /\[${{ github.workflow }}\]\([^)]+\)/; + + if (regex.test(body)) { + body = body.replace(regex, newLine); + } else { + body = body.trim() + `\n\n${newLine}`; + } + + await github.rest.pulls.update({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: prNumber, + body + }); diff --git a/.github/workflows/conformance_weight_compression.yml b/.github/workflows/conformance_weight_compression.yml index 9de6ac03807..731ce29d7f8 100644 --- a/.github/workflows/conformance_weight_compression.yml +++ b/.github/workflows/conformance_weight_compression.yml @@ -71,3 +71,22 @@ jobs: run: | pip install defusedxml==0.7.1 python .github/scripts/pytest_md_summary.py pytest-results.xml >> $GITHUB_STEP_SUMMARY + + update-pr-description: + name: Update PR description + runs-on: ubuntu-22.04 + if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.pull_request_number != '' }} + permissions: + contents: write + pull-requests: write + issues: write + steps: + - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + with: + sparse-checkout: .github/actions/add_job_link + - name: Update PR preview link + uses: ./.github/actions/add_job_link + with: + pull_request_number: ${{ inputs.pull_request_number }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index fe34511cde6..1aeda23ccc4 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -203,3 +203,22 @@ jobs: run: | pip install defusedxml==0.7.1 python .github/scripts/pytest_md_summary.py pytest-results.xml >> $GITHUB_STEP_SUMMARY + + update-pr-description: + name: Update PR description + runs-on: ubuntu-22.04 + if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.pull_request_number != '' }} + permissions: + contents: write + pull-requests: write + issues: write + steps: + - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + with: + sparse-checkout: .github/actions/add_job_link + - name: Update PR preview link + uses: ./.github/actions/add_job_link + with: + pull_request_number: ${{ inputs.pull_request_number }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/install.yml b/.github/workflows/install.yml index 93f46a70d79..b85de7d135e 100644 --- a/.github/workflows/install.yml +++ b/.github/workflows/install.yml @@ -90,3 +90,22 @@ jobs: export PATH=/usr/local/cuda-12.4/bin${PATH:+:${PATH}} export LD_LIBRARY_PATH=/usr/local/cuda-12.4/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} pytest tests/cross_fw/install -rA -s --host-configuration gpu --backend torch + + update-pr-description: + name: Update PR description + runs-on: ubuntu-22.04 + if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.pull_request_number != '' }} + permissions: + contents: write + pull-requests: write + issues: write + steps: + - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + with: + sparse-checkout: .github/actions/add_job_link + - name: Update PR preview link + uses: ./.github/actions/add_job_link + with: + pull_request_number: ${{ inputs.pull_request_number }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 311fda1171c..d56d12507f8 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -59,3 +59,22 @@ jobs: run: pytest -ra tests/openvino env: ONEDNN_MAX_CPU_ISA: AVX2 + + update-pr-description: + name: Update PR description + runs-on: ubuntu-22.04 + if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.pull_request_number != '' }} + permissions: + contents: write + pull-requests: write + issues: write + steps: + - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + with: + sparse-checkout: .github/actions/add_job_link + - name: Update PR preview link + uses: ./.github/actions/add_job_link + with: + pull_request_number: ${{ inputs.pull_request_number }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 27893dc51fdd347534e767d03250497541e74d8e Mon Sep 17 00:00:00 2001 From: Alexander Dokuchaev Date: Thu, 24 Apr 2025 17:03:53 +0300 Subject: [PATCH 2/2] link_name --- .github/actions/add_job_link/action.yml | 8 +++++--- .github/workflows/conformance_weight_compression.yml | 1 + .github/workflows/examples.yml | 1 + .github/workflows/install.yml | 1 + .github/workflows/macos.yml | 1 + 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/actions/add_job_link/action.yml b/.github/actions/add_job_link/action.yml index 5696cc0f67d..900fedd8f1b 100644 --- a/.github/actions/add_job_link/action.yml +++ b/.github/actions/add_job_link/action.yml @@ -3,7 +3,9 @@ inputs: pull_request_number: description: 'Pull Request number' required: true - + link_name: + description: 'Name of link, should contain only alphanumeric characters, dashes, and underscores' + required: true runs: using: "composite" steps: @@ -13,7 +15,7 @@ runs: script: | const prNumber = parseInt(${{ inputs.pull_request_number }}); const newLink = `https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}`; - const newLine = `[${{ github.workflow }}](${newLink})`; + const newLine = `[${{ inputs.link_name }}](${newLink})`; const { data: pr } = await github.rest.pulls.get({ owner: context.repo.owner, @@ -22,7 +24,7 @@ runs: }); let body = pr.body || ''; - const regex = /\[${{ github.workflow }}\]\([^)]+\)/; + const regex = /\[${{ inputs.link_name }}\]\([^)]+\)/; if (regex.test(body)) { body = body.replace(regex, newLine); diff --git a/.github/workflows/conformance_weight_compression.yml b/.github/workflows/conformance_weight_compression.yml index 731ce29d7f8..bc8a7facacf 100644 --- a/.github/workflows/conformance_weight_compression.yml +++ b/.github/workflows/conformance_weight_compression.yml @@ -88,5 +88,6 @@ jobs: uses: ./.github/actions/add_job_link with: pull_request_number: ${{ inputs.pull_request_number }} + link_name: "Test_Weight_Compression" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index 1aeda23ccc4..8cd62230dc0 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -220,5 +220,6 @@ jobs: uses: ./.github/actions/add_job_link with: pull_request_number: ${{ inputs.pull_request_number }} + link_name: "Test_Examples" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/install.yml b/.github/workflows/install.yml index b85de7d135e..88ceb5b1a3c 100644 --- a/.github/workflows/install.yml +++ b/.github/workflows/install.yml @@ -107,5 +107,6 @@ jobs: uses: ./.github/actions/add_job_link with: pull_request_number: ${{ inputs.pull_request_number }} + link_name: "Test_Install" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index d56d12507f8..a1760ceb215 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -76,5 +76,6 @@ jobs: uses: ./.github/actions/add_job_link with: pull_request_number: ${{ inputs.pull_request_number }} + link_name: "Test_MacOS" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}