mirror of
				https://github.com/asterisk/asterisk.git
				synced 2025-10-31 10:47:18 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			165 lines
		
	
	
		
			6.1 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
			
		
		
	
	
			165 lines
		
	
	
		
			6.1 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
| name: CherryPickTest
 | |
| run-name: "Cherry-Pick Tests for PR ${{github.event.number || inputs.pr_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 }}
 | |
|   cancel-in-progress: true
 | |
| 
 | |
| env:
 | |
|   PR_NUMBER:          ${{ github.event.number || inputs.pr_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}}
 | |
|     outputs:
 | |
|       branches:     ${{ steps.getbranches.outputs.branches }}
 | |
|       branch_count: ${{ steps.getbranches.outputs.branch_count }}
 | |
|     runs-on: ubuntu-latest
 | |
|     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_GATES_PASSED_LABEL}} \
 | |
|             --remove-label ${{vars.CHERRY_PICK_GATES_FAILED_LABEL}} \
 | |
|             --add-label ${{vars.CHERRY_PICK_TESTING_IN_PROGRESS}} \
 | |
|             ${{env.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}}
 | |
| 
 | |
|   AsteriskUnitTestMatrix:
 | |
|     needs: [ IdentifyBranches ]
 | |
|     if: needs.IdentifyBranches.outputs.branch_count > 0
 | |
|     continue-on-error: false
 | |
|     strategy:
 | |
|       fail-fast: false
 | |
|       matrix:
 | |
|         branch: ${{ fromJSON(needs.IdentifyBranches.outputs.branches) }}
 | |
|     runs-on: ubuntu-latest
 | |
|     steps:
 | |
|       - name: Run Unit Tests for branch ${{matrix.branch}}
 | |
|         uses: asterisk/asterisk-ci-actions/AsteriskUnitComposite@main
 | |
|         with:
 | |
|           asterisk_repo:     ${{github.repository}}
 | |
|           pr_number:         ${{env.PR_NUMBER}}
 | |
|           base_branch:       ${{matrix.branch}}
 | |
|           is_cherry_pick:    true
 | |
|           modules_blacklist: ${{env.MODULES_BLACKLIST}}
 | |
|           github_token:      ${{secrets.GITHUB_TOKEN}}
 | |
|           unittest_command:  ${{vars.UNITTEST_COMMAND}}
 | |
| 
 | |
|   AsteriskUnitTests:
 | |
|     if: ${{ always() }}
 | |
|     runs-on: ubuntu-latest
 | |
|     needs: [ AsteriskUnitTestMatrix ] 
 | |
|     steps:
 | |
|       - name: Check unit test matrix status
 | |
|         env:
 | |
|           RESULT:    ${{needs.AsteriskUnitTestMatrix.result}}
 | |
|           GH_TOKEN:  ${{ secrets.GITHUB_TOKEN }}
 | |
|         run: |
 | |
|           case $RESULT in
 | |
|             success)
 | |
|               gh pr edit --repo ${{github.repository}} \
 | |
|                 --add-label ${{vars.CHERRY_PICK_CHECKS_PASSED_LABEL}} \
 | |
|                 ${{env.PR_NUMBER}} || :
 | |
|               echo "::notice::All tests passed"
 | |
|               exit 0
 | |
|               ;;
 | |
|             skipped)
 | |
|               gh pr edit --repo ${{github.repository}} \
 | |
|                 --remove-label ${{vars.CHERRY_PICK_TESTING_IN_PROGRESS}} \
 | |
|                 --add-label ${{vars.CHERRY_PICK_CHECKS_FAILED_LABEL}} \
 | |
|                 ${{env.PR_NUMBER}} || :
 | |
|               echo "::notice::Unit tests were skipped because of an earlier failure"
 | |
|               exit 1
 | |
|               ;;
 | |
|             *)
 | |
|               gh pr edit --repo ${{github.repository}} \
 | |
|                 --remove-label ${{vars.CHERRY_PICK_TESTING_IN_PROGRESS}} \
 | |
|                 --add-label ${{vars.CHERRY_PICK_CHECKS_FAILED_LABEL}} \
 | |
|                 ${{env.PR_NUMBER}} || :
 | |
|               echo "::error::One or more tests failed ($RESULT)"
 | |
|               exit 1
 | |
|           esac
 | |
| 
 | |
|   AsteriskGateTestMatrix:
 | |
|     needs: [ IdentifyBranches, AsteriskUnitTests ]
 | |
|     if: ${{ success() }}
 | |
|     continue-on-error: false
 | |
|     strategy:
 | |
|       fail-fast: false
 | |
|       matrix:
 | |
|         branch: ${{ fromJSON(needs.IdentifyBranches.outputs.branches) }}
 | |
|         group: ${{ fromJSON(vars.GATETEST_LIST) }}
 | |
|     runs-on: ubuntu-latest
 | |
|     steps:
 | |
|       - name: Run Gate Tests for ${{ matrix.group }}-${{matrix.branch}}
 | |
|         uses: asterisk/asterisk-ci-actions/AsteriskGateComposite@main
 | |
|         with:
 | |
|           test_type:         Gate
 | |
|           asterisk_repo:     ${{github.repository}}
 | |
|           pr_number:         ${{env.PR_NUMBER}}
 | |
|           base_branch:       ${{matrix.branch}}
 | |
|           is_cherry_pick:    true
 | |
|           modules_blacklist: ${{env.MODULES_BLACKLIST}}
 | |
|           github_token:      ${{secrets.GITHUB_TOKEN}}
 | |
|           testsuite_repo:    ${{vars.TESTSUITE_REPO}}
 | |
|           gatetest_group:    ${{matrix.group}}
 | |
|           gatetest_commands: ${{vars.GATETEST_COMMANDS}}
 | |
| 
 | |
|   AsteriskGateTests:
 | |
|     if: ${{ always() }}
 | |
|     runs-on: ubuntu-latest
 | |
|     needs: AsteriskGateTestMatrix
 | |
|     steps:
 | |
|       - name: Check test matrix status
 | |
|         env:
 | |
|           RESULT:    ${{needs.AsteriskGateTestMatrix.result}}
 | |
|           GH_TOKEN:  ${{ secrets.GITHUB_TOKEN }}
 | |
|         run: |
 | |
|           gh pr edit --repo ${{github.repository}} \
 | |
|             --remove-label ${{vars.CHERRY_PICK_TESTING_IN_PROGRESS}} \
 | |
|             ${{env.PR_NUMBER}} || :
 | |
|           case $RESULT in
 | |
|             success)
 | |
|               gh pr edit --repo ${{github.repository}} \
 | |
|                 --add-label ${{vars.CHERRY_PICK_GATES_PASSED_LABEL}} \
 | |
|                 ${{env.PR_NUMBER}} || :
 | |
|               echo "::notice::All Testsuite tests passed"
 | |
|               exit 0
 | |
|               ;;
 | |
|             skipped)
 | |
|               echo "::error::Testsuite tests were skipped because of an earlier failure"
 | |
|               exit 1
 | |
|               ;;
 | |
|             *)
 | |
|               gh pr edit --repo ${{github.repository}} \
 | |
|                 --add-label ${{vars.CHERRY_PICK_GATES_FAILED_LABEL}} \
 | |
|                 ${{env.PR_NUMBER}} || :
 | |
|               echo "::error::One or more Testsuite tests failed ($RESULT)"
 | |
|               exit 1
 | |
|           esac
 |