]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
.github: Changes required to use cached builds and shorten names
authorGeorge Joseph <gjoseph@sangoma.com>
Sun, 28 Jul 2024 19:51:31 +0000 (13:51 -0600)
committerGeorge Joseph <gjoseph@sangoma.com>
Wed, 18 Sep 2024 14:06:26 +0000 (08:06 -0600)
.github/workflows/OnPRCherryPickTest.yml
.github/workflows/OnPRMergeApproved.yml
.github/workflows/OnPRRecheck.yml
.github/workflows/OnPRStateChanged.yml
.github/workflows/OnPRStateChangedPriv.yml

index e67070119f5f5f335372b8cd2065dc874357f7e9..f1a5df80ad6bfda9acbff741b21c522e55642ec1 100644 (file)
-name: PRCherryPickTest
-run-name: "PR ${{github.event.number}} CherryPickTest"
+name: PRCPCheck
+run-name: "PR ${{ github.event.number }} CherryPickTest"
 on:
   pull_request_target:
     types: [ labeled ]
 
 concurrency:
-  group: ${{github.workflow}}-${{github.event.label.name}}-${{github.event.number}}
+  group: ${{ github.workflow }}-${{ github.event.label.name }}-${{ github.event.number }}
   cancel-in-progress: true
 
+env:
+  PR_NUMBER: ${{ github.event.number }}
+
 jobs:
-  CherryPickTest:
-    name: CherryPickTest
+  Setup:
     if: ${{ github.event.label.name == vars.CHERRY_PICK_TEST_LABEL }}
-    uses: asterisk/asterisk-ci-actions/.github/workflows/AsteriskCherryPickTest.yml@main
+    name: Setup
+    runs-on: ubuntu-latest
+    outputs:
+      branches:           ${{ steps.getbranches.outputs.branches }}
+      branch_count:       ${{ steps.getbranches.outputs.branch_count }}
+      testsuite_test_pr:  ${{ steps.testsuitepr.outputs.testsuite_test_pr }}
+    steps:
+      - name: Remove Trigger Label, Add InProgress Label
+        env:
+          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        run: |
+          gh pr edit --repo ${{ github.repository }} \
+            --remove-label ${{ vars.CHERRY_PICK_TEST_LABEL }} \
+            --remove-label ${{ vars.CHERRY_PICK_CHECKS_PASSED_LABEL }} \
+            --remove-label ${{ vars.CHERRY_PICK_CHECKS_FAILED_LABEL }} \
+            --remove-label ${{ vars.CHERRY_PICK_TESTING_IN_PROGRESS }} \
+            $PR_NUMBER || :
+
+      - name: Get cherry-pick branches
+        uses: asterisk/asterisk-ci-actions/GetCherryPickBranchesFromPR@main
+        id: getbranches
+        with:
+          repo:                    ${{ github.repository }}
+          pr_number:               ${{ env.PR_NUMBER }}
+          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 }} \
+          $PR_NUMBER || :
+
+      - name: GetTestsuitePR
+        id: testsuitepr
+        uses: asterisk/asterisk-ci-actions/GetTestsuitePRFromAsteriskPR@main
+        with:
+          repo:                            ${{ github.repository }}
+          pr_number:                       ${{ github.event.number }}
+          testsuite_test_pr_regex:         ${{ vars.TESTSUITE_TEST_PR_REGEX }}
+          testsuite_test_auto_merge_regex: ${{ vars.TESTSUITE_TEST_AUTO_MERGE_REGEX }}
+          github_token:                    ${{ secrets.GITHUB_TOKEN }}
+
+      - name: CherryPick
+        uses: asterisk/asterisk-ci-actions/CherryPick@main
+        with:
+          repo:         ${{ github.repository }}
+          pr_number:    ${{ github.event.number }}
+          branches:     ${{ steps.getbranches.outputs.branches }}
+          push:         false
+          github_token: ${{ secrets.GITHUB_TOKEN }}
+          debug:        false
+
+  Check:
+    needs: [Setup]
+    if: ${{ needs.Setup.outputs.branch_count > 0 && ( success() ) }}
+    strategy:
+      fail-fast: false
+      matrix:
+        branch: ${{ fromJSON(needs.Setup.outputs.branches) }}
+    uses: asterisk/asterisk-ci-actions/.github/workflows/AsteriskUnitGateTest.yml@main
+    with:
+      test_type:         cherry-pick
+      asterisk_repo:     ${{ github.repository }}
+      pr_number:         ${{ github.event.number }}
+      base_branch:       ${{ matrix.branch }}
+      is_cherry_pick:    true
+      build_options:     ${{ vars.BUILD_OPTIONS }}
+      unittest_command:  ${{ vars.UNITTEST_COMMAND }}
+      testsuite_repo:    ${{ vars.TESTSUITE_REPO }}
+      testsuite_test_pr: ${{ needs.Setup.outputs.testsuite_test_pr }}
+      gatetest_list:     ${{ vars.GATETEST_LIST }}
+      gatetest_commands: ${{ vars.GATETEST_COMMANDS }}
     secrets:
       TOKEN: ${{ secrets.GITHUB_TOKEN }}
+
+  Cleanup:
+    if: ${{ success() || failure() }}
+    runs-on: ubuntu-latest
+    needs: [Setup,Check]
+    steps:
+      - name: Check status
+        env:
+          GH_TOKEN:     ${{ secrets.GITHUB_TOKEN }}
+          RESULT_UNIT:  ${{ needs.Check.result }}
+          TESTS_PASSED: ${{ vars.CHERRY_PICK_CHECKS_PASSED_LABEL }}
+          TESTS_FAILED: ${{ vars.CHERRY_PICK_CHECKS_FAILED_LABEL }}
+        run: |
+          declare -i rc=0
+          case $RESULT_UNIT in
+            success)
+              ;;
+            skipped)
+              rc+=1
+              ;;
+            *)
+              rc+=1
+          esac
+          [ $rc -gt 0 ] && label=$TESTS_FAILED || label=$TESTS_PASSED
+          gh pr edit --repo ${{ github.repository }} \
+            --remove-label ${{ vars.CHERRY_PICK_TESTING_IN_PROGRESS }} \
+            --add-label $label \
+              $PR_NUMBER || :
+          exit $rc
+
index 39766fe7e538e7205d8a7708c16d9418e99b0417..2b0dec5302f0a2332df3c0c66230f59dd8928872 100644 (file)
@@ -1,11 +1,11 @@
-name: PRMergeApproved
-run-name: "PR ${{github.event.number}} MergeApproved"
+name: MergePR
+run-name: "PR ${{ github.event.number }} MergeApproved"
 on:
   pull_request_target:
     types: [labeled]
 
 concurrency:
-  group: ${{github.workflow}}-${{github.event.label.name}}-${{github.event.number}}
+  group: ${{ github.workflow }}-${{ github.event.label.name }}-${{ github.event.number }}
   cancel-in-progress: true
 
 jobs:
@@ -14,6 +14,6 @@ jobs:
     if: contains(fromJSON(vars.MERGE_APPROVED_LABELS), github.event.label.name)
     uses: asterisk/asterisk-ci-actions/.github/workflows/AsteriskMergePR.yml@main
     secrets:
-      TOKEN: ${{ secrets.GITHUB_TOKEN }}
-      application_id: ${{secrets.ASTERISK_ORG_ACCESS_APP_ID}}
-      application_private_key: ${{secrets.ASTERISK_ORG_ACCESS_APP_PRIV_KEY}}
+      TOKEN:                   ${{ secrets.GITHUB_TOKEN }}
+      application_id:          ${{ secrets.ASTERISK_ORG_ACCESS_APP_ID }}
+      application_private_key: ${{ secrets.ASTERISK_ORG_ACCESS_APP_PRIV_KEY }}
index 3018eb532db133369632e7a737bb19f0d359ff33..899622e219cc6fc777702e6bee85041636346b5a 100644 (file)
@@ -1,18 +1,89 @@
-name: PRRecheck
-run-name: "PR ${{github.event.number}} Recheck"
+name: PRReCheck
+run-name: "PR ${{ github.event.number }} Recheck"
 on:
   pull_request_target:
     types: [ labeled ]
 
 concurrency:
-  group: ${{github.workflow}}-${{github.event.label.name}}-${{github.event.number}}
+  group: check-${{ github.event.number }}
   cancel-in-progress: true
 
+env:
+  PR_NUMBER: ${{ github.event.number }}
+
 jobs:
-  PRCheck:
-    name: PRCheck
+  Setup:
     if: ${{ github.event.label.name == vars.RECHECKPR_LABEL }}
-    uses: asterisk/asterisk-ci-actions/.github/workflows/AsteriskRecheckPR.yml@main
+    runs-on: ubuntu-latest
+    outputs:
+      testsuite_test_pr:  ${{ steps.testsuitepr.outputs.testsuite_test_pr }}
+    steps:
+      - name: Set Label
+        id: setlabel
+        env:
+          GH_TOKEN:  ${{ secrets.GITHUB_TOKEN }}
+        run: |
+          gh pr edit --repo ${{ github.repository }} \
+            --remove-label ${{ vars.RECHECKPR_LABEL }} \
+            --remove-label ${{ vars.PR_SUBMIT_TESTS_PASSED }} \
+            --remove-label  ${{ vars.PR_SUBMIT_TESTS_FAILED }} \
+            --add-label ${{ vars.PR_SUBMIT_TESTING_IN_PROGRESS }} \
+            $PR_NUMBER || :
+
+      - name: GetTestsuitePR
+        id: testsuitepr
+        uses: asterisk/asterisk-ci-actions/GetTestsuitePRFromAsteriskPR@main
+        with:
+          repo:                            ${{ github.repository }}
+          pr_number:                       ${{ github.event.number }}
+          testsuite_test_pr_regex:         ${{ vars.TESTSUITE_TEST_PR_REGEX }}
+          testsuite_test_auto_merge_regex: ${{ vars.TESTSUITE_TEST_AUTO_MERGE_REGEX }}
+          github_token:                    ${{ secrets.GITHUB_TOKEN }}
+
+  ReCheck:
+    name: ReCheck
+    needs: Setup
+    uses: asterisk/asterisk-ci-actions/.github/workflows/AsteriskUnitGateTest.yml@main
+    with:
+      test_type:         prrecheck
+      asterisk_repo:     ${{ github.repository }}
+      pr_number:         ${{ github.event.number }}
+      base_branch:       ${{ github.event.pull_request.base.ref }}
+      is_cherry_pick:    false
+      build_options:     ${{ vars.BUILD_OPTIONS }}
+      unittest_command:  ${{ vars.UNITTEST_COMMAND }}
+      testsuite_repo:    ${{ vars.TESTSUITE_REPO }}
+      testsuite_test_pr: ${{ needs.Setup.outputs.testsuite_test_pr }}
+      gatetest_list:     ${{ vars.GATETEST_LIST }}
+      gatetest_commands: ${{ vars.GATETEST_COMMANDS }}
     secrets:
       TOKEN: ${{ secrets.GITHUB_TOKEN }}
-      
\ No newline at end of file
+
+  Cleanup:
+    if: ${{ success() || failure() }}
+    runs-on: ubuntu-latest
+    needs: [Setup,ReCheck]
+    steps:
+      - name: Check status
+        env:
+          GH_TOKEN:  ${{ secrets.GITHUB_TOKEN }}
+          RESULT_UNIT: ${{ needs.ReCheck.result }}
+          TESTS_PASSED: ${{ vars.PR_SUBMIT_TESTS_PASSED }}
+          TESTS_FAILED: ${{ vars.PR_SUBMIT_TESTS_FAILED }}
+        run: |
+          declare -i rc=0
+          case $RESULT_UNIT in
+            success)
+              ;;
+            skipped)
+              rc+=1
+              ;;
+            *)
+              rc+=1
+          esac
+          [ $rc -gt 0 ] && label=$TESTS_FAILED || label=$TESTS_PASSED
+          gh pr edit --repo ${{ github.repository }} \
+            --remove-label ${{ vars.PR_SUBMIT_TESTING_IN_PROGRESS }} \
+            --add-label $label \
+              $PR_NUMBER || :
+          exit $rc
index 5eabbfb6d59d5f1de108e10e1141da71a576cf26..5b9d6bf66fc7038520791c72e8869971a779c299 100644 (file)
 # privileges needed to add and remove labels and comments.  The
 # accompanying OnPRStateChangedPriv workflow does just that.
 
-name: PRStateChanged
-run-name: "PR ${{github.event.number}} ${{github.event.action}} by ${{ github.actor }}"
+name: PRChanged
+run-name: "PR ${{ github.event.number }} ${{ github.event.action }} by ${{ github.actor }}"
 on:
   pull_request:
     types: [opened, reopened, synchronize]
 
 concurrency:
-  group: ${{github.workflow}}-${{github.event.number}}
+  group: check-${{ github.event.number }}
   cancel-in-progress: true
 
 jobs:
@@ -32,42 +32,45 @@ jobs:
       vars:  ${{ steps.setvars.outputs.control_data }}
       testsuite_test_pr:  ${{ steps.testsuitepr.outputs.testsuite_test_pr }}
     steps:
-      - id: wait
-        run: |
-          echo "::notice::Waiting for 2 minutes to give user a chance to add PR comments"
-          sleep 120
-          exit 0
-
       - id: setvars
         uses: asterisk/asterisk-ci-actions/GetRepoControlData@main
         with:
-          repo: ${{ github.event.repository.name}}
+          repo: ${{ github.event.repository.name }}
+
+      - id: wait
+        env:
+          PR_STATE_CHANGE_DELAY_SEC: ${{ fromJSON(steps.setvars.outputs.control_data).PR_STATE_CHANGE_DELAY_SEC || 120 }}
+        run: |
+          echo "Waiting for ${PR_STATE_CHANGE_DELAY_SEC} seconds to give user a chance to add PR comments"
+          sleep ${PR_STATE_CHANGE_DELAY_SEC}
+          exit 0
 
       - name: GetTestsuitePR
         id: testsuitepr
         uses: asterisk/asterisk-ci-actions/GetTestsuitePRFromAsteriskPR@main
         with:
-          repo:     ${{github.repository}}
-          pr_number: ${{github.event.number}}
-          testsuite_test_pr_regex: ${{ fromJSON(steps.setvars.outputs.control_data).TESTSUITE_TEST_PR_REGEX }}
+          repo:                            ${{ github.repository }}
+          pr_number:                       ${{ github.event.number }}
+          testsuite_test_pr_regex:         ${{ fromJSON(steps.setvars.outputs.control_data).TESTSUITE_TEST_PR_REGEX }}
           testsuite_test_auto_merge_regex: ${{ fromJSON(steps.setvars.outputs.control_data).TESTSUITE_TEST_AUTO_MERGE_REGEX }}
-          github_token: ${{ secrets.GITHUB_TOKEN }}
+          github_token:                    ${{ secrets.GITHUB_TOKEN }}
 
       - name: DumpEnvironment
+        if: ${{ fromJSON(steps.setvars.outputs.control_data).RUN_DUMP_ENV }}
         uses: asterisk/asterisk-ci-actions/DumpEnvironmentAction@main
         with:
           action-vars: ${{ toJSON(steps.setvars.outputs) }}
           action-inputs: ${{ toJSON(steps.testsuitepr.outputs) }}
 
-  PRCheck:
-    name: PRCheck
+  Check:
+    name: Check
     needs: Setup
     uses: asterisk/asterisk-ci-actions/.github/workflows/AsteriskUnitGateTest.yml@main
     with:
       test_type:         prstatechange
-      asterisk_repo:     ${{github.repository}}
-      pr_number:         ${{github.event.number}}
-      base_branch:       ${{github.event.pull_request.base.ref}}
+      asterisk_repo:     ${{ github.repository }}
+      pr_number:         ${{ github.event.number }}
+      base_branch:       ${{ github.event.pull_request.base.ref }}
       build_options:     ${{ fromJSON(needs.Setup.outputs.vars).BUILD_OPTIONS }}
       unittest_command:  ${{ fromJSON(needs.Setup.outputs.vars).UNITTEST_COMMAND }}
       testsuite_repo:    ${{ fromJSON(needs.Setup.outputs.vars).TESTSUITE_REPO }}
index 1dfb4822191b008fbe1c0811a2443f819f1367f6..96f3b42385bcc028f20f5c5aa10fe804d651b5eb 100644 (file)
 # add and remove labels and comments. Hence the "Priv" at the end
 # of this workflow name.
 #
-name: PRStateChangedPriv
-run-name: "PRStateChangedPriv ${{github.event.workflow.name}} ${{github.event.action}}"
+name: PRChangedPriv
+run-name: "PRChangedPriv ${{ github.event.workflow.name }} ${{ github.event.action }}"
 on:
   workflow_run:
-    workflows: [PRStateChanged]
+    workflows: [PRChanged]
     types:
       - requested
       - completed
 
 jobs:
-  PRStateChangedPriv:
-    name: PRStateChangedPriv
+  PRChangedPriv:
+    name: PRChangedPriv
     uses: asterisk/asterisk-ci-actions/.github/workflows/AsteriskPRStateChangedPriv.yml@main
     secrets:
       TOKEN: ${{ secrets.GITHUB_TOKEN }}