## Description - Fix syntax error in ci-merge-check ## Type of change - ci-merge-check.yml ## How Has This Been Tested? - Github actions ## Checklist: ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test
110 lines
5.3 KiB
YAML
110 lines
5.3 KiB
YAML
on:
|
|
#This workflow is only triggered by the ok to test command dispatch
|
|
repository_dispatch:
|
|
types: [ ci-merge-check-command ]
|
|
|
|
jobs:
|
|
ci-merge-check:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
# This step creates a comment on the PR with a link to this workflow run.
|
|
- name: Add a comment on the PR with link to workflow run
|
|
uses: peter-evans/create-or-update-comment@v2
|
|
with:
|
|
issue-number: ${{ github.event.client_payload.pull_request.number }}
|
|
body: |
|
|
Merge check is running at: <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}>
|
|
PR: ${{ github.event.client_payload.pull_request.number }}
|
|
|
|
- name: Find the latest workflow run comment
|
|
uses: peter-evans/find-comment@v2
|
|
id: find-comment
|
|
with:
|
|
issue-number: ${{ github.event.client_payload.pull_request.number }}
|
|
body-includes: 'Appsmith External Integration Test Workflow'
|
|
comment-author: github-actions[bot]
|
|
direction: last
|
|
|
|
- name: Get the workflow run_id
|
|
id: workflow
|
|
run: |
|
|
echo "run_id=$(echo '${{ steps.find-comment.outputs.comment-body }}' | grep -o 'runs/[0-9]\+' | cut -d/ -f2)" >> $GITHUB_OUTPUT
|
|
|
|
- name: Get ci-test-result status from the run_id
|
|
id: ci-test-result-status
|
|
run: |
|
|
run_status=`curl --silent https://api.github.com/repos/appsmithorg/appsmith/actions/runs/${{steps.workflow.outputs.run_id}}/jobs?per_page=100|jq -r '[ .jobs[] | select(.name | contains("ci-test-result")) | .conclusion ]'|grep -v '\[\|\]'|sed "s/\"//g"|sed "s/ //g"`
|
|
echo "run_status=$run_status" >> $GITHUB_OUTPUT
|
|
|
|
- name: get status-checks from pr
|
|
id: pr_status_check
|
|
run: |
|
|
status_link="https://api.github.com/repos/appsmithorg/appsmith/statuses/${{github.event.client_payload.pull_request.head.sha}}"
|
|
curl --silent "$status_link"|jq -r '.[]'|jq -r 'select(.state | contains("success") | not) | .context' >> ~/check1
|
|
echo "status=`grep -c -v 'cypress\|Vercel\|DeepSource' ~/check1`" >> $GITHUB_OUTPUT
|
|
|
|
- name: get status-checks from check suite
|
|
id: suite_status_check
|
|
run: |
|
|
check_runs_link="https://api.github.com/repos/appsmithorg/appsmith/commits/${{github.event.client_payload.pull_request.head.sha}}/check-runs"
|
|
curl --silent "$check_runs_link"|jq -r '.check_runs[] | select(.conclusion | contains("success") | not ) | .name' >> ~/check2
|
|
echo "status1=`grep -c 'Check for Test Plan Approved label' ~/check2`" >> $GITHUB_OUTPUT
|
|
curl --silent "$check_runs_link"|jq -r '.check_runs[] | .name' >> ~/check3
|
|
echo "status2=`grep -c 'ci-test-result' ~/check3`" >> $GITHUB_OUTPUT
|
|
|
|
- name: Verify all the checks
|
|
id: verify_checks
|
|
run: |
|
|
if [ "${{ steps.ci-test-result-status.outputs.run_status }}" == "failure" ]; then
|
|
echo "msg=Looks like there are some Cypress failures. Can't Merge" >> $GITHUB_OUTPUT
|
|
exit 1
|
|
elif [ ${{ steps.suite_status_check.outputs.status2 }} == 0 ]; then
|
|
echo "msg=Looks like you forgot to run /ok-to-test on the latest commit. Can't Merge" >> $GITHUB_OUTPUT
|
|
exit 1
|
|
elif [ ${{ steps.pr_status_check.outputs.status }} != 0 ]; then
|
|
echo "msg=There's merge freeze. Can't Merge, please try after merge-freeze is lifted" >> $GITHUB_OUTPUT
|
|
exit 1
|
|
elif [ ${{ steps.suite_status_check.outputs.status1 }} == 0 ]; then
|
|
echo "msg=Hurray!🎉 Proceeding to Merge!!!" >> $GITHUB_OUTPUT
|
|
exit 0
|
|
elif [ ${{ steps.suite_status_check.outputs.status1 }} == 1 ]; then
|
|
echo "msg=Either get 'Test Plan Approved' or 'skip-testPlan' added and try again!" >> $GITHUB_OUTPUT
|
|
exit 1
|
|
else
|
|
echo "msg=Some checks have failed. Can't merge" >> $GITHUB_OUTPUT
|
|
exit 1
|
|
fi
|
|
|
|
- name: Add a comment on the PR after all checks
|
|
if: always()
|
|
uses: peter-evans/create-or-update-comment@v2
|
|
with:
|
|
issue-number: ${{ github.event.client_payload.pull_request.number }}
|
|
body: |
|
|
${{steps.verify_checks.outputs.msg}}
|
|
|
|
- name: Auto merge if above checks are success and have 1 approval
|
|
if: success()
|
|
id: automerge
|
|
uses: "pascalgn/automerge-action@v0.15.5"
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
PULL_REQUEST: ${{ github.event.client_payload.pull_request.number }}
|
|
MERGE_REQUIRED_APPROVALS: 1
|
|
|
|
- name: Add comment once merge is success-full
|
|
if: steps.automerge.outputs.mergeResult == 'merged'
|
|
uses: peter-evans/create-or-update-comment@v2
|
|
with:
|
|
issue-number: ${{ github.event.client_payload.pull_request.number }}
|
|
body: |
|
|
Pull request ${{ steps.automerge.outputs.pullRequestNumber }} Auto-merged!
|
|
|
|
- name: Comment if it is not merged
|
|
if: steps.automerge.outputs.mergeResult != 'merged'
|
|
uses: peter-evans/create-or-update-comment@v2
|
|
with:
|
|
issue-number: ${{ github.event.client_payload.pull_request.number }}
|
|
body: |
|
|
Please try /ci-merge-check after at-least 1 peer approval. Can't merge this now.
|