mirror of https://github.com/asterisk/asterisk
Moved to asterisk-ci-actions reusable workflows.pull/1120/head
parent
7597082312
commit
d55b072a93
@ -0,0 +1,16 @@
|
||||
name: PRCPCheck
|
||||
run-name: "PR ${{ github.event.number }} ${{ github.workflow }} by ${{ github.actor }}"
|
||||
on:
|
||||
pull_request_target:
|
||||
types: [ labeled ]
|
||||
|
||||
jobs:
|
||||
PRCPCheck:
|
||||
if: ${{ github.event.label.name == vars.CHERRY_PICK_TEST_LABEL }}
|
||||
concurrency:
|
||||
group: cpcheck-${{ github.event.number }}
|
||||
cancel-in-progress: true
|
||||
name: "run-cpcheck"
|
||||
uses: asterisk/asterisk-ci-actions/.github/workflows/AsteriskPRCPCheck.yml@main
|
||||
secrets:
|
||||
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
@ -0,0 +1,31 @@
|
||||
#
|
||||
# Workflows, like this one, that are triggered by PRs submitted
|
||||
# from forked repositories are severly limited in what they can do
|
||||
# for security reasons. For instance, they can't add or remove
|
||||
# labels or comments even on the PR that triggered them. Since
|
||||
# we need to both of those things, GitHub recommends creating a
|
||||
# separate workflow that does those tasks that's triggered when
|
||||
# this PR workflow starts or finishes. Since that workflow isn't
|
||||
# being run in the context of a forked repo, it has all the
|
||||
# privileges needed to add and remove labels and comments. The
|
||||
# accompanying OnPRStateChangedPriv workflow does just that.
|
||||
|
||||
name: PRChanged
|
||||
# WARNING! The run name MUST start with "PR <pr_number>".
|
||||
# The accompanying privleged workflow parses this to find
|
||||
# the PR number. It's the only reliable way it can get it.
|
||||
run-name: "PR ${{ github.event.number }} Changed by ${{ github.actor }}"
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, reopened, synchronize]
|
||||
|
||||
concurrency:
|
||||
group: check-${{ github.event.number }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
PRChanged:
|
||||
name: "run-check"
|
||||
uses: asterisk/asterisk-ci-actions/.github/workflows/AsteriskPRChanged.yml@main
|
||||
secrets:
|
||||
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
@ -1,185 +0,0 @@
|
||||
name: PRCPCheck
|
||||
run-name: "PR ${{ github.event.number }} CherryPickTest by ${{ github.actor }}"
|
||||
on:
|
||||
pull_request_target:
|
||||
types: [ labeled ]
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.event.label.name }}-${{ github.event.number }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
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:
|
||||
if: ${{ github.event.label.name == vars.CHERRY_PICK_TEST_LABEL }}
|
||||
name: Setup
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
branches: ${{ steps.setup.outputs.BRANCHES }}
|
||||
branch_count: ${{ steps.setup.outputs.BRANCH_COUNT }}
|
||||
testsuite_test_pr: ${{ steps.setup.outputs.TESTSUITE_TEST_PR }}
|
||||
steps:
|
||||
- id: setup
|
||||
env:
|
||||
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: |
|
||||
# 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"
|
||||
|
||||
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} || :
|
||||
|
||||
# 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:
|
||||
BRANCHES: ${{ steps.setup.outputs.branches }}
|
||||
run: |
|
||||
${SCRIPT_DIR}/cherryPick.sh \
|
||||
--repo=${REPO} \
|
||||
--repo-dir=${REPO_DIR} \
|
||||
--pr-number=${PR_NUMBER} \
|
||||
--output-dir=${LOG_DIR} \
|
||||
--branches="${BRANCHES}"
|
||||
|
||||
- name: Save Output
|
||||
id: save-output
|
||||
if: ${{ always() }}
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: Setup
|
||||
if-no-files-found: ignore
|
||||
path: ${{ env.LOG_DIR }}
|
||||
|
||||
Check:
|
||||
needs: [Setup]
|
||||
if: ${{ needs.Setup.outputs.branch_count > 0 && ( success() ) }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
branch: ${{ fromJSON(needs.Setup.outputs.branches) }}
|
||||
uses: asterisk/asterisk-ci-actions/.github/workflows/AsteriskUnitGateTest.yml@main
|
||||
with:
|
||||
test_type: cherry-pick
|
||||
asterisk_repo: ${{ github.repository }}
|
||||
pr_number: ${{ github.event.number }}
|
||||
base_branch: ${{ matrix.branch }}
|
||||
is_cherry_pick: true
|
||||
build_options: ${{ vars.BUILD_OPTIONS }}
|
||||
unittest_command: ${{ vars.UNITTEST_COMMAND }}
|
||||
testsuite_repo: ${{ vars.TESTSUITE_REPO }}
|
||||
testsuite_test_pr: ${{ needs.Setup.outputs.testsuite_test_pr }}
|
||||
gatetest_list: ${{ vars.GATETEST_LIST }}
|
||||
gatetest_commands: ${{ vars.GATETEST_COMMANDS }}
|
||||
secrets:
|
||||
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
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
|
||||
run: |
|
||||
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)
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
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
|
@ -1,123 +0,0 @@
|
||||
#
|
||||
# Workflows, like this one, that are triggered by PRs submitted
|
||||
# from forked repositories are severly limited in what they can do
|
||||
# for security reasons. For instance, they can't add or remove
|
||||
# labels or comments even on the PR that triggered them. Since
|
||||
# we need to both of those things, GitHub recommends creating a
|
||||
# separate workflow that does those tasks that's triggered when
|
||||
# this PR workflow starts or finishes. Since that workflow isn't
|
||||
# being run in the context of a forked repo, it has all the
|
||||
# privileges needed to add and remove labels and comments. The
|
||||
# accompanying OnPRStateChangedPriv workflow does just that.
|
||||
|
||||
name: PRChanged
|
||||
# WARNING! The run name MUST start with "PR <pr_number>".
|
||||
# The accompanying privleged workflow parses this to find
|
||||
# the PR number. It's the only reliable way it can get it.
|
||||
run-name: "PR ${{ github.event.number }} ${{ github.event.action }} by ${{ github.actor }}"
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, reopened, synchronize]
|
||||
|
||||
concurrency:
|
||||
group: check-${{ github.event.number }}
|
||||
cancel-in-progress: true
|
||||
|
||||
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 }}
|
||||
SCRIPT_DIR: ${{ github.workspace }}/asterisk-ci-actions/scripts
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
LOG_DIR: ${{ github.workspace }}/logs
|
||||
ACTIONS_OWNER: asterisk
|
||||
ACTIONS_REPO: asterisk-ci-actions
|
||||
ACTIONS_BRANCH: main
|
||||
|
||||
jobs:
|
||||
#
|
||||
# Pull requests created from forked respositories don't have access
|
||||
# to the "Action Variables" ('vars' context) so we need to retrieve
|
||||
# control data from an action that's located in asterisk-ci-actions.
|
||||
#
|
||||
Setup:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
vars: ${{ steps.setvars.outputs.control_data }}
|
||||
testsuite_test_pr: ${{ steps.setup.outputs.TESTSUITE_TEST_PR }}
|
||||
normalized_branch: ${{ steps.setup.outputs.NORMALIZED_BRANCH }}
|
||||
steps:
|
||||
- id: setvars
|
||||
uses: asterisk/asterisk-ci-actions/GetRepoControlData@main
|
||||
with:
|
||||
repo: ${{ github.event.repository.name }}
|
||||
|
||||
- id: setup
|
||||
env:
|
||||
PR_STATE_CHANGE_DELAY_SEC: ${{ fromJSON(steps.setvars.outputs.control_data).PR_STATE_CHANGE_DELAY_SEC || 120 }}
|
||||
TESTSUITE_TEST_PR_REGEX: ${{ fromJSON(steps.setvars.outputs.control_data).TESTSUITE_TEST_PR_REGEX }}
|
||||
run: |
|
||||
# Wait then get testsuite PR
|
||||
echo "Waiting for ${PR_STATE_CHANGE_DELAY_SEC} seconds to give user a chance to add PR comments"
|
||||
sleep ${PR_STATE_CHANGE_DELAY_SEC}
|
||||
|
||||
NORMALIZED_BRANCH="${BASE_BRANCH/\//-}"
|
||||
echo "NORMALIZED_BRANCH=${NORMALIZED_BRANCH}" >> ${GITHUB_ENV}
|
||||
echo "NORMALIZED_BRANCH=${NORMALIZED_BRANCH}" >> ${GITHUB_OUTPUT}
|
||||
|
||||
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"
|
||||
|
||||
# Testsuite PR will be placed in TESTSUITE_TEST_PR in both
|
||||
# GITHUB_ENV and GITHUB_OUTPUT by the script.
|
||||
${SCRIPT_DIR}/getTestsuitePRfromAsteriskPR.sh \
|
||||
--repo=${REPO} \
|
||||
--pr-number=${PR_NUMBER} \
|
||||
--testsuite-pr-regex="${TESTSUITE_TEST_PR_REGEX}"
|
||||
|
||||
Check:
|
||||
name: Check
|
||||
needs: Setup
|
||||
uses: asterisk/asterisk-ci-actions/.github/workflows/AsteriskUnitGateTest.yml@main
|
||||
with:
|
||||
test_type: prstatechange
|
||||
asterisk_repo: ${{ github.repository }}
|
||||
pr_number: ${{ github.event.number }}
|
||||
base_branch: ${{ github.event.pull_request.base.ref }}
|
||||
build_options: ${{ fromJSON(needs.Setup.outputs.vars).BUILD_OPTIONS }}
|
||||
unittest_command: ${{ fromJSON(needs.Setup.outputs.vars).UNITTEST_COMMAND }}
|
||||
testsuite_repo: ${{ fromJSON(needs.Setup.outputs.vars).TESTSUITE_REPO }}
|
||||
testsuite_test_pr: ${{ needs.Setup.outputs.testsuite_test_pr }}
|
||||
gatetest_list: ${{ fromJSON(needs.Setup.outputs.vars).GATETEST_LIST }}
|
||||
gatetest_commands: ${{ fromJSON(needs.Setup.outputs.vars).GATETEST_COMMANDS }}
|
||||
secrets:
|
||||
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
PostWorkflow:
|
||||
if: ${{ success() || failure() }}
|
||||
runs-on: ubuntu-latest
|
||||
needs: [Setup,Check]
|
||||
env:
|
||||
RESULT: ${{ needs.Check.result }}
|
||||
steps:
|
||||
- name: Create Job Summary
|
||||
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}" \
|
||||
--workflow-run=${WORKFLOW_RUN_ID} \
|
||||
--tmp-dir=./run-${WORKFLOW_RUN_ID} \
|
||||
--job-summary-output=job_summary.txt \
|
||||
--write-step-summary \
|
||||
--verbose || :
|
||||
exit 0
|
Loading…
Reference in new issue