From fbd5a7e34c63f14a395ad1e104d2954716b16c7a Mon Sep 17 00:00:00 2001 From: sobolevn Date: Tue, 13 Aug 2024 12:10:33 +0300 Subject: [PATCH 1/5] gh-122965: Fix `reusable-change-detection.yml` on `workflow_dispatch` --- .github/workflows/reusable-change-detection.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/reusable-change-detection.yml b/.github/workflows/reusable-change-detection.yml index 25c789d335efc8..ef8988e6382109 100644 --- a/.github/workflows/reusable-change-detection.yml +++ b/.github/workflows/reusable-change-detection.yml @@ -133,6 +133,7 @@ jobs: run: | echo "run-docs=true" >> "${GITHUB_OUTPUT}" - name: Get a list of the MSI installer-related files + if: github.event_name == 'pull_request' id: changed-win-msi-files uses: Ana06/get-changed-files@v2.3.0 with: @@ -142,9 +143,8 @@ jobs: format: csv # works for paths with spaces - name: Check for changes in MSI installer-related files if: >- - steps.changed-win-msi-files.outputs.added_modified_renamed != '' + github.event_name == 'pull_request' + && steps.changed-win-msi-files.outputs.added_modified_renamed != '' id: win-msi-changes run: | echo "run-win-msi=true" >> "${GITHUB_OUTPUT}" - -... From 3cf547fbc2437252e88bbafe5dbb52237315c5a1 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Tue, 13 Aug 2024 14:07:17 +0300 Subject: [PATCH 2/5] Don't skip MSI and Docs jobs and workflow_dispatch --- .github/workflows/reusable-change-detection.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/reusable-change-detection.yml b/.github/workflows/reusable-change-detection.yml index ef8988e6382109..c1595660c6f7e5 100644 --- a/.github/workflows/reusable-change-detection.yml +++ b/.github/workflows/reusable-change-detection.yml @@ -127,8 +127,9 @@ jobs: format: csv # works for paths with spaces - name: Check for docs changes if: >- - github.event_name == 'pull_request' - && steps.changed-docs-files.outputs.added_modified_renamed != '' + (github.event_name == 'pull_request' + && steps.changed-docs-files.outputs.added_modified_renamed != '') + || github.event_name == 'workflow_dispatch' id: docs-changes run: | echo "run-docs=true" >> "${GITHUB_OUTPUT}" @@ -143,8 +144,9 @@ jobs: format: csv # works for paths with spaces - name: Check for changes in MSI installer-related files if: >- - github.event_name == 'pull_request' - && steps.changed-win-msi-files.outputs.added_modified_renamed != '' + (github.event_name == 'pull_request' + && steps.changed-win-msi-files.outputs.added_modified_renamed != '' + ) || github.event_name == 'workflow_dispatch' id: win-msi-changes run: | echo "run-win-msi=true" >> "${GITHUB_OUTPUT}" From 6d04e6dd4a2098a10b8d98ce0762294769c1d728 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Tue, 13 Aug 2024 14:21:21 +0300 Subject: [PATCH 3/5] Fix Docs build --- .github/workflows/reusable-change-detection.yml | 10 +++++++--- .github/workflows/reusable-docs.yml | 5 +++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/reusable-change-detection.yml b/.github/workflows/reusable-change-detection.yml index c1595660c6f7e5..1ea12ee40d53ce 100644 --- a/.github/workflows/reusable-change-detection.yml +++ b/.github/workflows/reusable-change-detection.yml @@ -126,10 +126,12 @@ jobs: .github/workflows/reusable-docs.yml format: csv # works for paths with spaces - name: Check for docs changes + # We only want to run this on PRs when related files are changed, + # or when user triggers manual workflow run. if: >- (github.event_name == 'pull_request' - && steps.changed-docs-files.outputs.added_modified_renamed != '') - || github.event_name == 'workflow_dispatch' + && steps.changed-docs-files.outputs.added_modified_renamed != '' + ) || github.event_name == 'workflow_dispatch' id: docs-changes run: | echo "run-docs=true" >> "${GITHUB_OUTPUT}" @@ -143,9 +145,11 @@ jobs: .github/workflows/reusable-windows-msi.yml format: csv # works for paths with spaces - name: Check for changes in MSI installer-related files + # We only want to run this on PRs when related files are changed, + # or when user triggers manual workflow run. if: >- (github.event_name == 'pull_request' - && steps.changed-win-msi-files.outputs.added_modified_renamed != '' + && steps.changed-win-msi-files.outputs.added_modified_renamed != '' ) || github.event_name == 'workflow_dispatch' id: win-msi-changes run: | diff --git a/.github/workflows/reusable-docs.yml b/.github/workflows/reusable-docs.yml index 859f78d043ba92..29959e837d9977 100644 --- a/.github/workflows/reusable-docs.yml +++ b/.github/workflows/reusable-docs.yml @@ -23,11 +23,16 @@ jobs: refspec_pr: '+${{ github.event.pull_request.head.sha }}:remotes/origin/${{ github.event.pull_request.head.ref }}' steps: - name: 'Check out latest PR branch commit' + if: github.event_name == 'pull_request' uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} + - name: 'Check out latest commit' + if: github.event_name != 'pull_request' + uses: actions/checkout@v4 # Adapted from https://github.com/actions/checkout/issues/520#issuecomment-1167205721 - name: 'Fetch commits to get branch diff' + if: github.event_name == 'pull_request' run: | # Fetch enough history to find a common ancestor commit (aka merge-base): git fetch origin ${{ env.refspec_pr }} --depth=$(( ${{ github.event.pull_request.commits }} + 1 )) \ From 4aadb4aa152551280c3762dfe9820e7e8914ba3d Mon Sep 17 00:00:00 2001 From: sobolevn Date: Tue, 13 Aug 2024 14:34:05 +0300 Subject: [PATCH 4/5] Address review --- .github/workflows/reusable-docs.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/reusable-docs.yml b/.github/workflows/reusable-docs.yml index 29959e837d9977..c6cd89cdcdb169 100644 --- a/.github/workflows/reusable-docs.yml +++ b/.github/workflows/reusable-docs.yml @@ -27,9 +27,6 @@ jobs: uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} - - name: 'Check out latest commit' - if: github.event_name != 'pull_request' - uses: actions/checkout@v4 # Adapted from https://github.com/actions/checkout/issues/520#issuecomment-1167205721 - name: 'Fetch commits to get branch diff' if: github.event_name == 'pull_request' @@ -45,6 +42,9 @@ jobs: # Get all commits since that commit date from the base branch (eg: master or main): git fetch origin ${{ env.refspec_base }} --shallow-since="${DATE}" \ --no-tags --prune --no-recurse-submodules + - name: 'Check out latest commit' + if: github.event_name != 'pull_request' + uses: actions/checkout@v4 - name: 'Set up Python' uses: actions/setup-python@v5 with: From e20a1c466b4b05c974b4248ced41f9b501f8a6e9 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Tue, 13 Aug 2024 16:03:20 +0300 Subject: [PATCH 5/5] Address review --- .github/workflows/reusable-change-detection.yml | 6 ++++-- .github/workflows/reusable-docs.yml | 11 ++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/reusable-change-detection.yml b/.github/workflows/reusable-change-detection.yml index 1ea12ee40d53ce..6f599f75547ceb 100644 --- a/.github/workflows/reusable-change-detection.yml +++ b/.github/workflows/reusable-change-detection.yml @@ -129,7 +129,8 @@ jobs: # We only want to run this on PRs when related files are changed, # or when user triggers manual workflow run. if: >- - (github.event_name == 'pull_request' + ( + github.event_name == 'pull_request' && steps.changed-docs-files.outputs.added_modified_renamed != '' ) || github.event_name == 'workflow_dispatch' id: docs-changes @@ -148,7 +149,8 @@ jobs: # We only want to run this on PRs when related files are changed, # or when user triggers manual workflow run. if: >- - (github.event_name == 'pull_request' + ( + github.event_name == 'pull_request' && steps.changed-win-msi-files.outputs.added_modified_renamed != '' ) || github.event_name == 'workflow_dispatch' id: win-msi-changes diff --git a/.github/workflows/reusable-docs.yml b/.github/workflows/reusable-docs.yml index c6cd89cdcdb169..4b384f4b3fa602 100644 --- a/.github/workflows/reusable-docs.yml +++ b/.github/workflows/reusable-docs.yml @@ -23,10 +23,14 @@ jobs: refspec_pr: '+${{ github.event.pull_request.head.sha }}:remotes/origin/${{ github.event.pull_request.head.ref }}' steps: - name: 'Check out latest PR branch commit' - if: github.event_name == 'pull_request' uses: actions/checkout@v4 with: - ref: ${{ github.event.pull_request.head.sha }} + ref: >- + ${{ + github.event_name == 'pull_request' + && github.event.pull_request.head.sha + || '' + }} # Adapted from https://github.com/actions/checkout/issues/520#issuecomment-1167205721 - name: 'Fetch commits to get branch diff' if: github.event_name == 'pull_request' @@ -42,9 +46,6 @@ jobs: # Get all commits since that commit date from the base branch (eg: master or main): git fetch origin ${{ env.refspec_base }} --shallow-since="${DATE}" \ --no-tags --prune --no-recurse-submodules - - name: 'Check out latest commit' - if: github.event_name != 'pull_request' - uses: actions/checkout@v4 - name: 'Set up Python' uses: actions/setup-python@v5 with: