PromucFlow_constructor/.github/workflows/pr-automation.yml
Shrikant Sharat Kandula 3264ac3725
ci: Support for limited tests run from PR description (#34736)
Specify the specs we want to run, in a plain code fence, where the first
line has to exactly be `/test`. The remaining lines have to be one spec
file per line.

Like this:

```
/test
cypress/e2e/Regression/ClientSide/Fork/ForkApplication_spec.ts
cypress/e2e/Regression/ClientSide/JSLibrary/Library_spec.ts
```

1. It's not possible to run with tags and specs and the same time. This
will need a slightly larger effort. But we'll get there.
2. The status message shows spec files like they are space-separated,
and isn't very easy to read. Don't take it too seriously yet, we'll
improve.
3. Globs _should_ also work fine. The `spec` content, _almost_ directly
lands into the `--spec` argument of Cypress. See docs at
https://docs.cypress.io/guides/guides/command-line#cypress-run-spec-lt-spec-gt.
4. Multiple runners is disabled for this, have to solve it separately.
The `ci-test-limited.yml` also doesn't do multiple runners either.

<!-- This is an auto-generated comment: Cypress test results  -->
> [!WARNING]
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/9803353429>
> Commit: e99ae387c9a239ae51155af45977c285474cfbaf
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9803353429&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: 
> Spec: cypress/e2e/Regression/ClientSide/Fork/ForkApplication_spec.ts
> cypress/e2e/Regression/ClientSide/JSLibrary/Library_spec.ts
> 
> It seems like **no tests ran** 😔. We are not able to recognize it,
please check <a
href="https://github.com/appsmithorg/appsmith/actions/runs/9803353429"
target="_blank">workflow here</a>.
> <hr>Fri, 05 Jul 2024 05:20:23 UTC
<!-- end of auto-generated comment: Cypress test results  -->


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Chores**
- Enhanced GitHub Actions workflows to improve test specification
handling and reporting.
- Refactored tag parsing logic in scripts for more accurate and
informative outputs.


<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-07-08 21:28:07 +05:30

84 lines
3.1 KiB
YAML

name: PR Automation test suite
on:
pull_request:
branches:
- release
- pg
types:
- labeled
jobs:
parse-tags:
runs-on: ubuntu-latest
if: github.event.label.name == 'ok-to-test'
permissions:
pull-requests: write
defaults:
run:
shell: bash
outputs:
tags: ${{ steps.parseTags.outputs.tags }}
spec: ${{ steps.parseTags.outputs.spec }}
matrix: ${{ steps.checkAll.outputs.matrix }}
steps:
# Checkout the code in the current branch in case the workflow is called because of a branch push event
- name: Checkout the head commit of the branch
uses: actions/checkout@v4
with:
repository: appsmithorg/appsmith
# Reads the PR description to retrieve the /ok-to-test or, if that's absent, the /test command
- name: Read tags from PR description
uses: actions/github-script@v7
id: parseTags
env:
NODE_PATH: "${{ github.workspace }}/.github/workflows/scripts"
with:
script: |
require("test-tag-parser.js")({core, context, github})
# In case of a run with all test cases, allocate a larger matrix
- name: Check if @tag.All is present in tags
id: checkAll
run: |
if [[ -n "${{ steps.parseTags.outputs.spec }}" ]]; then
echo "matrix=[0]" >> $GITHUB_OUTPUT
else
tags="${{ steps.parseTags.outputs.tags }}"
if [[ $tags == "@tag.All" ]]; then
echo "matrix=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59]" >> $GITHUB_OUTPUT
else
echo "matrix=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]" >> $GITHUB_OUTPUT
fi
fi
# In case of a runnable command, update the PR with run details
- name: Add test response with link to workflow run
uses: actions/github-script@v7
env:
NODE_PATH: "${{ github.workspace }}/.github/workflows/scripts"
BODY: |
Your tests are running.
Tests running at: <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}>
Commit: ${{ github.event.pull_request.head.sha }}
Workflow: `${{ github.workflow }}`
Tags: `${{ steps.parseTags.outputs.tags }}`
Spec: `${{ steps.parseTags.outputs.spec }}`
with:
script: |
require("write-cypress-status.js")({core, context, github}, "important", process.env.BODY)
# Call the workflow to run Cypress tests
perform-test:
needs: [parse-tags]
if: success()
uses: ./.github/workflows/pr-cypress.yml
secrets: inherit
with:
tags: ${{ needs.parse-tags.outputs.tags}}
spec: ${{ needs.parse-tags.outputs.spec}}
matrix: ${{ needs.parse-tags.outputs.matrix}}
is-pg-build: ${{ github.event.pull_request.base.ref == 'pg' }}