Skip to content

Commit 77e51ad

Browse files
committed
.github Bring workflows up to date with Asterisk
1 parent 5c89420 commit 77e51ad

File tree

5 files changed

+315
-77
lines changed

5 files changed

+315
-77
lines changed

.github/workflows/CherryPickTest.yml

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
11
name: CherryPickTest
2-
run-name: "Cherry-Pick Tests for PR ${{github.event.number || inputs.pr_number}}"
2+
run-name: "Cherry-Pick Tests for PR ${{github.event.number}}"
33
on:
44
pull_request_target:
55
types: [ labeled ]
6-
workflow_dispatch:
7-
inputs:
8-
pr_number:
9-
description: 'PR number'
10-
required: true
11-
type: number
126

137
concurrency:
14-
group: ${{github.workflow}}-${{github.event.number || inputs.pr_number }}
8+
group: ${{github.workflow}}-${{github.event.number}}
159
cancel-in-progress: true
1610

1711
env:
18-
PR_NUMBER: ${{ github.event.number || inputs.pr_number }}
12+
PR_NUMBER: ${{ github.event.number }}
1913
MODULES_BLACKLIST: ${{ vars.GATETEST_MODULES_BLACKLIST }} ${{ vars.UNITTEST_MODULES_BLACKLIST }}
2014

2115
jobs:
2216
IdentifyBranches:
2317
name: IdentifyBranches
24-
if: github.event.label.name == ${{vars.CHERRY_PICK_TEST_LABEL}}
18+
if: ${{ github.event.label.name == vars.CHERRY_PICK_TEST_LABEL }}
2519
outputs:
2620
branches: ${{ steps.getbranches.outputs.branches }}
2721
branch_count: ${{ steps.getbranches.outputs.branch_count }}
2822
runs-on: ubuntu-latest
2923
steps:
30-
- name: Remove Trigger Label
24+
- name: Remove Trigger Label, Add InProgress Label
3125
env:
3226
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3327
run: |
3428
gh pr edit --repo ${{github.repository}} \
35-
--remove-label ${{vars.CHERRY_PICK_TEST_LABEL}} ${{env.PR_NUMBER}} || :
29+
--remove-label ${{vars.CHERRY_PICK_TEST_LABEL}} \
30+
--remove-label ${{vars.CHERRY_PICK_CHECKS_PASSED_LABEL}} \
31+
--remove-label ${{vars.CHERRY_PICK_CHECKS_FAILED_LABEL}} \
32+
--remove-label ${{vars.CHERRY_PICK_GATES_PASSED_LABEL}} \
33+
--remove-label ${{vars.CHERRY_PICK_GATES_FAILED_LABEL}} \
34+
--remove-label ${{vars.CHERRY_PICK_TESTING_IN_PROGRESS}} \
35+
${{env.PR_NUMBER}} || :
3636
3737
- name: Get cherry-pick branches
3838
uses: asterisk/asterisk-ci-actions/GetCherryPickBranchesFromPR@main
@@ -43,9 +43,18 @@ jobs:
4343
cherry_pick_regex: ${{vars.CHERRY_PICK_REGEX}}
4444
github_token: ${{secrets.GITHUB_TOKEN}}
4545

46-
UnitTestMatrix:
46+
- name: Check Branch Count
47+
if: ${{ steps.getbranches.outputs.branch_count > 0 }}
48+
env:
49+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
run: |
51+
gh pr edit --repo ${{github.repository}} \
52+
--add-label ${{vars.CHERRY_PICK_TESTING_IN_PROGRESS}} \
53+
${{env.PR_NUMBER}} || :
54+
55+
CherryPickUnitTestMatrix:
4756
needs: [ IdentifyBranches ]
48-
if: needs.IdentifyBranches.outputs.branch_count > 0
57+
if: ${{ needs.IdentifyBranches.outputs.branch_count > 0 && ( success() || failure() ) }}
4958
continue-on-error: false
5059
strategy:
5160
fail-fast: false
@@ -65,26 +74,37 @@ jobs:
6574
github_token: ${{secrets.GITHUB_TOKEN}}
6675
unittest_command: ${{vars.UNITTEST_COMMAND}}
6776

68-
UnitTests:
69-
if: ${{ always() }}
77+
CherryPickUnitTests:
78+
needs: [ IdentifyBranches, CherryPickUnitTestMatrix ]
79+
if: ${{ needs.IdentifyBranches.outputs.branch_count > 0 && ( success() || failure() ) }}
7080
runs-on: ubuntu-latest
71-
needs: [ UnitTestMatrix ]
7281
steps:
7382
- name: Check unit test matrix status
7483
env:
75-
RESULT: ${{needs.UnitTestMatrix.result}}
84+
RESULT: ${{needs.CherryPickUnitTestMatrix.result}}
85+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7686
run: |
7787
case $RESULT in
7888
success)
89+
gh pr edit --repo ${{github.repository}} \
90+
--add-label ${{vars.CHERRY_PICK_CHECKS_PASSED_LABEL}} \
91+
${{env.PR_NUMBER}} || :
7992
echo "::notice::All tests passed"
8093
exit 0
8194
;;
8295
skipped)
96+
gh pr edit --repo ${{github.repository}} \
97+
--remove-label ${{vars.CHERRY_PICK_TESTING_IN_PROGRESS}} \
98+
--add-label ${{vars.CHERRY_PICK_CHECKS_FAILED_LABEL}} \
99+
${{env.PR_NUMBER}} || :
83100
echo "::notice::Unit tests were skipped because of an earlier failure"
84101
exit 1
85102
;;
86-
*)
103+
*)
104+
gh pr edit --repo ${{github.repository}} \
105+
--remove-label ${{vars.CHERRY_PICK_TESTING_IN_PROGRESS}} \
106+
--add-label ${{vars.CHERRY_PICK_CHECKS_FAILED_LABEL}} \
107+
${{env.PR_NUMBER}} || :
87108
echo "::error::One or more tests failed ($RESULT)"
88109
exit 1
89110
esac
90-

.github/workflows/MergeApproved.yml

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
name: MergeApproved
2+
run-name: "Merge Approved for PR ${{github.event.number}}"
3+
on:
4+
pull_request_target:
5+
types: [labeled]
6+
7+
env:
8+
PR_NUMBER: ${{ github.event.number }}
9+
BASE_BRANCH: ${{github.event.pull_request.base.ref}}
10+
MODULES_BLACKLIST: ${{ vars.GATETEST_MODULES_BLACKLIST }} ${{ vars.UNITTEST_MODULES_BLACKLIST }}
11+
FORCE: ${{ endsWith(github.event.label.name, '-force') }}
12+
13+
jobs:
14+
IdentifyBranches:
15+
if: contains(fromJSON(vars.MERGE_APPROVED_LABELS), github.event.label.name)
16+
outputs:
17+
branches: ${{ steps.getbranches.outputs.branches }}
18+
all_branches: ${{ steps.checkbranches.outputs.all_branches }}
19+
branch_count: ${{ steps.getbranches.outputs.branch_count }}
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Clean up labels
23+
env:
24+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
run: |
26+
gh pr edit --repo ${{github.repository}} \
27+
--remove-label ${{github.event.label.name}} \
28+
--remove-label ${{vars.PRE_MERGE_CHECKS_PASSED_LABEL}} \
29+
--remove-label ${{vars.PRE_MERGE_CHECKS_FAILED_LABEL}} \
30+
--remove-label ${{vars.PRE_MERGE_GATES_PASSED_LABEL}} \
31+
--remove-label ${{vars.PRE_MERGE_GATES_FAILED_LABEL}} \
32+
--remove-label ${{vars.PRE_MERGE_TESTING_IN_PROGRESS}} \
33+
${{env.PR_NUMBER}} || :
34+
35+
- name: Get cherry-pick branches
36+
uses: asterisk/asterisk-ci-actions/GetCherryPickBranchesFromPR@main
37+
id: getbranches
38+
with:
39+
repo: ${{github.repository}}
40+
pr_number: ${{env.PR_NUMBER}}
41+
cherry_pick_regex: ${{vars.CHERRY_PICK_REGEX}}
42+
github_token: ${{secrets.GITHUB_TOKEN}}
43+
44+
- name: Check Branch Count
45+
id: checkbranches
46+
env:
47+
BRANCH_COUNT: ${{ steps.getbranches.outputs.branch_count }}
48+
BRANCHES: ${{ steps.getbranches.outputs.branches }}
49+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
run: |
51+
gh pr edit --repo ${{github.repository}} \
52+
--add-label ${{vars.PRE_MERGE_TESTING_IN_PROGRESS}} \
53+
${{env.PR_NUMBER}} || :
54+
all_branches=$(echo "$BRANCHES" | jq -c "[ \"$BASE_BRANCH\" ] + .")
55+
echo "all_branches=${all_branches}" >>${GITHUB_OUTPUT}
56+
57+
- name: Pre Check Cherry-Picks
58+
if: ${{ steps.getbranches.outputs.branch_count > 0 }}
59+
uses: asterisk/asterisk-ci-actions/CherryPick@main
60+
with:
61+
repo: ${{github.repository}}
62+
pr_number: ${{env.PR_NUMBER}}
63+
branches: ${{steps.getbranches.outputs.branches}}
64+
github_token: ${{secrets.GITHUB_TOKEN}}
65+
push: false
66+
67+
PreMergeUnitTestMatrix:
68+
needs: [ IdentifyBranches ]
69+
if: success()
70+
continue-on-error: false
71+
strategy:
72+
fail-fast: false
73+
matrix:
74+
branch: ${{ fromJSON(needs.IdentifyBranches.outputs.all_branches) }}
75+
runs-on: ubuntu-latest
76+
steps:
77+
- name: Run Unit Tests for branch ${{matrix.branch}}
78+
uses: asterisk/asterisk-ci-actions/TestsuiteUnitComposite@main
79+
with:
80+
testsuite_repo: ${{github.repository}}
81+
asterisk_repo: ${{vars.ASTERISK_REPO}}
82+
pr_number: ${{env.PR_NUMBER}}
83+
base_branch: ${{matrix.branch}}
84+
is_cherry_pick: true
85+
modules_blacklist: ${{env.MODULES_BLACKLIST}}
86+
github_token: ${{secrets.GITHUB_TOKEN}}
87+
unittest_command: ${{vars.UNITTEST_COMMAND}}
88+
89+
PreMergeUnitTests:
90+
needs: [ IdentifyBranches, PreMergeUnitTestMatrix ]
91+
runs-on: ubuntu-latest
92+
steps:
93+
- name: Check unit test matrix status
94+
env:
95+
RESULT: ${{needs.PreMergeUnitTestMatrix.result}}
96+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
97+
run: |
98+
case $RESULT in
99+
success)
100+
gh pr edit --repo ${{github.repository}} \
101+
--remove-label ${{vars.PRE_MERGE_TESTING_IN_PROGRESS}} \
102+
--add-label ${{vars.PRE_MERGE_CHECKS_PASSED_LABEL}} \
103+
${{env.PR_NUMBER}} || :
104+
echo "::notice::All tests passed"
105+
exit 0
106+
;;
107+
skipped)
108+
gh pr edit --repo ${{github.repository}} \
109+
--remove-label ${{vars.PRE_MERGE_TESTING_IN_PROGRESS}} \
110+
--add-label ${{vars.PRE_MERGE_CHECKS_FAILED_LABEL}} \
111+
${{env.PR_NUMBER}} || :
112+
echo "::notice::Unit tests were skipped because of an earlier failure"
113+
exit 1
114+
;;
115+
*)
116+
gh pr edit --repo ${{github.repository}} \
117+
--remove-label ${{vars.PRE_MERGE_TESTING_IN_PROGRESS}} \
118+
--add-label ${{vars.PRE_MERGE_CHECKS_FAILED_LABEL}} \
119+
${{env.PR_NUMBER}} || :
120+
echo "::error::One or more tests failed ($RESULT)"
121+
exit 1
122+
esac
123+
124+
MergeAndCherryPick:
125+
needs: [ IdentifyBranches, PreMergeUnitTests ]
126+
if: success()
127+
concurrency:
128+
group: MergeAndCherryPick
129+
cancel-in-progress: false
130+
runs-on: ubuntu-latest
131+
steps:
132+
- name: Start Merge
133+
env:
134+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
135+
run: |
136+
gh pr edit --repo ${{github.repository}} \
137+
--add-label ${{vars.MERGE_IN_PROGRESS_LABEL}} \
138+
${{env.PR_NUMBER}} || :
139+
140+
- name: Get Token needed to push cherry-picks
141+
id: get_workflow_token
142+
uses: peter-murray/workflow-application-token-action@v1
143+
with:
144+
application_id: ${{secrets.ASTERISK_ORG_ACCESS_APP_ID}}
145+
application_private_key: ${{secrets.ASTERISK_ORG_ACCESS_APP_PRIV_KEY}}
146+
organization: asterisk
147+
148+
- name: Merge and Cherry Pick to ${{needs.IdentifyBranches.outputs.branches}}
149+
id: mergecp
150+
uses: asterisk/asterisk-ci-actions/MergeAndCherryPickComposite@main
151+
with:
152+
repo: ${{github.repository}}
153+
pr_number: ${{env.PR_NUMBER}}
154+
branches: ${{needs.IdentifyBranches.outputs.branches}}
155+
force: ${{env.FORCE}}
156+
github_token: ${{steps.get_workflow_token.outputs.token}}
157+
158+
- name: Merge Cleanup
159+
if: always()
160+
env:
161+
RESULT: ${{ steps.mergecp.outcome }}
162+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
163+
BRANCH_COUNT: ${{ needs.IdentifyBranches.outputs.branch_count }}
164+
BRANCHES: ${{ needs.IdentifyBranches.outputs.branches }}
165+
166+
run: |
167+
case $RESULT in
168+
success)
169+
gh pr edit --repo ${{github.repository}} \
170+
--remove-label ${{vars.MERGE_IN_PROGRESS_LABEL}} \
171+
${{env.PR_NUMBER}} || :
172+
if [ $BRANCH_COUNT -eq 0 ] ; then
173+
gh pr comment --repo ${{github.repository}} \
174+
-b "Successfully merged to branch $BASE_BRANCH." \
175+
${{env.PR_NUMBER}} || :
176+
else
177+
gh pr comment --repo ${{github.repository}} \
178+
-b "Successfully merged to branch $BASE_BRANCH and cherry-picked to $BRANCHES" \
179+
${{env.PR_NUMBER}} || :
180+
fi
181+
exit 0
182+
;;
183+
failure)
184+
gh pr edit --repo ${{github.repository}} \
185+
--remove-label ${{vars.MERGE_IN_PROGRESS_LABEL}} \
186+
--add-label ${{vars.MERGE_FAILED_LABEL}} \
187+
${{env.PR_NUMBER}} || :
188+
exit 1
189+
;;
190+
*)
191+
esac

.github/workflows/NightlyAdmin.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ jobs:
1515
uses: actions/stale@v7
1616
with:
1717
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.'
18+
stale-issue-label: stale
1819
close-issue-message: 'This issue was closed because it has been stalled for 14 days with no activity.'
1920
days-before-stale: 7
2021
days-before-close: 14

.github/workflows/PRMerged.yml

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -30,40 +30,3 @@ jobs:
3030
with:
3131
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3232

33-
IdentifyBranches:
34-
if: github.event.pull_request.merged == true || inputs.pr_number
35-
outputs:
36-
branches: ${{ steps.getbranches.outputs.branches }}
37-
branch_count: ${{ steps.getbranches.outputs.branch_count }}
38-
github_token: ${{steps.get_workflow_token.outputs.token}}
39-
runs-on: ubuntu-latest
40-
steps:
41-
- name: Get cherry-pick branches
42-
uses: asterisk/asterisk-ci-actions/GetCherryPickBranchesFromPR@main
43-
id: getbranches
44-
with:
45-
repo: ${{env.REPO}}
46-
pr_number: ${{env.PR_NUMBER}}
47-
cherry_pick_regex: ${{vars.CHERRY_PICK_REGEX}}
48-
github_token: ${{env.GITHUB_TOKEN}}
49-
50-
MergeCherryPicks:
51-
needs: [ IdentifyBranches ]
52-
if: needs.IdentifyBranches.outputs.branch_count > 0
53-
continue-on-error: false
54-
strategy:
55-
fail-fast: true
56-
matrix:
57-
branch: ${{ fromJSON(needs.IdentifyBranches.outputs.branches) }}
58-
runs-on: ubuntu-latest
59-
steps:
60-
61-
- name: Cherry Pick PR ${{env.PR_NUMBER}} to branch ${{matrix.branch}}
62-
uses: asterisk/asterisk-ci-actions/CherryPick@main
63-
with:
64-
repo: ${{env.REPO}}
65-
pr_number: ${{env.PR_NUMBER}}
66-
branch: ${{matrix.branch}}
67-
github_token: ${{secrets.ASTERISKTEAM_PAT}}
68-
access_app_id: ${{secrets.ASTERISK_ORG_ACCESS_APP_ID}}
69-
access_app_key: ${{secrets.ASTERISK_ORG_ACCESS_APP_PRIV_KEY}}

0 commit comments

Comments
 (0)