|
|
|
@ -1,15 +1,30 @@
|
|
|
|
|
name: PRCPCheck
|
|
|
|
|
run-name: "PR ${{ github.event.number }} CherryPickTest"
|
|
|
|
|
run-name: "PR ${{ github.event.number }} CherryPickTest by ${{ github.actor }}"
|
|
|
|
|
on:
|
|
|
|
|
pull_request_target:
|
|
|
|
|
types: [ labeled ]
|
|
|
|
|
|
|
|
|
|
concurrency:
|
|
|
|
|
group: ${{ github.workflow }}-${{ github.event.label.name }}-${{ github.event.number }}
|
|
|
|
|
group: ${{ github.event.label.name }}-${{ github.event.number }}
|
|
|
|
|
cancel-in-progress: true
|
|
|
|
|
|
|
|
|
|
env:
|
|
|
|
|
PR_NUMBER: ${{ github.event.number }}
|
|
|
|
|
REPO: ${{ github.repository }}
|
|
|
|
|
REPO_DIR: ${{ github.workspace }}/${{ github.event.repository.name }}
|
|
|
|
|
REPO_ORG: ${{ github.event.repository.owner.login }}
|
|
|
|
|
PR_NUMBER: ${{ github.event.number }}
|
|
|
|
|
WORKFLOW_NAME: ${{ github.workflow }}
|
|
|
|
|
WORKFLOW_RUN_ID: ${{ github.run_id }}
|
|
|
|
|
SCRIPT_DIR: ${{ github.workspace }}/asterisk-ci-actions/scripts
|
|
|
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
LOG_DIR: ${{ github.workspace }}/logs
|
|
|
|
|
LOG_FILE: ${{ github.workspace }}/logs/job_summary.txt
|
|
|
|
|
ACTIONS_OWNER: asterisk
|
|
|
|
|
ACTIONS_REPO: asterisk-ci-actions
|
|
|
|
|
ACTIONS_BRANCH: main
|
|
|
|
|
TESTING_IN_PROGRESS: ${{ vars.CHERRY_PICK_TESTING_IN_PROGRESS }}
|
|
|
|
|
TESTS_PASSED: ${{ vars.CHERRY_PICK_CHECKS_PASSED_LABEL }}
|
|
|
|
|
TESTS_FAILED: ${{ vars.CHERRY_PICK_CHECKS_FAILED_LABEL }}
|
|
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
|
Setup:
|
|
|
|
@ -17,58 +32,75 @@ jobs:
|
|
|
|
|
name: Setup
|
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
outputs:
|
|
|
|
|
branches: ${{ steps.getbranches.outputs.branches }}
|
|
|
|
|
branch_count: ${{ steps.getbranches.outputs.branch_count }}
|
|
|
|
|
testsuite_test_pr: ${{ steps.testsuitepr.outputs.testsuite_test_pr }}
|
|
|
|
|
branches: ${{ steps.setup.outputs.BRANCHES }}
|
|
|
|
|
branch_count: ${{ steps.setup.outputs.BRANCH_COUNT }}
|
|
|
|
|
testsuite_test_pr: ${{ steps.setup.outputs.TESTSUITE_TEST_PR }}
|
|
|
|
|
steps:
|
|
|
|
|
- name: Remove Trigger Label, Add InProgress Label
|
|
|
|
|
- id: setup
|
|
|
|
|
env:
|
|
|
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
CHERRY_PICK_TEST_LABEL: ${{ vars.CHERRY_PICK_TEST_LABEL }}
|
|
|
|
|
CHERRY_PICK_REGEX: ${{ vars.CHERRY_PICK_REGEX }}
|
|
|
|
|
TESTSUITE_TEST_PR_REGEX: ${{ vars.TESTSUITE_TEST_PR_REGEX }}
|
|
|
|
|
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_TESTING_IN_PROGRESS }} \
|
|
|
|
|
$PR_NUMBER || :
|
|
|
|
|
# Setup
|
|
|
|
|
wget -qO asterisk-ci-actions.tar.gz \
|
|
|
|
|
https://github.com/${ACTIONS_OWNER}/${ACTIONS_REPO}/archive/refs/heads/${ACTIONS_BRANCH}.tar.gz
|
|
|
|
|
tar -xf asterisk-ci-actions.tar.gz --transform="s/^${ACTIONS_REPO}-${ACTIONS_BRANCH}/asterisk-ci-actions/g"
|
|
|
|
|
|
|
|
|
|
- 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 }}
|
|
|
|
|
gh pr edit --repo ${REPO} \
|
|
|
|
|
--remove-label ${CHERRY_PICK_TEST_LABEL} \
|
|
|
|
|
--remove-label ${TESTS_PASSED} \
|
|
|
|
|
--remove-label ${TESTS_FAILED} \
|
|
|
|
|
--remove-label ${TESTING_IN_PROGRESS} \
|
|
|
|
|
${PR_NUMBER} || :
|
|
|
|
|
|
|
|
|
|
# The script will populate BRANCHES and BRANCH_COUNT in
|
|
|
|
|
# both GITHUB_ENV and GITHUB_OUTPUT for future use but
|
|
|
|
|
# we need them here as well so we need to capture and
|
|
|
|
|
# parse the output.
|
|
|
|
|
result=$(${SCRIPT_DIR}/getCherryPickBranchesFromPR.sh \
|
|
|
|
|
--repo=${REPO} \
|
|
|
|
|
--pr-number=${PR_NUMBER} \
|
|
|
|
|
--cherry-pick-regex="${CHERRY_PICK_REGEX}")
|
|
|
|
|
BRANCH_COUNT=$(echo ${result} | jq -c '.branch_count')
|
|
|
|
|
BRANCHES=$(echo ${result} | jq -c '.branches')
|
|
|
|
|
FORCED_NONE=$(echo ${result} | jq -c '.forced_none')
|
|
|
|
|
|
|
|
|
|
if [ ${BRANCH_COUNT} -eq 0 ] ; then
|
|
|
|
|
echo "No cherry-pick branches"
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
gh pr edit --repo ${REPO} \
|
|
|
|
|
--add-label ${TESTING_IN_PROGRESS} \
|
|
|
|
|
${PR_NUMBER} || :
|
|
|
|
|
|
|
|
|
|
- name: Check Branch Count
|
|
|
|
|
if: ${{ steps.getbranches.outputs.branch_count > 0 }}
|
|
|
|
|
# The script will populate TESTSUITE_TEST_PR in both
|
|
|
|
|
# GITHUB_ENV and GITHUB_OUTPUT.
|
|
|
|
|
${SCRIPT_DIR}/getTestsuitePRfromAsteriskPR.sh \
|
|
|
|
|
--repo=${REPO} \
|
|
|
|
|
--pr-number=${PR_NUMBER} \
|
|
|
|
|
--testsuite-pr-regex="${TESTSUITE_TEST_PR_REGEX}"
|
|
|
|
|
|
|
|
|
|
- name: CheckCherryPicks
|
|
|
|
|
env:
|
|
|
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
BRANCHES: ${{ steps.setup.outputs.branches }}
|
|
|
|
|
run: |
|
|
|
|
|
gh pr edit --repo ${{ github.repository }} \
|
|
|
|
|
--add-label ${{ vars.CHERRY_PICK_TESTING_IN_PROGRESS }} \
|
|
|
|
|
$PR_NUMBER || :
|
|
|
|
|
|
|
|
|
|
- name: GetTestsuitePR
|
|
|
|
|
id: testsuitepr
|
|
|
|
|
uses: asterisk/asterisk-ci-actions/GetTestsuitePRFromAsteriskPR@main
|
|
|
|
|
with:
|
|
|
|
|
repo: ${{ github.repository }}
|
|
|
|
|
pr_number: ${{ github.event.number }}
|
|
|
|
|
testsuite_test_pr_regex: ${{ vars.TESTSUITE_TEST_PR_REGEX }}
|
|
|
|
|
testsuite_test_auto_merge_regex: ${{ vars.TESTSUITE_TEST_AUTO_MERGE_REGEX }}
|
|
|
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
${SCRIPT_DIR}/cherryPick.sh \
|
|
|
|
|
--repo=${REPO} \
|
|
|
|
|
--repo-dir=${REPO_DIR} \
|
|
|
|
|
--pr-number=${PR_NUMBER} \
|
|
|
|
|
--output-dir=${LOG_DIR} \
|
|
|
|
|
--branches="${BRANCHES}"
|
|
|
|
|
|
|
|
|
|
- name: CherryPick
|
|
|
|
|
uses: asterisk/asterisk-ci-actions/CherryPick@main
|
|
|
|
|
- name: Save Output
|
|
|
|
|
id: save-output
|
|
|
|
|
if: ${{ always() }}
|
|
|
|
|
uses: actions/upload-artifact@v4
|
|
|
|
|
with:
|
|
|
|
|
repo: ${{ github.repository }}
|
|
|
|
|
pr_number: ${{ github.event.number }}
|
|
|
|
|
branches: ${{ steps.getbranches.outputs.branches }}
|
|
|
|
|
push: false
|
|
|
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
debug: false
|
|
|
|
|
name: Setup
|
|
|
|
|
if-no-files-found: ignore
|
|
|
|
|
path: ${{ env.LOG_DIR }}
|
|
|
|
|
|
|
|
|
|
Check:
|
|
|
|
|
needs: [Setup]
|
|
|
|
@ -93,32 +125,61 @@ jobs:
|
|
|
|
|
secrets:
|
|
|
|
|
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
|
|
|
|
|
Cleanup:
|
|
|
|
|
if: ${{ success() || failure() }}
|
|
|
|
|
PostWorkflow:
|
|
|
|
|
if: ${{ success() || failure() || cancelled() }}
|
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
needs: [Setup,Check]
|
|
|
|
|
env:
|
|
|
|
|
RESULT: ${{ needs.Check.result }}
|
|
|
|
|
BUILD_CACHE_KEY_PREFIX: ${{ github.workflow }}-${{ github.run_number }}-${{ github.event.number }}
|
|
|
|
|
BRANCHES: ${{ needs.Setup.outputs.branches }}
|
|
|
|
|
steps:
|
|
|
|
|
- name: Check status
|
|
|
|
|
env:
|
|
|
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
RESULT_UNIT: ${{ needs.Check.result }}
|
|
|
|
|
TESTS_PASSED: ${{ vars.CHERRY_PICK_CHECKS_PASSED_LABEL }}
|
|
|
|
|
TESTS_FAILED: ${{ vars.CHERRY_PICK_CHECKS_FAILED_LABEL }}
|
|
|
|
|
run: |
|
|
|
|
|
declare -i rc=0
|
|
|
|
|
case $RESULT_UNIT in
|
|
|
|
|
label=""
|
|
|
|
|
branches=$(echo $BRANCHES | jq -r '.[]')
|
|
|
|
|
case $RESULT in
|
|
|
|
|
success)
|
|
|
|
|
label=$TESTS_PASSED
|
|
|
|
|
for b in $branches ; do
|
|
|
|
|
gh cache delete -R ${REPO} ${BUILD_CACHE_KEY_PREFIX}-$b || :
|
|
|
|
|
done
|
|
|
|
|
;;
|
|
|
|
|
failure)
|
|
|
|
|
label=$TESTS_FAILED
|
|
|
|
|
;;
|
|
|
|
|
cancelled)
|
|
|
|
|
for b in $branches ; do
|
|
|
|
|
gh cache delete -R ${REPO} ${BUILD_CACHE_KEY_PREFIX}-$b || :
|
|
|
|
|
done
|
|
|
|
|
;;
|
|
|
|
|
skipped)
|
|
|
|
|
rc+=1
|
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
rc+=1
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
[ $rc -gt 0 ] && label=$TESTS_FAILED || label=$TESTS_PASSED
|
|
|
|
|
gh pr edit --repo ${{ github.repository }} \
|
|
|
|
|
--remove-label ${{ vars.CHERRY_PICK_TESTING_IN_PROGRESS }} \
|
|
|
|
|
--add-label $label \
|
|
|
|
|
gh pr edit --repo ${REPO} \
|
|
|
|
|
--remove-label ${TESTING_IN_PROGRESS} \
|
|
|
|
|
${label:+--add-label $label} \
|
|
|
|
|
$PR_NUMBER || :
|
|
|
|
|
exit 0
|
|
|
|
|
|
|
|
|
|
- name: Create Job Summary
|
|
|
|
|
if: ${{ success() || failure() }}
|
|
|
|
|
run: |
|
|
|
|
|
wget -qO asterisk-ci-actions.tar.gz \
|
|
|
|
|
https://github.com/${ACTIONS_OWNER}/${ACTIONS_REPO}/archive/refs/heads/${ACTIONS_BRANCH}.tar.gz
|
|
|
|
|
tar -xf asterisk-ci-actions.tar.gz --transform="s/^${ACTIONS_REPO}-${ACTIONS_BRANCH}/asterisk-ci-actions/g"
|
|
|
|
|
|
|
|
|
|
${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 || :
|
|
|
|
|
exit 0
|
|
|
|
|