From 987315a5faa95354ff2d2069898e08ed43ee1d0b Mon Sep 17 00:00:00 2001 From: George Joseph Date: Fri, 28 Apr 2023 12:31:03 -0600 Subject: [PATCH] Initial GitHub PRs --- .github/workflows/CherryPickTest.yml | 137 ++++++++++++++++++++++++ .github/workflows/NightlyAdmin.yml | 47 ++++++++ .github/workflows/NightlyTests.yml | 59 ++++++++++ .github/workflows/PRMerged.yml | 69 ++++++++++++ .github/workflows/PROpenedOrUpdated.yml | 104 ++++++++++++++++++ 5 files changed, 416 insertions(+) create mode 100644 .github/workflows/CherryPickTest.yml create mode 100644 .github/workflows/NightlyAdmin.yml create mode 100644 .github/workflows/NightlyTests.yml create mode 100644 .github/workflows/PRMerged.yml create mode 100644 .github/workflows/PROpenedOrUpdated.yml diff --git a/.github/workflows/CherryPickTest.yml b/.github/workflows/CherryPickTest.yml new file mode 100644 index 0000000000..60a647b243 --- /dev/null +++ b/.github/workflows/CherryPickTest.yml @@ -0,0 +1,137 @@ +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 + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh pr edit --repo ${{github.repository}} \ + --remove-label ${{vars.CHERRY_PICK_TEST_LABEL}} ${{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_test_label: ${{vars.CHERRY_PICK_TEST_LABEL}} + 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}} + run: | + case $RESULT in + success) + echo "::notice::All tests passed" + exit 0 + ;; + skipped) + echo "::notice::Unit tests were skipped because of an earlier failure" + exit 1 + ;; + *) + 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}} + run: | + case $RESULT in + success) + echo "::notice::All Testsuite tests passed" + exit 0 + ;; + skipped) + echo "::error::Testsuite tests were skipped because of an earlier failure" + exit 1 + ;; + *) + echo "::error::One or more Testsuite tests failed ($RESULT)" + exit 1 + esac diff --git a/.github/workflows/NightlyAdmin.yml b/.github/workflows/NightlyAdmin.yml new file mode 100644 index 0000000000..dd7f6bad2d --- /dev/null +++ b/.github/workflows/NightlyAdmin.yml @@ -0,0 +1,47 @@ +name: Nightly Admin +on: + schedule: + - cron: '30 1 * * *' + +env: + ASTERISK_REPO: ${{ github.repository }} + PR_NUMBER: 0 + PR_COMMIT: '' + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + MODULES_BLACKLIST: ${{ vars.GATETEST_MODULES_BLACKLIST }} ${{ vars.UNITTEST_MODULES_BLACKLIST }} + +jobs: + CloseStaleIssues: + runs-on: ubuntu-latest + steps: + - name: Close Stale Issues + uses: actions/stale@v7 + with: + stale-issue-message: 'This issue is stale because it has been open 7 days with no activity. Remove stale label or comment or this will be closed in 14 days.' + close-issue-message: 'This issue was closed because it has been stalled for 14 days with no activity.' + days-before-stale: 7 + days-before-close: 14 + days-before-pr-close: -1 + only-label: triage,feedback-required + + PublishWikiDocs: + if: ${{fromJSON(vars.WIKIDOCS_ENABLE) == true}} + strategy: + fail-fast: false + matrix: + branch: ${{ fromJSON(vars.WIKIDOC_BRANCHES) }} + runs-on: ubuntu-latest + steps: + - name: PublishWikiDocs + uses: asterisk/asterisk-ci-actions/AsteriskPublishDocsComposite@main + with: + asterisk_repo: ${{env.ASTERISK_REPO}} + base_branch: ${{matrix.branch}} + modules_blacklist: ${{env.MODULES_BLACKLIST}} + github_token: ${{secrets.GITHUB_TOKEN}} + publish_docs_repo: ${{vars.PUBLISH_DOCS_REPO}} + publish_docs_branch: ${{vars.PUBLISH_DOCS_BRANCH}} + confluence_url: ${{vars.CONFLUENCE_URL}} + confluence_userpass: ${{secrets.CONFLUENCE_USERPASS}} + confluence_space: ${{vars.CONFLUENCE_SPACE}} diff --git a/.github/workflows/NightlyTests.yml b/.github/workflows/NightlyTests.yml new file mode 100644 index 0000000000..7eb3e163b7 --- /dev/null +++ b/.github/workflows/NightlyTests.yml @@ -0,0 +1,59 @@ +name: NightlyTests +on: + workflow_dispatch: + + schedule: + - cron: '0 2 * * *' + +env: + ASTERISK_REPO: ${{ github.repository }} + PR_NUMBER: 0 + PR_COMMIT: '' + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + MODULES_BLACKLIST: ${{ vars.GATETEST_MODULES_BLACKLIST }} + +jobs: + AsteriskNightly: + strategy: + fail-fast: false + matrix: + branch: ${{ fromJSON(vars.NIGHTLYTEST_BRANCHES) }} + group: ${{ fromJSON(vars.NIGHTLYTEST_LIST) }} + runs-on: ubuntu-latest + steps: + - name: Run Nightly Tests for ${{ matrix.group }}/${{ matrix.branch }} + uses: asterisk/asterisk-ci-actions/AsteriskGateComposite@main + with: + test_type: Nightly + asterisk_repo: ${{env.ASTERISK_REPO}} + pr_number: ${{env.PR_NUMBER}} + base_branch: ${{matrix.branch}} + modules_blacklist: ${{env.MODULES_BLACKLIST}} + github_token: ${{secrets.GITHUB_TOKEN}} + testsuite_repo: ${{vars.TESTSUITE_REPO}} + gatetest_group: ${{matrix.group}} + gatetest_commands: ${{vars.GATETEST_COMMANDS}} + + AsteriskNightlyTests: + if: ${{ always() }} + runs-on: ubuntu-latest + needs: AsteriskNightly + steps: + - name: Check test matrix status + env: + RESULT: ${{needs.AsteriskNightly.result}} + run: | + case $RESULT in + success) + echo "::notice::All Testsuite tests passed" + exit 0 + ;; + skipped) + echo "::error::Testsuite tests were skipped because of an earlier failure" + exit 1 + ;; + *) + echo "::error::One or more Testsuite tests failed" + exit 1 + esac diff --git a/.github/workflows/PRMerged.yml b/.github/workflows/PRMerged.yml new file mode 100644 index 0000000000..73af62a49b --- /dev/null +++ b/.github/workflows/PRMerged.yml @@ -0,0 +1,69 @@ +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 }} + + IdentifyBranches: + if: github.event.pull_request.merged == true || inputs.pr_number + outputs: + branches: ${{ steps.getbranches.outputs.branches }} + branch_count: ${{ steps.getbranches.outputs.branch_count }} + github_token: ${{steps.get_workflow_token.outputs.token}} + runs-on: ubuntu-latest + steps: + - name: Get cherry-pick branches + uses: asterisk/asterisk-ci-actions/GetCherryPickBranchesFromPR@main + id: getbranches + with: + repo: ${{env.REPO}} + pr_number: ${{env.PR_NUMBER}} + cherry_pick_regex: ${{vars.CHERRY_PICK_REGEX}} + github_token: ${{env.GITHUB_TOKEN}} + + MergeCherryPicks: + needs: [ IdentifyBranches ] + if: needs.IdentifyBranches.outputs.branch_count > 0 + continue-on-error: false + strategy: + fail-fast: true + matrix: + branch: ${{ fromJSON(needs.IdentifyBranches.outputs.branches) }} + runs-on: ubuntu-latest + steps: + + - name: Cherry Pick PR ${{env.PR_NUMBER}} to branch ${{matrix.branch}} + uses: asterisk/asterisk-ci-actions/CherryPick@main + with: + repo: ${{env.REPO}} + pr_number: ${{env.PR_NUMBER}} + branch: ${{matrix.branch}} + github_token: ${{secrets.ASTERISKTEAM_PAT}} + access_app_id: ${{secrets.ASTERISK_ORG_ACCESS_APP_ID}} + access_app_key: ${{secrets.ASTERISK_ORG_ACCESS_APP_PRIV_KEY}} diff --git a/.github/workflows/PROpenedOrUpdated.yml b/.github/workflows/PROpenedOrUpdated.yml new file mode 100644 index 0000000000..c56b3ee807 --- /dev/null +++ b/.github/workflows/PROpenedOrUpdated.yml @@ -0,0 +1,104 @@ +name: PROpenedOrUpdated +run-name: "PR ${{github.event.number}} ${{github.event.action}} by ${{ github.actor }}" +on: +# workflow_dispatch: + pull_request_target: + 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}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + MODULES_BLACKLIST: ${{vars.GATETEST_MODULES_BLACKLIST}} ${{vars.UNITTEST_MODULES_BLACKLIST}} + +jobs: + AsteriskUnitTests: + runs-on: ubuntu-latest + 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}} + modules_blacklist: ${{env.MODULES_BLACKLIST}} + github_token: ${{secrets.GITHUB_TOKEN}} + unittest_command: ${{vars.UNITTEST_COMMAND}} + + - name: Get Token needed to add reviewers + id: get_workflow_token + uses: peter-murray/workflow-application-token-action@v1 + with: + application_id: ${{secrets.ASTERISK_ORG_ACCESS_APP_ID}} + application_private_key: ${{secrets.ASTERISK_ORG_ACCESS_APP_PRIV_KEY}} + organization: asterisk + + - name: Add Reviewers + if: ${{ success() }} + env: + GITHUB_TOKEN: ${{steps.get_workflow_token.outputs.token}} + GH_TOKEN: ${{steps.get_workflow_token.outputs.token}} + REVIEWERS: ${{vars.PR_REVIEWERS}} + run: | + echo "${{env.GITHUB_ACTION}} Add reviewers" + IFS=$'; \n' + for r in $REVIEWERS ; do + gh pr edit --repo ${ASTERISK_REPO} ${PR_NUMBER} --add-reviewer $r + done + + AsteriskGate: + needs: AsteriskUnitTests + continue-on-error: false + strategy: + fail-fast: false + matrix: + group: ${{ fromJSON(vars.GATETEST_LIST) }} + runs-on: ubuntu-latest + 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}} + 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: + name: AsteriskGateTests + if: always() + runs-on: ubuntu-latest + needs: AsteriskGate + steps: + - name: Check test matrix status + env: + RESULT: ${{ needs.AsteriskGate.result }} + run: | + echo "all results: ${{ toJSON(needs.*.result) }}" + echo "composite result: ${{ needs.AsteriskGate.result }}" + + case $RESULT in + success) + echo "::notice::All Testsuite tests passed" + exit 0 + ;; + skipped) + echo "::error::Testsuite tests were skipped because of an earlier failure" + exit 1 + ;; + *) + echo "::error::One or more Testsuite tests failed ($RESULT)" + exit 1 + esac