88 type : string
99 required : false
1010 default : ' { "owner": "asterisk", "repo": "asterisk-ci-actions", "branch": "main" }'
11- secrets :
12- TOKEN :
13- required : true
1411
1512env :
1613 REPO : ${{ github.repository }}
2118 WORKFLOW_NAME : ${{ github.workflow }}
2219 WORKFLOW_RUN_ID : ${{ github.run_id }}
2320 SCRIPT_DIR : ${{ github.workspace }}/asterisk-ci-actions/scripts
24- GH_TOKEN : ${{ secrets.TOKEN }}
21+ GH_TOKEN : ${{ secrets.github_token }}
2522 LOG_DIR : ${{ github.workspace }}/logs
23+ BUILD_CACHE_KEY : ${{ github.workflow }}-${{ github.run_number }}-${{ github.event.number }}-${{ github.event.pull_request.base.ref }}
2624 ACTIONS_OWNER : asterisk
2725 ACTIONS_REPO : asterisk-ci-actions
2826 ACTIONS_BRANCH : main
27+ TESTING_IN_PROGRESS : ${{ vars.PR_SUBMIT_TESTING_IN_PROGRESS }}
28+ TESTS_PASSED : ${{ vars.PR_SUBMIT_TESTS_PASSED }}
29+ TESTS_FAILED : ${{ vars.PR_SUBMIT_TESTS_FAILED }}
2930
3031jobs :
31- #
32- # Pull requests created from forked respositories don't have access
33- # to the "Action Variables" ('vars' context) so we need to retrieve
34- # control data from an action that's located in asterisk-ci-actions.
35- #
3632 Setup :
3733 runs-on : ubuntu-latest
3834 outputs :
39- vars : ${{ steps.setvars.outputs.control_data }}
4035 testsuite_test_pr : ${{ steps.setup.outputs.TESTSUITE_TEST_PR }}
4136 normalized_branch : ${{ steps.setup.outputs.NORMALIZED_BRANCH }}
4237 steps :
43- - id : setvars
44- uses : asterisk/asterisk-ci-actions/GetRepoControlData@main
45- with :
46- repo : ${{ github.event.repository.name }}
38+ - name : DumpEnvironment
39+ run : |
40+ echo "::group::vars_context"
41+ cat <<%%EOF%% | sed -r -e "/(TOKEN|token|ghs_)/d" | tee ${OUTPUT_DIR}/env_context.json
42+ ${{toJSON(vars)}}
43+ %%EOF%%
44+ echo "::endgroup::"
45+
46+ echo "::group::env_context"
47+ cat <<%%EOF%% | sed -r -e "/(TOKEN|token|ghs_)/d" | tee ${OUTPUT_DIR}/env_context.json
48+ ${{toJSON(env)}}
49+ %%EOF%%
50+ echo "::endgroup::"
51+
52+ echo "::group::github_context"
53+ cat <<%%EOF%% | sed -r -e "/(TOKEN|token|ghs_)/d" | tee ${OUTPUT_DIR}/github_context.json
54+ ${{toJSON(github)}}
55+ %%EOF%%
56+ echo "::endgroup::"
57+
58+ echo "::group::shell_env"
59+ printenv | sort | sed -r -e "/(TOKEN|token|ghs_)/d" | tee ${OUTPUT_DIR}/shell_env.env
60+ echo "::endgroup::"
61+
62+ if [ -n "${GITHUB_ACTION_PATH}" ] ; then
63+ echo "::group::GITHUB_ACTION_PATH: ${GITHUB_ACTION_PATH}"
64+ echo "${GITHUB_ACTION_PATH}" > ${OUTPUT_DIR}/GITHUB_ACTION_PATH.txt
65+ ls -al ${GITHUB_ACTION_PATH} | tee -a ${OUTPUT_DIR}/GITHUB_ACTION_PATH.txt
66+ echo "::endgroup::"
67+ fi
68+
69+
70+ uses: asterisk/asterisk-ci-actions/DumpEnvironmentAction@main
4771
4872 - id: setup
4973 env:
50- PR_STATE_CHANGE_DELAY_SEC : ${{ fromJSON(steps.setvars.outputs.control_data) .PR_STATE_CHANGE_DELAY_SEC || 120 }}
51- TESTSUITE_TEST_PR_REGEX : ${{ fromJSON(steps.setvars.outputs.control_data) .TESTSUITE_TEST_PR_REGEX }}
74+ PR_STATE_CHANGE_DELAY_SEC: ${{ vars .PR_STATE_CHANGE_DELAY_SEC || 120 }}
75+ TESTSUITE_TEST_PR_REGEX: ${{ vars .TESTSUITE_TEST_PR_REGEX }}
5276 run: |
5377 # Wait then get testsuite PR
5478 echo "Waiting for ${PR_STATE_CHANGE_DELAY_SEC} seconds to give user a chance to add PR comments"
@@ -69,43 +93,90 @@ jobs:
6993 --pr-number=${PR_NUMBER} \
7094 --testsuite-pr-regex="${TESTSUITE_TEST_PR_REGEX}"
7195
96+ gh cache delete -R ${REPO} ${BUILD_CACHE_KEY} &> /dev/null || :
97+ #
98+ gh pr edit --repo ${REPO} \
99+ --remove-label ${TESTS_PASSED} \
100+ --remove-label ${TESTS_FAILED} \
101+ --add-label ${TESTING_IN_PROGRESS} \
102+ $PR_NUMBER || :
103+
72104 Check:
73105 name: Check
74106 needs: Setup
75- uses : asterisk/asterisk-ci-actions/.github/workflows/AsteriskUnitGateTest.yml@main
107+ permissions:
108+ actions: read
109+ checks: read
110+ contents: read
111+ issues: read
112+ pull-requests: read
113+ statuses: read
114+ uses: ./.github/workflows/AsteriskUnitGateTest.yml
76115 with:
77116 test_type: prstatechange
78117 asterisk_repo: ${{ github.repository }}
79118 pr_number: ${{ github.event.number }}
80119 base_branch: ${{ github.event.pull_request.base.ref }}
81- build_options : ${{ fromJSON(needs.Setup.outputs.vars).BUILD_OPTIONS }}
82- unittest_command : ${{ fromJSON(needs.Setup.outputs.vars).UNITTEST_COMMAND }}
83- testsuite_repo : ${{ fromJSON(needs.Setup.outputs.vars).TESTSUITE_REPO }}
120+ is_cherry_pick: false
121+ build_options: ${{ vars.BUILD_OPTIONS }}
122+ unittest_command: ${{ vars.UNITTEST_COMMAND }}
123+ testsuite_repo: ${{ vars.TESTSUITE_REPO }}
84124 testsuite_test_pr: ${{ needs.Setup.outputs.testsuite_test_pr }}
85- gatetest_list : ${{ fromJSON(needs.Setup.outputs.vars).GATETEST_LIST }}
86- gatetest_commands : ${{ fromJSON(needs.Setup.outputs.vars).GATETEST_COMMANDS }}
87- secrets : inherit
125+ gatetest_list: ${{ vars.GATETEST_LIST }}
126+ gatetest_commands: ${{ vars.GATETEST_COMMANDS }}
88127
89128 PostWorkflow:
90- if : ${{ success() || failure() }}
129+ if: ${{ success() || failure() || cancelled() }}
91130 runs-on: ubuntu-latest
92131 needs: [Setup,Check]
93132 env:
94- RESULT : ${{ needs.Check.result }}
133+ RESULT: ${{ needs.Check.result }}
134+ CHERRY_PICK_REGEX: ${{ vars.CHERRY_PICK_REGEX }}
135+ CHERRY_PICK_REMINDER: ${{ vars.CHERRY_PICK_REMINDER }}
136+ SQUASH_COMMITS_REMINDER: ${{ vars.SQUASH_COMMITS_REMINDER }}
137+ USER_NOTE_REMINDER: ${{ vars.USER_NOTE_REMINDER }}
138+ UPGRADE_NOTE_REMINDER: ${{ vars.UPGRADE_NOTE_REMINDER }}
95139 steps:
96- - name : Create Job Summary
140+ - name: Add labels, reminders and summary
97141 run: |
98- wget -qO asterisk-ci-actions.tar.gz \
99- https://github.com/${ACTIONS_OWNER}/${ACTIONS_REPO}/archive/refs/heads/${ACTIONS_BRANCH}.tar.gz
100- tar -xf asterisk-ci-actions.tar.gz --transform="s/^${ACTIONS_REPO}-${ACTIONS_BRANCH}/asterisk-ci-actions/g"
142+ label=""
143+ case $RESULT in
144+ success)
145+ label=$TESTS_PASSED
146+ gh cache delete -R ${REPO} ${BUILD_CACHE_KEY} || :
147+ ;;
148+ failure)
149+ label=$TESTS_FAILED
150+ ;;
151+ cancelled)
152+ gh cache delete -R ${REPO} ${BUILD_CACHE_KEY} || :
153+ ;;
154+ skipped)
155+ ;;
156+ *)
157+ ;;
158+ esac
159+ gh pr edit --repo ${REPO} \
160+ --remove-label ${TESTING_IN_PROGRESS} \
161+ ${label:+--add-label $label} \
162+ $PR_NUMBER || :
101163
102- ${SCRIPT_DIR}/createJobSummary.sh \
103- --result=${RESULT} \
104- --repo=${REPO} \
105- --workflow-name="${WORKFLOW_NAME}" \
106- --workflow-run=${WORKFLOW_RUN_ID} \
107- --tmp-dir=./run-${WORKFLOW_RUN_ID} \
108- --job-summary-output=job_summary.txt \
109- --write-step-summary \
110- --verbose || :
164+ if [[ $RESULT =~ (success|failure) ]] ; then
165+ ${SCRIPT_DIR}/addCherryPickReminderIfNeeded.sh \
166+ --repo=${REPO} \
167+ --pr-number=${PR_NUMBER} \
168+ --cherry-pick-regex="${CHERRY_PICK_REGEX}" \
169+ --cherry-pick-reminder="${CHERRY_PICK_REMINDER}"
170+
171+ ${SCRIPT_DIR}/createJobSummary.sh \
172+ --result=${RESULT} \
173+ --repo=${REPO} \
174+ --workflow-name="${WORKFLOW_NAME}" \
175+ --pr-number=${PR_NUMBER} \
176+ --workflow-run=${WORKFLOW_RUN_ID} \
177+ --tmp-dir=./run-${WORKFLOW_RUN_ID} \
178+ --job-summary-output=job_summary.txt \
179+ --add-pr-comment \
180+ --verbose || :
181+ fi
111182 exit 0
0 commit comments