PR 18 synchronize by btriller #29
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: PROpenedOrUpdated | |
run-name: "PR ${{github.event.number}} ${{github.event.action}} by ${{ github.actor }}" | |
on: | |
# workflow_dispatch: | |
pull_request_target: | |
types: [opened, reopened, synchronize] | |
env: | |
ASTERISK_REPO: ${{vars.ASTERISK_REPO}} | |
TESTSUITE_REPO: ${{github.repository}} | |
PR_NUMBER: ${{github.event.number}} | |
PR_COMMIT: ${{github.event.pull_request.head.sha}} | |
BRANCH: ${{github.event.pull_request.base.ref}} | |
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
MODULES_BLACKLIST: ${{vars.GATETEST_MODULES_BLACKLIST}} ${{vars.UNITTEST_MODULES_BLACKLIST}} | |
jobs: | |
PROpenUpdateUnitTests: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get Token needed to add reviewers | |
if: github.event.action == 'opened' | |
id: get_workflow_token | |
uses: peter-murray/workflow-application-token-action@v1 | |
with: | |
application_id: ${{secrets.ASTERISK_ORG_ACCESS_APP_ID}} | |
application_private_key: ${{secrets.ASTERISK_ORG_ACCESS_APP_PRIV_KEY}} | |
organization: asterisk | |
- name: Add cherry-pick reminder and reviewers | |
if: github.event.action == 'opened' | |
env: | |
GITHUB_TOKEN: ${{steps.get_workflow_token.outputs.token}} | |
GH_TOKEN: ${{steps.get_workflow_token.outputs.token}} | |
CHERRY_PICK_REMINDER: ${{vars.CHERRY_PICK_REMINDER}} | |
REVIEWERS: ${{vars.PR_REVIEWERS}} | |
run: | | |
IFS=$'; \n' | |
for r in $REVIEWERS ; do | |
echo "Adding reviewer $r" | |
gh pr edit --repo ${{github.repository}} ${PR_NUMBER} --add-reviewer $r || : | |
done | |
# If there's already a reminder comment, don't add another one. | |
ADD_COMMENT=true | |
# This query will FAIL if it finds the comment. | |
gh pr view --repo ${{github.repository}} --json comments \ | |
--jq '.comments[].body | select(. | startswith("<!--CPR-->")) | halt_error(1)' \ | |
${{env.PR_NUMBER}} >/dev/null 2>&1 || ADD_COMMENT=false | |
if $ADD_COMMENT ; then | |
echo "Adding CPR comment" | |
gh pr comment --repo ${{github.repository}} \ | |
-b "${CHERRY_PICK_REMINDER}" ${{env.PR_NUMBER}} | |
else | |
echo "CPR comment already present" | |
fi | |
- name: Set Labels | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh pr edit --repo ${{github.repository}} \ | |
--remove-label ${{vars.TEST_CHECKS_PASSED_LABEL}} \ | |
--remove-label ${{vars.TEST_CHECKS_FAILED_LABEL}} \ | |
--remove-label ${{vars.TEST_GATES_PASSED_LABEL}} \ | |
--remove-label ${{vars.TEST_GATES_FAILED_LABEL}} \ | |
--remove-label ${{vars.CHERRY_PICK_CHECKS_PASSED_LABEL}} \ | |
--remove-label ${{vars.CHERRY_PICK_CHECKS_FAILED_LABEL}} \ | |
--remove-label ${{vars.CHERRY_PICK_GATES_PASSED_LABEL}} \ | |
--remove-label ${{vars.CHERRY_PICK_GATES_FAILED_LABEL}} \ | |
--add-label ${{vars.TESTING_IN_PROGRESS}} \ | |
${{env.PR_NUMBER}} || : | |
- name: Run Unit Tests | |
id: rununittests | |
uses: asterisk/asterisk-ci-actions/TestsuiteUnitComposite@main | |
with: | |
asterisk_repo: ${{env.ASTERISK_REPO}} | |
testsuite_repo: ${{env.TESTSUITE_REPO}} | |
pr_number: ${{env.PR_NUMBER}} | |
base_branch: ${{env.BRANCH}} | |
modules_blacklist: ${{env.MODULES_BLACKLIST}} | |
github_token: ${{secrets.GITHUB_TOKEN}} | |
unittest_command: ${{vars.UNITTEST_COMMAND}} | |
- name: Add Checks Passed Label | |
if: ${{ success() }} | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh pr edit --repo ${{github.repository}} \ | |
--add-label ${{vars.TEST_CHECKS_PASSED_LABEL}} \ | |
${{env.PR_NUMBER}} || : | |
- name: Publish Result | |
if: always() | |
env: | |
RESULT: ${{ steps.rununittests.outcome }} | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh pr edit --repo ${{github.repository}} \ | |
--remove-label ${{vars.TESTING_IN_PROGRESS}} \ | |
${{env.PR_NUMBER}} || : | |
case $RESULT in | |
success) | |
gh pr edit --repo ${{github.repository}} \ | |
--add-label ${{vars.TEST_CHECKS_PASSED_LABEL}} \ | |
${{env.PR_NUMBER}} || : | |
exit 0 | |
;; | |
*) | |
gh pr edit --repo ${{github.repository}} \ | |
--add-label ${{vars.TEST_CHECKS_FAILED_LABEL}} \ | |
${{env.PR_NUMBER}} || : | |
exit 1 | |
;; | |
esac |