ci: Make Cypress results show up in body as well (#31631)

This commit is contained in:
Nidhi 2024-03-09 09:55:50 +05:30 committed by GitHub
parent cd8cefd965
commit 3b10f233cd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 44 additions and 96 deletions

View File

@ -170,109 +170,58 @@ jobs:
echo "$new_failed_spec_env" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Add a comment on the PR with new CI failures
- name: Modify test response in the PR with new CI failures
if: needs.ci-test.result != 'success' && steps.combine_ci.outputs.specs_failed == '1'
uses: peter-evans/create-or-update-comment@v3
uses: nefrob/pr-description@v1.1.1
with:
issue-number: ${{ github.event.number }}
body: |
Workflow run: <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}>.
Commit: `${{ github.event.client_payload.slash_command.args.named.sha }}`.
Cypress dashboard: <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=${{ github.run_id }}&attempt=${{ github.run_attempt }}&selectiontype=test&testsstatus=failed&specsstatus=fail" target="_blank"> Click here!</a>
The following are new failures, please fix them before merging the PR: ${{env.new_failed_spec_env}}
To know the list of identified flaky tests - <a href="https://internal.appsmith.com/app/cypress-dashboard/identified-flaky-tests-65890b3c81d7400d08fa9ee3?branch=master" target="_blank">Refer here</a>
content: |
################# _Do Not Edit This Area_ #################
#### ok-to-test Response:
Workflow run: <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}>.
Commit: `${{ github.event.pull_request.head.sha }}`.
Cypress dashboard: <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=${{ github.run_id }}&attempt=${{ github.run_attempt }}&selectiontype=test&testsstatus=failed&specsstatus=fail" target="_blank"> Click here!</a>
The following are new failures, please fix them before merging the PR: ${{env.new_failed_spec_env}}
To know the list of identified flaky tests - <a href="https://internal.appsmith.com/app/cypress-dashboard/identified-flaky-tests-65890b3c81d7400d08fa9ee3?branch=master" target="_blank">Refer here</a>
- name: Add a comment on the PR when ci-test is failed but no specs found
###################################################
regex: "################# _Do Not Edit This Area_ #################.*?###################################################"
regexFlags: ims
token: ${{ secrets.GITHUB_TOKEN }}
- name: Modify test response in the PR when ci-test is failed but no specs found
if: needs.ci-test.result != 'success' && steps.combine_ci.outputs.specs_failed == '0'
uses: peter-evans/create-or-update-comment@v3
uses: nefrob/pr-description@v1.1.1
with:
issue-number: ${{ github.event.number }}
body: |
Workflow run: <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}>.
Commit: `${{ github.event.client_payload.slash_command.args.named.sha }}`.
Cypress dashboard url: <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=${{ github.run_id }}&attempt=${{ github.run_attempt }}" target="_blank">Click here!</a>
It seems like **no tests ran** 😔. We are not able to recognize it, please check workflow <a href="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" target="_blank">here.</a>
content: |
################# _Do Not Edit This Area_ #################
#### ok-to-test Response:
Workflow run: <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}>.
Commit: `${{ github.event.pull_request.head.sha }}`.
Cypress dashboard url: <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=${{ github.run_id }}&attempt=${{ github.run_attempt }}" target="_blank">Click here!</a>
It seems like **no tests ran** 😔. We are not able to recognize it, please check workflow <a href="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" target="_blank">here.</a>
- name: Add a comment on the PR when ci-test is success
###################################################
regex: "################# _Do Not Edit This Area_ #################.*?###################################################"
regexFlags: ims
token: ${{ secrets.GITHUB_TOKEN }}
- name: Modify test response in the PR when ci-test is success
if: needs.ci-test.result == 'success' && steps.combine_ci.outputs.specs_failed == '0'
uses: peter-evans/create-or-update-comment@v3
uses: nefrob/pr-description@v1.1.1
with:
issue-number: ${{ github.event.number }}
body: |
Workflow run: <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}>.
Commit: `${{ github.event.client_payload.slash_command.args.named.sha }}`.
Cypress dashboard url: <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=${{ github.run_id }}&attempt=${{ github.run_attempt }}" target="_blank">Click here!</a>
All cypress tests have passed 🎉🎉🎉
content: |
################# _Do Not Edit This Area_ #################
#### ok-to-test Response:
Workflow run: <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}>.
Commit: `${{ github.event.pull_request.head.sha }}`.
Cypress dashboard url: <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=${{ github.run_id }}&attempt=${{ github.run_attempt }}" target="_blank">Click here!</a>
All cypress tests have passed 🎉🎉🎉
###################################################
regex: "################# _Do Not Edit This Area_ #################.*?###################################################"
regexFlags: ims
token: ${{ secrets.GITHUB_TOKEN }}
- name: Check ci-test set status
if: needs.ci-test.result != 'success'
run: exit 1
package:
needs: [ci-test]
runs-on: ubuntu-latest
defaults:
run:
working-directory: app/client
# Run this job only if all the previous steps are a success and the reference if the release or master branch
if: success() && (github.ref == 'refs/heads/release' || github.ref == 'refs/heads/master')
steps:
# Update check run called "package"
- name: Mark package job as complete
uses: actions/github-script@v6
id: update-check-run
if: ${{ always() }}
env:
run_id: ${{ github.run_id }}
repository: ${{ github.repository }}
number: ${{ github.event.number }}
job: ${{ github.job }}
# Conveniently, job.status maps to https://developer.github.com/v3/checks/runs/#update-a-check-run
conclusion: ${{ job.status }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { data: pull } = await github.rest.pulls.get({
...context.repo,
pull_number: process.env.number
});
const ref = pull.head.sha;
const { data: checks } = await github.rest.checks.listForRef({
...context.repo,
ref
});
const check = checks.check_runs.filter(c => c.name === process.env.job);
if(check.length == 0) {
const head_sha = pull.head.sha;
const { data: completed_at } = await github.rest.checks.create({
owner: context.repo.owner,
repo: context.repo.repo,
head_sha: head_sha,
name: process.env.job,
status: 'completed',
conclusion: process.env.conclusion,
output: {
title: "Package result for ok to test",
summary: "https://github.com/" + process.env.repository + "/actions/runs/" + process.env.run_id
}
});
return completed_at;
} else {
const { data: result } = await github.rest.checks.update({
...context.repo,
check_run_id: check[0].id,
status: 'completed',
conclusion: process.env.conclusion,
output: {
title: "Package result for ok to test",
summary: "https://github.com/" + process.env.repository + "/actions/runs/" + process.env.run_id
}
});
return result;
}
run: exit 1

View File

@ -141,7 +141,6 @@ jobs:
regex: "################# _Do Not Edit This Area_ #################.*?###################################################"
regexFlags: ims
token: ${{ secrets.GITHUB_TOKEN }}
uses: peter-evans/create-or-update-comment@v3
# Call the workflow to run Cypress tests
perform-test: