-
Notifications
You must be signed in to change notification settings - Fork 4
135 lines (123 loc) · 4.27 KB
/
TestsuitePRCheck.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
name: PRCheck
on:
workflow_call:
permissions:
actions: write
checks: read
contents: read
issues: read
pull-requests: write
repository-projects: read
statuses: read
env:
REPO: ${{ github.repository }}
REPO_DIR: ${{ github.workspace }}/${{ github.event.repository.name }}
REPO_ORG: ${{ github.event.repository.owner.login }}
PR_NUMBER: ${{ github.event.number }}
BASE_BRANCH: ${{ github.event.pull_request.base.ref }}
WORKFLOW_NAME: ${{ github.workflow }}
WORKFLOW_RUN_ID: ${{ github.run_id }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LOG_DIR: ${{ github.workspace }}/logs
LOG_FILE: ${{ github.workspace }}/logs/job_summary.txt
TRIGGER: ${{ github.event.action }}
TESTING_IN_PROGRESS: ${{ vars.PR_SUBMIT_TESTING_IN_PROGRESS }}
TESTS_PASSED: ${{ vars.PR_SUBMIT_TESTS_PASSED }}
TESTS_FAILED: ${{ vars.PR_SUBMIT_TESTS_FAILED }}
jobs:
Setup:
runs-on: ubuntu-latest
outputs:
testsuite_test_pr: ${{ steps.setup.outputs.TESTSUITE_TEST_PR }}
steps:
# ACTIONS_PATH, SCRIPT_DIR, NORMALIZED_BRANCH env vars
- name: GetActionsRepo
uses: asterisk/asterisk-ci-actions/GetActionsRepo@main
- id: setup
env:
PR_STATE_CHANGE_DELAY_SEC: ${{ vars.PR_STATE_CHANGE_DELAY_SEC || 120 }}
RECHECKPR_LABEL: ${{ vars.RECHECKPR_LABEL }}
run: |
echo "Labeling"
gh pr edit --repo ${REPO} \
--remove-label ${RECHECKPR_LABEL} \
--remove-label ${TESTS_PASSED} \
--remove-label ${TESTS_FAILED} \
--add-label ${TESTING_IN_PROGRESS} \
${PR_NUMBER} || :
Check:
name: Check
needs: [ Setup ]
permissions:
actions: read
checks: read
contents: read
issues: read
pull-requests: read
statuses: read
uses: ./.github/workflows/TestsuiteRunUnitTests.yml
with:
pr_number: ${{ github.event.number }}
base_branch: ${{ github.event.pull_request.base.ref }}
unittest_command: ${{ vars.UNITTEST_COMMAND }}
PostWorkflow:
if: ${{ always() }}
runs-on: ubuntu-latest
needs: [Setup,Check]
env:
RESULT_SETUP: ${{ needs.Setup.result }}
RESULT_CHECK: ${{ needs.Check.result }}
CHERRY_PICK_REGEX: ${{ vars.CHERRY_PICK_REGEX }}
CHERRY_PICK_REMINDER: ${{ vars.CHERRY_PICK_REMINDER }}
SQUASH_COMMITS_REMINDER: ${{ vars.SQUASH_COMMITS_REMINDER }}
steps:
# ACTIONS_PATH, SCRIPT_DIR, NORMALIZED_BRANCH env vars
- name: GetActionsRepo
uses: asterisk/asterisk-ci-actions/GetActionsRepo@main
- name: Add labels, reminders and summary
run: |
label=""
RESULT=$RESULT_CHECK
echo "Setup status: $RESULT_SETUP Check status: $RESULT_CHECK"
case $RESULT_CHECK in
success)
label=$TESTS_PASSED
gh cache delete -R ${REPO} ${BUILD_CACHE_KEY} || :
;;
failure)
label=$TESTS_FAILED
;;
cancelled)
gh cache delete -R ${REPO} ${BUILD_CACHE_KEY} || :
;;
skipped)
if [ "$RESULT_SETUP" == "failure" ] ; then
RESULT=failure
label=$TESTS_FAILED
fi
;;
*)
;;
esac
echo "RESULT: '${RESULT}' Setting label: '$label'"
gh pr edit --repo ${REPO} \
--remove-label ${TESTING_IN_PROGRESS} \
${label:+--add-label $label} \
$PR_NUMBER || :
if [[ $RESULT =~ (success|failure) ]] ; then
${SCRIPT_DIR}/PRChecks/addPRChecklistIfNeeded.sh \
--repo=${REPO} \
--pr-number=${PR_NUMBER}
${SCRIPT_DIR}/createJobSummary.sh \
--result=${RESULT} \
--repo=${REPO} \
--workflow-name="${WORKFLOW_NAME}" \
--pr-number=${PR_NUMBER} \
--workflow-run=${WORKFLOW_RUN_ID} \
--tmp-dir=./run-${WORKFLOW_RUN_ID} \
--job-summary-output=job_summary.txt \
--write-step-summary \
--add-pr-comment \
--verbose || :
fi
exit 0