From 1f6918cd644e57c4c860ae4aa8f8fc12645fe514 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Stolarczuk?= Date: Wed, 6 Mar 2024 14:40:06 +0100 Subject: [PATCH 1/2] [CI] Fix E2E workflows on PR trigger By default 'issue_comment' trigger gets the context of a default branch. If we want to test the actual PR, on which we created/edited a comment we have to fetch and checkout a special ref for PR's merge commit. Note, that 'pull//merge' ref is available as long as the PR is not merged. This commit do not take this under consideration, since this case should be fairly uncommon and would obfuscate the workflow. --- .github/workflows/e2e_core.yml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/e2e_core.yml b/.github/workflows/e2e_core.yml index e4c59956dc..f953f25600 100644 --- a/.github/workflows/e2e_core.yml +++ b/.github/workflows/e2e_core.yml @@ -66,10 +66,6 @@ jobs: ls -la ./ rm -rf ./* || true - - uses: xt0rted/pull-request-comment-branch@d97294d304604fa98a2600a6e2f916a84b596dc7 # v2.0.0 - id: comment-branch - if: ${{ always() && inputs.trigger != 'schedule' }} - - name: Add comment to PR uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 if: ${{ always() && inputs.trigger != 'schedule' }} @@ -90,7 +86,18 @@ jobs: uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 with: path: ur-repo - ref: ${{ steps.comment-branch.outputs.head_ref }} + + # On issue_comment trigger (for PRs) we need to fetch special ref for + # proper PR's merge commit. Note, this ref may be absent if the PR is already merged. + - name: Fetch PR's merge commit + if: ${{ inputs.trigger != 'schedule' }} + working-directory: ${{github.workspace}}/ur-repo + env: + PR_NO: ${{github.event.issue.number}} + run: | + git fetch -- https://github.com/${{github.repository}} +refs/pull/${PR_NO}/*:refs/remotes/origin/pr/${PR_NO}/* + git checkout origin/pr/${PR_NO}/merge + git rev-parse origin/pr/${PR_NO}/merge - name: Checkout SYCL uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 From 51bbfcf36cd0bdc475f7b2dcf958af4f83ba9078 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Stolarczuk?= Date: Wed, 6 Mar 2024 15:24:34 +0100 Subject: [PATCH 2/2] [CI] E2E on PR - add more information in the comment --- .github/workflows/e2e_core.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e_core.yml b/.github/workflows/e2e_core.yml index f953f25600..e2f374ee1a 100644 --- a/.github/workflows/e2e_core.yml +++ b/.github/workflows/e2e_core.yml @@ -198,8 +198,9 @@ jobs: script: | const adapter = '${{ matrix.adapter.name }}'; const url = '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'; - const status = '${{ steps.tests.outcome }}'; - const body = `E2E ${adapter} build: \n${url}\n Status: ${status}`; + const test_status = '${{ steps.tests.outcome }}'; + const job_status = '${{ job.status }}'; + const body = `E2E ${adapter} build:\n${url}\nJob status: ${job_status}. Test status: ${test_status}`; github.rest.issues.createComment({ issue_number: context.issue.number,