From fde3d1e185c1baf78b55f13915efb839856d81f7 Mon Sep 17 00:00:00 2001 From: yatinappsmith <84702014+yatinappsmith@users.noreply.github.com> Date: Fri, 24 Feb 2023 16:54:51 +0530 Subject: [PATCH] ci: Add ci test check command (#20672) ## Description Add ci test check command Fixes # (issue) Media ## Type of change - New feature (non-breaking change which adds functionality) ## How Has This Been Tested? - Manual ### Test Plan ### Issues raised during DP testing ## Checklist: ### Dev activity - [X] My code follows the style guidelines of this project - [X] I have performed a self-review of my own code - [X] I have commented my code, particularly in hard-to-understand areas - [x] I have made corresponding changes to the documentation - [X] My changes generate no new warnings - [X] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [X] PR is being merged under a feature flag ### 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 --------- Co-authored-by: Aishwarya-U-R <91450662+Aishwarya-U-R@users.noreply.github.com> Co-authored-by: Aishwarya UR --- .github/workflows/ci-merge-check.yml | 56 ++++++++++++++++++++++++++++ .github/workflows/ok-to-test.yml | 1 + 2 files changed, 57 insertions(+) create mode 100644 .github/workflows/ci-merge-check.yml diff --git a/.github/workflows/ci-merge-check.yml b/.github/workflows/ci-merge-check.yml new file mode 100644 index 0000000000..2e57b5d88d --- /dev/null +++ b/.github/workflows/ci-merge-check.yml @@ -0,0 +1,56 @@ +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: | + found ci-merge-check ${{ github.event.client_payload.pull_request.number }} + + # Timestamp will be used to create cache key + - name: timestamp + run: echo "timestamp=$(date +'%Y-%m-%dT%H:%M:%S')" >> $GITHUB_OUTPUT + + - name: Check ci test result + run: | + set -o pipefail + export retval=0 + export prnumber=${{ github.event.client_payload.pull_request.number }} + echo "prnumber=$prnumber" + workflowid=`curl --silent https://api.github.com/repos/appsmithorg/appsmith/issues/$prnumber/comments|grep "Tests running at:"|grep -Eo 'https://github[^ >]+'|tail -1|awk -F/ '{print $8}'` + export retval=`expr $retval + $?` + echo "workflowid=$workflowid" + runsatatus=`curl --silent https://api.github.com/repos/appsmithorg/appsmith/actions/runs/$workflowid/jobs?per_page=100|jq -r '[ .jobs[] | select(.name | contains("ci-test-result")) | .conclusion ]'|grep -v '\[\|\]'|sed "s/\"//g"|sed "s/ //g"` + export retval=`expr $retval + $?` + echo "runsatatus=$runsatatus" + statuslink=`curl --silent https://api.github.com/repos/appsmithorg/appsmith/pulls/$prnumber|jq -r '[ ._links |.statuses | .href]'|grep http|sed "s/\"//g"|sed "s/ //g"` + export retval=`expr $retval + $?` + echo $retval + echo "statuslink=$statuslink" + pendingchecks=`curl --silent $statuslink|jq -r '.[]'|jq -r '[ select(.state | contains("pending")) | .context ]'` + set +o pipefail + pendingchecks=`echo $pendingchecks|grep -v '\[\|\]'|grep -v 'cypress\|Vercel\|DeepSource'|wc -l` + export retval=`expr $retval + $pendingchecks` + echo $retval + exit $retval + + #- name: automerge + # uses: "pascalgn/automerge-action@v0.15.5" + # env: + # GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + + - name: Add a comment on the PR with status + if: failure() + uses: peter-evans/create-or-update-comment@v2 + with: + issue-number: ${{ github.event.client_payload.pull_request.number }} + body: | + Won't merge.Other checks failing. diff --git a/.github/workflows/ok-to-test.yml b/.github/workflows/ok-to-test.yml index 7f1da6561a..34818597ce 100644 --- a/.github/workflows/ok-to-test.yml +++ b/.github/workflows/ok-to-test.yml @@ -30,4 +30,5 @@ jobs: commands: | ok-to-test perf-test + ci-merge-check permission: write