diff --git a/.github/workflows/CherryPickTest.yml b/.github/workflows/CherryPickTest.yml deleted file mode 100644 index 59604194d0..0000000000 --- a/.github/workflows/CherryPickTest.yml +++ /dev/null @@ -1,167 +0,0 @@ -name: CherryPickTest -run-name: "Cherry-Pick Tests for PR ${{github.event.number}}" -on: - pull_request_target: - types: [ labeled ] - -concurrency: - group: ${{github.workflow}}-${{github.event.number}} - cancel-in-progress: true - -env: - 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 }} - 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}} \ - --remove-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}} - - - 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}} || : - - CherryPickUnitTestMatrix: - needs: [ IdentifyBranches ] - if: ${{ needs.IdentifyBranches.outputs.branch_count > 0 && ( success() || failure() ) }} - 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}} - - CherryPickUnitTests: - needs: [ IdentifyBranches, CherryPickUnitTestMatrix ] - if: ${{ needs.IdentifyBranches.outputs.branch_count > 0 && ( success() || failure() ) }} - runs-on: ubuntu-latest - steps: - - name: Check unit test matrix status - env: - RESULT: ${{needs.CherryPickUnitTestMatrix.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 - - CherryPickGateTestMatrix: - needs: [ IdentifyBranches, CherryPickUnitTests ] - 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_command: ${{ toJSON(fromJSON(vars.GATETEST_COMMANDS)[matrix.group]) }} - - CherryPickGateTests: - needs: [ IdentifyBranches, CherryPickGateTestMatrix ] - if: ${{ success() || failure() }} - runs-on: ubuntu-latest - steps: - - name: Check test matrix status - env: - RESULT: ${{needs.CherryPickGateTestMatrix.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 diff --git a/.github/workflows/MergeApproved.yml b/.github/workflows/MergeApproved.yml deleted file mode 100644 index 1d1984e9d5..0000000000 --- a/.github/workflows/MergeApproved.yml +++ /dev/null @@ -1,187 +0,0 @@ -name: MergeApproved -run-name: "Merge Approved for PR ${{github.event.number}}" -on: - pull_request_target: - types: [labeled] - -env: - PR_NUMBER: ${{ github.event.number }} - BASE_BRANCH: ${{github.event.pull_request.base.ref}} - MODULES_BLACKLIST: ${{ vars.GATETEST_MODULES_BLACKLIST }} ${{ vars.UNITTEST_MODULES_BLACKLIST }} - FORCE: ${{ endsWith(github.event.label.name, '-force') }} - -jobs: - IdentifyBranches: - if: contains(fromJSON(vars.MERGE_APPROVED_LABELS), github.event.label.name) - outputs: - branches: ${{ steps.getbranches.outputs.branches }} - all_branches: ${{ steps.checkbranches.outputs.all_branches }} - branch_count: ${{ steps.getbranches.outputs.branch_count }} - runs-on: ubuntu-latest - steps: - - name: Clean up labels - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - gh pr edit --repo ${{github.repository}} \ - --remove-label ${{github.event.label.name}} \ - --remove-label ${{vars.PRE_MERGE_CHECKS_PASSED_LABEL}} \ - --remove-label ${{vars.PRE_MERGE_CHECKS_FAILED_LABEL}} \ - --remove-label ${{vars.PRE_MERGE_GATES_PASSED_LABEL}} \ - --remove-label ${{vars.PRE_MERGE_GATES_FAILED_LABEL}} \ - --remove-label ${{vars.PRE_MERGE_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}} - - - name: Check Branch Count - id: checkbranches - env: - BRANCH_COUNT: ${{ steps.getbranches.outputs.branch_count }} - BRANCHES: ${{ steps.getbranches.outputs.branches }} - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - gh pr edit --repo ${{github.repository}} \ - --add-label ${{vars.PRE_MERGE_TESTING_IN_PROGRESS}} \ - ${{env.PR_NUMBER}} || : - all_branches=$(echo "$BRANCHES" | jq -c "[ \"$BASE_BRANCH\" ] + .") - echo "all_branches=${all_branches}" >>${GITHUB_OUTPUT} - - - name: Pre Check Cherry-Picks - if: ${{ steps.getbranches.outputs.branch_count > 0 }} - uses: asterisk/asterisk-ci-actions/CherryPick@main - with: - repo: ${{github.repository}} - pr_number: ${{env.PR_NUMBER}} - branches: ${{steps.getbranches.outputs.branches}} - github_token: ${{secrets.GITHUB_TOKEN}} - push: false - - PreMergeUnitTestMatrix: - needs: [ IdentifyBranches ] - if: success() - continue-on-error: false - strategy: - fail-fast: false - matrix: - branch: ${{ fromJSON(needs.IdentifyBranches.outputs.all_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}} - - PreMergeUnitTests: - needs: [ IdentifyBranches, PreMergeUnitTestMatrix ] - runs-on: ubuntu-latest - steps: - - name: Check unit test matrix status - env: - RESULT: ${{needs.PreMergeUnitTestMatrix.result}} - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - case $RESULT in - success) - gh pr edit --repo ${{github.repository}} \ - --remove-label ${{vars.PRE_MERGE_TESTING_IN_PROGRESS}} \ - --add-label ${{vars.PRE_MERGE_CHECKS_PASSED_LABEL}} \ - ${{env.PR_NUMBER}} || : - echo "::notice::All tests passed" - exit 0 - ;; - skipped) - gh pr edit --repo ${{github.repository}} \ - --remove-label ${{vars.PRE_MERGE_TESTING_IN_PROGRESS}} \ - --add-label ${{vars.PRE_MERGE_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.PRE_MERGE_TESTING_IN_PROGRESS}} \ - --add-label ${{vars.PRE_MERGE_CHECKS_FAILED_LABEL}} \ - ${{env.PR_NUMBER}} || : - echo "::error::One or more tests failed ($RESULT)" - exit 1 - esac - - MergeAndCherryPick: - needs: [ IdentifyBranches, PreMergeUnitTests ] - if: success() - runs-on: ubuntu-latest - steps: - - name: Start Merge - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - gh pr edit --repo ${{github.repository}} \ - --add-label ${{vars.MERGE_IN_PROGRESS_LABEL}} \ - ${{env.PR_NUMBER}} || : - - - name: Get Token needed to push cherry-picks - id: get_workflow_token - uses: peter-murray/workflow-application-token-action@v2 - with: - application_id: ${{secrets.ASTERISK_ORG_ACCESS_APP_ID}} - application_private_key: ${{secrets.ASTERISK_ORG_ACCESS_APP_PRIV_KEY}} - organization: asterisk - - - name: Merge and Cherry Pick to ${{needs.IdentifyBranches.outputs.branches}} - id: mergecp - uses: asterisk/asterisk-ci-actions/MergeAndCherryPickComposite@main - with: - repo: ${{github.repository}} - pr_number: ${{env.PR_NUMBER}} - branches: ${{needs.IdentifyBranches.outputs.branches}} - force: ${{env.FORCE}} - github_token: ${{steps.get_workflow_token.outputs.token}} - - - name: Merge Cleanup - if: always() - env: - RESULT: ${{ steps.mergecp.outcome }} - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - BRANCH_COUNT: ${{ needs.IdentifyBranches.outputs.branch_count }} - BRANCHES: ${{ needs.IdentifyBranches.outputs.branches }} - - run: | - case $RESULT in - success) - gh pr edit --repo ${{github.repository}} \ - --remove-label ${{vars.MERGE_IN_PROGRESS_LABEL}} \ - ${{env.PR_NUMBER}} || : - if [ $BRANCH_COUNT -eq 0 ] ; then - gh pr comment --repo ${{github.repository}} \ - -b "Successfully merged to branch $BASE_BRANCH." \ - ${{env.PR_NUMBER}} || : - else - gh pr comment --repo ${{github.repository}} \ - -b "Successfully merged to branch $BASE_BRANCH and cherry-picked to $BRANCHES" \ - ${{env.PR_NUMBER}} || : - fi - exit 0 - ;; - failure) - gh pr edit --repo ${{github.repository}} \ - --remove-label ${{vars.MERGE_IN_PROGRESS_LABEL}} \ - --add-label ${{vars.MERGE_FAILED_LABEL}} \ - ${{env.PR_NUMBER}} || : - exit 1 - ;; - *) - esac diff --git a/.github/workflows/OnPRCherryPickTest.yml b/.github/workflows/OnPRCherryPickTest.yml new file mode 100644 index 0000000000..e67070119f --- /dev/null +++ b/.github/workflows/OnPRCherryPickTest.yml @@ -0,0 +1,17 @@ +name: PRCherryPickTest +run-name: "PR ${{github.event.number}} CherryPickTest" +on: + pull_request_target: + types: [ labeled ] + +concurrency: + group: ${{github.workflow}}-${{github.event.label.name}}-${{github.event.number}} + cancel-in-progress: true + +jobs: + CherryPickTest: + name: CherryPickTest + if: ${{ github.event.label.name == vars.CHERRY_PICK_TEST_LABEL }} + uses: asterisk/asterisk-ci-actions/.github/workflows/AsteriskCherryPickTest.yml@main + secrets: + TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/OnPRMergeApproved.yml b/.github/workflows/OnPRMergeApproved.yml new file mode 100644 index 0000000000..6c55e0d154 --- /dev/null +++ b/.github/workflows/OnPRMergeApproved.yml @@ -0,0 +1,17 @@ +name: PRMergeApproved +run-name: "PR ${{github.event.number}} MergeApproved" +on: + pull_request_target: + types: [labeled] + +concurrency: + group: ${{github.workflow}}-${{github.event.label.name}}-${{github.event.number}} + cancel-in-progress: true + +jobs: + MergePR: + name: MergePR + 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 }} diff --git a/.github/workflows/OnPRRecheck.yml b/.github/workflows/OnPRRecheck.yml new file mode 100644 index 0000000000..3018eb532d --- /dev/null +++ b/.github/workflows/OnPRRecheck.yml @@ -0,0 +1,18 @@ +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}} + cancel-in-progress: true + +jobs: + PRCheck: + name: PRCheck + if: ${{ github.event.label.name == vars.RECHECKPR_LABEL }} + uses: asterisk/asterisk-ci-actions/.github/workflows/AsteriskRecheckPR.yml@main + secrets: + TOKEN: ${{ secrets.GITHUB_TOKEN }} + \ No newline at end of file diff --git a/.github/workflows/OnPRStateChanged.yml b/.github/workflows/OnPRStateChanged.yml new file mode 100644 index 0000000000..e057ab2798 --- /dev/null +++ b/.github/workflows/OnPRStateChanged.yml @@ -0,0 +1,59 @@ +# +# Workflows, like this one, that are triggered by PRs submitted +# from forked repositories are severly limited in what they can do +# for security reasons. For instance, they can't add or remove +# labels or comments even on the PR that triggered them. Since +# we need to both of those things, GitHub recommends creating a +# separate workflow that does those tasks that's triggered when +# this PR workflow starts or finishes. Since that workflow isn't +# being run in the context of a forked repo, it has all the +# 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 }}" +on: + pull_request: + types: [opened, reopened, synchronize] + +concurrency: + group: ${{github.workflow}}-${{github.event.number}} + cancel-in-progress: true + +jobs: +# +# Pull requests created from forked respositories don't have access +# to the "Action Variables" ('vars' context) so we need to retrieve +# control data from an action that's located in asterisk-ci-actions. +# + Setup: + runs-on: ubuntu-latest + outputs: + vars: ${{ steps.setvars.outputs.control_data }} + steps: + - id: setvars + uses: asterisk/asterisk-ci-actions/GetRepoControlData@main + with: + repo: ${{ github.event.repository.name}} + - name: DumpEnvironment + uses: asterisk/asterisk-ci-actions/DumpEnvironmentAction@main + with: + action-vars: ${{ toJSON(steps.setvars.outputs) }} + + PRCheck: + name: PRCheck + 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}} + 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 }} + gatetest_list: ${{ fromJSON(needs.Setup.outputs.vars).GATETEST_LIST }} + gatetest_commands: ${{ fromJSON(needs.Setup.outputs.vars).GATETEST_COMMANDS }} + secrets: + TOKEN: ${{ secrets.GITHUB_TOKEN }} + diff --git a/.github/workflows/OnPRStateChangedPriv.yml b/.github/workflows/OnPRStateChangedPriv.yml new file mode 100644 index 0000000000..1dfb482219 --- /dev/null +++ b/.github/workflows/OnPRStateChangedPriv.yml @@ -0,0 +1,27 @@ +# +# Workflows triggered by PRs submitted from forked repositories +# (all of ours) are severly limited in what they can do. +# For instance, they can't add or remove labels or comments even +# on the PR that triggered them. Since we need to both of those, +# GitHub recommends creating a separate workflow (this one) that +# does those tasks that's triggered when the PR submit workflow +# starts or finishes. Since this workflow isn't being run in the +# context of a forked repo, it has all the privileges needed to +# 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}}" +on: + workflow_run: + workflows: [PRStateChanged] + types: + - requested + - completed + +jobs: + PRStateChangedPriv: + name: PRStateChangedPriv + uses: asterisk/asterisk-ci-actions/.github/workflows/AsteriskPRStateChangedPriv.yml@main + secrets: + TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/PRMerged.yml b/.github/workflows/PRMerged.yml deleted file mode 100644 index 774736a3bf..0000000000 --- a/.github/workflows/PRMerged.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: PRMerged -run-name: "PR ${{github.event.number || inputs.pr_number}} ${{github.event.action || 'MANUAL POST MERGE'}} by ${{ github.actor }}" -on: - pull_request_target: - types: [closed] - 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: - REPO: ${{github.repository}} - PR_NUMBER: ${{github.event.number || inputs.pr_number}} - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} - -jobs: - CloseIssues: - if: github.event.pull_request.merged == true - runs-on: ubuntu-latest - steps: - - uses: wow-actions/auto-close-fixed-issues@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - diff --git a/.github/workflows/PRSubmitActions.yml b/.github/workflows/PRSubmitActions.yml deleted file mode 100644 index c7706d5609..0000000000 --- a/.github/workflows/PRSubmitActions.yml +++ /dev/null @@ -1,149 +0,0 @@ -name: PRSubmitActions -run-name: "PRSubmitActions: Test ${{github.event.action}}" -on: - workflow_run: - workflows: [PRSubmitTests] - types: - - requested - - completed -env: - ACTION: ${{ github.event.action }} - CONCLUSION: ${{ github.event.workflow_run.conclusion }} - REPO: ${{ github.repository }} - -jobs: - PRSubmitActions: - runs-on: ubuntu-latest - steps: - - name: Get PR Number - id: getpr - uses: actions/github-script@v7 - with: - retries: 5 - script: | - let search = `repo:${context.repo.owner}/${context.repo.repo} ${context.payload.workflow_run.head_sha}`; - let prs = await github.rest.search.issuesAndPullRequests({ - q: search, - }); - if (prs.data.total_count == 0) { - core.setFailed(`Unable to get PR for ${context.payload.workflow_run.head_sha}`); - return; - } - let pr_number = prs.data.items[0].number; - core.setOutput('pr_number', pr_number); - return; - - - name: Set Label - id: setlabel - uses: actions/github-script@v7 - env: - PR_NUMBER: ${{ steps.getpr.outputs.PR_NUMBER }} - LABEL_TIP: ${{ vars.PR_SUBMIT_TESTING_IN_PROGRESS }} - LABEL_PASS: ${{ vars.PR_SUBMIT_TESTS_PASSED }} - LABEL_FAIL: ${{ vars.PR_SUBMIT_TESTS_FAILED }} - with: - retries: 5 - script: | - let label; - if (process.env.ACTION === 'requested') { - label = process.env.LABEL_TIP; - } else { - if ( process.env.CONCLUSION === 'success' ) { - label = process.env.LABEL_PASS; - } else { - label = process.env.LABEL_FAIL; - } - } - core.info(`Setting label ${label}`); - github.rest.issues.setLabels({ - issue_number: process.env.PR_NUMBER, - owner: context.repo.owner, - repo: context.repo.repo, - labels: [ label ] - }); - return; - - - name: Get cherry-pick branches - if: github.event.action == 'completed' - id: getbranches - uses: asterisk/asterisk-ci-actions/GetCherryPickBranchesFromPR@main - with: - repo: ${{env.REPO}} - pr_number: ${{steps.getpr.outputs.PR_NUMBER}} - cherry_pick_regex: ${{vars.CHERRY_PICK_REGEX}} - github_token: ${{secrets.GITHUB_TOKEN}} - - - name: Add cherry-pick reminder - if: github.event.action == 'completed' - uses: actions/github-script@v7 - env: - PR_NUMBER: ${{steps.getpr.outputs.PR_NUMBER}} - CHERRY_PICK_REMINDER: ${{vars.CHERRY_PICK_REMINDER}} - BRANCHES_OUTPUT: ${{toJSON(steps.getbranches.outputs)}} - BRANCH_COUNT: ${{steps.getbranches.outputs.branch_count}} - FORCED_NONE: ${{steps.getbranches.outputs.forced_none}} - with: - retries: 5 - script: | - if (process.env.FORCED_NONE === 'true' || - process.env.BRANCH_COUNT > 0) { - core.info("No cherry-pick reminder needed."); - return; - } - let comments = await github.rest.issues.listComments({ - issue_number: process.env.PR_NUMBER, - owner: context.repo.owner, - repo: context.repo.repo, - }); - let found = false; - for (const c of comments.data) { - if (c.body.startsWith("")) { - found = true; - break; - } - } - if (found) { - core.info("Cherry-pick reminder already exists."); - return; - } - core.info("Adding cherry-pick reminder."); - await github.rest.issues.createComment({ - issue_number: process.env.PR_NUMBER, - owner: context.repo.owner, - repo: context.repo.repo, - body: process.env.CHERRY_PICK_REMINDER - }) - return; - - - name: Add reviewers - if: github.event.action == 'completed' - uses: actions/github-script@v7 - env: - PR_NUMBER: ${{steps.getpr.outputs.PR_NUMBER}} - REVIEWERS: ${{vars.PR_REVIEWERS}} - with: - retries: 5 - github-token: ${{ secrets.ASTERISKTEAM_PAT }} - script: | - let rs = JSON.parse(process.env.REVIEWERS.length ? process.env.REVIEWERS : '[]'); - let users = []; - let teams = []; - for (const r of rs) { - if (r.indexOf("/") > 0) { - teams.push(r.split('/')[1]); - } else { - users.push(r); - } - } - if (teams.length > 0 || users.length > 0) { - core.info(`Adding user reviewers ${users}`); - core.info(`Adding team reviewers ${teams}`); - await github.rest.pulls.requestReviewers({ - pull_number: process.env.PR_NUMBER, - owner: context.repo.owner, - repo: context.repo.repo, - reviewers: users, - team_reviewers: teams - }); - } - return; diff --git a/.github/workflows/PRSubmitTests.yml b/.github/workflows/PRSubmitTests.yml deleted file mode 100644 index 1048192266..0000000000 --- a/.github/workflows/PRSubmitTests.yml +++ /dev/null @@ -1,114 +0,0 @@ -name: PRSubmitTests -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}} - cancel-in-progress: true - -env: - ASTERISK_REPO: ${{github.repository}} - PR_NUMBER: ${{github.event.number}} - PR_COMMIT: ${{github.event.pull_request.head.sha}} - BRANCH: ${{github.event.pull_request.base.ref}} - -jobs: -# -# Pull requests created from forked respositories don't have access to -# the "Action Variables" ('vars' context) so we need to retrieve control -# data from an action. -# - PRSGetControlData: - runs-on: ubuntu-latest - outputs: - control_data: ${{ steps.setvars.outputs.control_data }} - steps: - - id: setvars - uses: asterisk/asterisk-ci-actions/GetRepoControlData@main - with: - repo: ${{ github.event.repository.name}} - - name: DumpEnvironment - uses: asterisk/asterisk-ci-actions/DumpEnvironmentAction@main - with: - action-inputs: ${{toJSON(inputs)}} - action-vars: ${{ toJSON(steps.setvars.outputs) }} - - PRSUnitTests: - needs: PRSGetControlData - runs-on: ubuntu-latest - env: - UNITTEST_COMMAND: ${{ fromJSON(needs.PRSGetControlData.outputs.control_data).UNITTEST_COMMAND }} - steps: - - name: Run Unit Tests - uses: asterisk/asterisk-ci-actions/AsteriskUnitComposite@main - with: - asterisk_repo: ${{env.ASTERISK_REPO}} - pr_number: ${{env.PR_NUMBER}} - base_branch: ${{env.BRANCH}} - unittest_command: ${{env.UNITTEST_COMMAND}} - - PRSGateTestMatrix: - runs-on: ubuntu-latest - needs: PRSGetControlData - continue-on-error: false - strategy: - fail-fast: false - matrix: - group: ${{ fromJSON(fromJSON(needs.PRSGetControlData.outputs.control_data).GATETEST_LIST) }} - env: - TESTSUITE_REPO: "${{ fromJSON(needs.PRSGetControlData.outputs.control_data).TESTSUITE_REPO }}" - GATETEST_COMMANDS: "${{ fromJSON(needs.PRSGetControlData.outputs.control_data).GATETEST_COMMANDS }}" - GATETEST_COMMAND: "${{ toJSON(fromJSON(fromJSON(needs.PRSGetControlData.outputs.control_data).GATETEST_COMMANDS)[matrix.group]) }}" - steps: - - id: runtest - name: Run Gate Tests for ${{ matrix.group }} - uses: asterisk/asterisk-ci-actions/AsteriskGateComposite@main - with: - test_type: Gate - asterisk_repo: ${{env.ASTERISK_REPO}} - pr_number: ${{env.PR_NUMBER}} - base_branch: ${{env.BRANCH}} - testsuite_repo: ${{env.TESTSUITE_REPO}} - gatetest_group: ${{matrix.group}} - gatetest_command: ${{env.GATETEST_COMMAND}} - - PRSTestResults: - if: always() - runs-on: ubuntu-latest - needs: [PRSUnitTests,PRSGateTestMatrix] - steps: - - name: Check test matrix status - env: - RESULT_UNIT: ${{ needs.PRSUnitTests.result }} - RESULT_GATE: ${{ needs.PRSGateTestMatrix.result }} - run: | - declare -i rc=0 - echo "all results: ${{ toJSON(needs.*.result) }}" - case $RESULT_UNIT in - success) - echo "::notice::Unit tests passed" - ;; - skipped) - echo "::error::Unit tests were skipped because of an earlier failure" - rc+=1 - ;; - *) - echo "::error::One or more unit tests failed ($RESULT_UNIT)" - rc+=1 - esac - case $RESULT_GATE in - success) - echo "::notice::Gate tests passed" - ;; - skipped) - echo "::error::Gate tests were skipped because of an earlier failure" - rc+=1 - ;; - *) - echo "::error::One or more gate tests failed ($RESULT_GATE)" - rc+=1 - esac - echo "::notice::Final result code: $rc" - exit $rc