]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
.github: Fix CherryPickTest to only run when it should
authorGeorge Joseph <gjoseph@sangoma.com>
Wed, 3 May 2023 15:27:57 +0000 (09:27 -0600)
committerGeorge Joseph <gjoseph@sangoma.com>
Wed, 3 May 2023 15:27:57 +0000 (09:27 -0600)
Fixed CherryPickTest so it triggers only on the
"cherry-pick-test" label instead of all labels.

.github/workflows/CherryPickTest.yml

index 810e3ee1f6b2c2841ac57502373dd88c78ae28d7..88c0bc4029fc71a8624165028fdb8713dfc44604 100644 (file)
@@ -1,32 +1,31 @@
 name: CherryPickTest
-run-name: "Cherry-Pick Tests for PR ${{github.event.number || inputs.pr_number}}"
+run-name: "Cherry-Pick Tests for PR ${{github.event.number}}"
 on:
   pull_request_target:
     types: [ labeled ]
-  workflow_dispatch:
-    inputs:
-      pr_number:
-        description: 'PR number'
-        required: true
-        type: number
 
 concurrency:
-  group: ${{github.workflow}}-${{github.event.number || inputs.pr_number }}
+  group: ${{github.workflow}}-${{github.event.number}}
   cancel-in-progress: true
 
 env:
-  PR_NUMBER:          ${{ github.event.number || inputs.pr_number }}
+  PR_NUMBER:          ${{ github.event.number }}
   MODULES_BLACKLIST:  ${{ vars.GATETEST_MODULES_BLACKLIST }} ${{ vars.UNITTEST_MODULES_BLACKLIST }}
 
 jobs:
   IdentifyBranches:
     name: IdentifyBranches
-    if: github.event.label.name == ${{vars.CHERRY_PICK_TEST_LABEL}}
+    if: ${{ github.event.label.name == vars.CHERRY_PICK_TEST_LABEL }}
     outputs:
       branches:     ${{ steps.getbranches.outputs.branches }}
       branch_count: ${{ steps.getbranches.outputs.branch_count }}
     runs-on: ubuntu-latest
     steps:
+      - name: DumpEnvironment
+        uses: asterisk/asterisk-ci-actions/DumpEnvironmentAction@main
+        with:
+          action-vars: ${{toJSON(vars)}}
+
       - name: Remove Trigger Label, Add InProgress Label
         env:
           GH_TOKEN:          ${{ secrets.GITHUB_TOKEN }}
@@ -37,7 +36,7 @@ jobs:
             --remove-label ${{vars.CHERRY_PICK_CHECKS_FAILED_LABEL}} \
             --remove-label ${{vars.CHERRY_PICK_GATES_PASSED_LABEL}} \
             --remove-label ${{vars.CHERRY_PICK_GATES_FAILED_LABEL}} \
-            --add-label ${{vars.CHERRY_PICK_TESTING_IN_PROGRESS}} \
+            --remove-label ${{vars.CHERRY_PICK_TESTING_IN_PROGRESS}} \
             ${{env.PR_NUMBER}} || :
 
       - name: Get cherry-pick branches
@@ -49,9 +48,18 @@ jobs:
           cherry_pick_regex:       ${{vars.CHERRY_PICK_REGEX}}
           github_token:            ${{secrets.GITHUB_TOKEN}}
 
+      - name: Check Branch Count
+        if: ${{ steps.getbranches.outputs.branch_count > 0 }}
+        env:
+          GH_TOKEN:          ${{ secrets.GITHUB_TOKEN }}
+        run: |
+          gh pr edit --repo ${{github.repository}} \
+          --add-label ${{vars.CHERRY_PICK_TESTING_IN_PROGRESS}} \
+          ${{env.PR_NUMBER}} || :
+
   AsteriskUnitTestMatrix:
     needs: [ IdentifyBranches ]
-    if: needs.IdentifyBranches.outputs.branch_count > 0
+    if: ${{ needs.IdentifyBranches.outputs.branch_count > 0 && ( success() || failure() ) }}
     continue-on-error: false
     strategy:
       fail-fast: false
@@ -71,9 +79,9 @@ jobs:
           unittest_command:  ${{vars.UNITTEST_COMMAND}}
 
   AsteriskUnitTests:
-    if: ${{ always() }}
+    needs: [ IdentifyBranches, AsteriskUnitTestMatrix ]
+    if: ${{ needs.IdentifyBranches.outputs.branch_count > 0 && ( success() || failure() ) }}
     runs-on: ubuntu-latest
-    needs: [ AsteriskUnitTestMatrix ] 
     steps:
       - name: Check unit test matrix status
         env:
@@ -131,9 +139,9 @@ jobs:
           gatetest_commands: ${{vars.GATETEST_COMMANDS}}
 
   AsteriskGateTests:
-    if: ${{ always() }}
+    needs: [ IdentifyBranches, AsteriskGateTestMatrix ]
+    if: ${{ success() || failure() }}
     runs-on: ubuntu-latest
-    needs: AsteriskGateTestMatrix
     steps:
       - name: Check test matrix status
         env: