This is an automated email from the ASF dual-hosted git repository.

kaxilnaik pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/master by this push:
     new 4fcc71c  Fixes selective tests in case of missing merge commits 
(#11641)
4fcc71c is described below

commit 4fcc71c2ffbf87585759f49ab7e426ccb9516f87
Author: Jarek Potiuk <[email protected]>
AuthorDate: Mon Oct 19 02:05:50 2020 +0200

    Fixes selective tests in case of missing merge commits (#11641)
    
    In case of very simple changes, there might be no merge commits
    generated by GitHub. In such cases we should take the commit SHA
    instead as the base of change calculation for selective tests.
---
 .github/workflows/build-images-workflow-run.yml |  3 ++-
 .github/workflows/ci.yml                        |  9 ++++++++-
 scripts/ci/selective_ci_checks.sh               | 20 +++++++++++++++++++-
 3 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/.github/workflows/build-images-workflow-run.yml 
b/.github/workflows/build-images-workflow-run.yml
index f291081..97d75c9 100644
--- a/.github/workflows/build-images-workflow-run.yml
+++ b/.github/workflows/build-images-workflow-run.yml
@@ -223,10 +223,11 @@ jobs:
         env:
           EVENT_NAME: ${{ needs.cancel-workflow-runs.outputs.sourceEvent }}
           MERGE_COMMIT_SHA: ${{ 
needs.cancel-workflow-runs.outputs.mergeCommitSha }}
+          COMMIT_SHA: ${{ needs.cancel-workflow-runs.outputs.sourceHeadSha }}
         run: |
           if [[ ${EVENT_NAME} == "pull_request" ]]; then
             # Run selective checks
-            ./scripts/ci/selective_ci_checks.sh "${MERGE_COMMIT_SHA}"
+            ./scripts/ci/selective_ci_checks.sh "${MERGE_COMMIT_SHA}" 
"${COMMIT_SHA}"
           else
             # Run all checks
             ./scripts/ci/selective_ci_checks.sh
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 5de2d3f..badd9d3 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -106,6 +106,13 @@ jobs:
           ref: ${{ github.event.pull_request.merge_commit_sha }}
           fetch-depth: 2
         if: github.event_name  == 'pull_request'
+      - name: >
+          Fetch commit ${{ github.ref }} ( ${{ github.sha }}
+        uses: actions/checkout@v2
+        with:
+          ref: ${{ github.sha }}
+          fetch-depth: 2
+        if: github.event_name  == 'pull_request'
       - name: "Checkout ${{ github.ref }} ( ${{ github.sha }} : merge commit 
${{ github.merge_commit_sha }} )"
         uses: actions/checkout@v2
       - name: >
@@ -133,7 +140,7 @@ jobs:
         run: |
           if [[ ${EVENT_NAME} == "pull_request" ]]; then
             # Run selective checks
-            ./scripts/ci/selective_ci_checks.sh "${MERGE_COMMIT_SHA}"
+            ./scripts/ci/selective_ci_checks.sh "${MERGE_COMMIT_SHA}" 
"${GITHUB_SHA}"
           else
             # Run all checks
             ./scripts/ci/selective_ci_checks.sh
diff --git a/scripts/ci/selective_ci_checks.sh 
b/scripts/ci/selective_ci_checks.sh
index 21d21c7..c24e932 100755
--- a/scripts/ci/selective_ci_checks.sh
+++ b/scripts/ci/selective_ci_checks.sh
@@ -24,7 +24,8 @@
 #      sets all the version outputs that determine that all tests should be 
run. This happens in case
 #      the even triggering the workflow is 'schedule' or 'push'. Merge commit 
is only
 #      available in case of 'pull_request' triggered runs.
-#
+# $2 - Commit of the change. It might happen that the merge commit is missing 
(in simple changes)
+#      In which case the change commit is treated as fallback
 declare -a pattern_array
 
 function output_all_basic_variables() {
@@ -393,12 +394,29 @@ if (($# < 1)); then
 fi
 
 MERGE_COMMIT_SHA="${1}"
+
+if (($# > 1)); then
+    COMMIT_SHA="${2}"
+    echo
+    echo "Commit SHA : ${COMMIT_SHA}"
+    echo
+    if [[ ${MERGE_COMMIT_SHA} == "" ]]; then
+       MERGE_COMMIT_SHA=${COMMIT_SHA}
+    fi
+fi
 readonly MERGE_COMMIT_SHA
 
 echo
 echo "Merge commit SHA: ${MERGE_COMMIT_SHA}"
 echo
 
+if [[ ${MERGE_COMMIT_SHA} == "" ]] ; then
+    echo
+    echo "Merge commit SHA empty - running all tests!"
+    echo
+    set_outputs_run_everything_and_exit
+fi
+
 image_build_needed="false"
 tests_needed="false"
 kubernetes_tests_needed="false"

Reply via email to