ci: Added ci option for snapshot (#38261)
## Description Adding workflow for updating snapshot with github CI. Fixes #[`36419` ](https://github.com/appsmithorg/appsmith/issues/36419) ## Automation /ok-to-test tags="@tag.Sanity" ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/12426577557> > Commit: 2660c07257f3d78f64371cedc2ee82f247f9d76d > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=12426577557&attempt=2" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Sanity` > Spec: > <hr>Fri, 20 Dec 2024 07:02:16 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced CI workflow with new input parameters for snapshot updates and spec execution. - Added steps for uploading existing and new snapshot data during Cypress tests. - **Bug Fixes** - Improved artifact management and error handling in the CI process. - **Documentation** - Added comments for better understanding of workflow logic and input parameters. - **Refactor** - Streamlined job execution logic and conditional checks for test reruns. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
parent
71c51712da
commit
d1cff32d2b
23
.github/workflows/build-client-server-count.yml
vendored
23
.github/workflows/build-client-server-count.yml
vendored
|
|
@ -17,6 +17,8 @@ jobs:
|
|||
matrix_count: ${{steps.matrix.outputs.matrix_count}}
|
||||
run_count: ${{ steps.countArgs.outputs.run_count }}
|
||||
is-pg-build: ${{steps.args.outputs.is-pg-build}}
|
||||
update_snapshot: ${{steps.args.outputs.update_snapshot}}
|
||||
specs_to_run: ${{steps.args.outputs.specs_to_run}}
|
||||
steps:
|
||||
- name: Checkout the head commit of the branch
|
||||
uses: actions/checkout@v4
|
||||
|
|
@ -38,6 +40,21 @@ jobs:
|
|||
runId=$((checkArg + 0))
|
||||
echo "runId=$runId" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
# Check for update_snapshot
|
||||
checkArg=${{ github.event.client_payload.slash_command.args.named.update_snapshot }}
|
||||
if [[ -z "$checkArg" ]]; then
|
||||
echo "update_snapshot=false" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "update_snapshot=$checkArg" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
# Check for spec file
|
||||
checkArg=${{ github.event.client_payload.slash_command.args.named.specs_to_run }}
|
||||
if [[ -z "$checkArg" ]]; then
|
||||
echo "specs_to_run=''" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "specs_to_run=$checkArg" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Set run count
|
||||
id: countArgs
|
||||
|
|
@ -97,7 +114,7 @@ jobs:
|
|||
body: |
|
||||
Tests running at: <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}>.
|
||||
[Cypress dashboard](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)
|
||||
PR: #${{ fromJson(steps.args.outputs.pr) }}.
|
||||
PR: #${{ fromJson(steps.args.outputs.pr) }} with spec: ${{steps.args.outputs.specs_to_run}} .
|
||||
|
||||
server-build:
|
||||
name: server-build
|
||||
|
|
@ -149,6 +166,8 @@ jobs:
|
|||
with:
|
||||
pr: ${{fromJson(needs.file-check.outputs.pr)}}
|
||||
run_count: ${{fromJson(needs.file-check.outputs.run_count)}}
|
||||
update_snapshot: ${{fromJson(needs.file-check.outputs.update_snapshot)}}
|
||||
specs_to_run: ${{needs.file-check.outputs.specs_to_run}}
|
||||
|
||||
|
||||
ci-test-limited-existing-docker-image:
|
||||
|
|
@ -162,6 +181,8 @@ jobs:
|
|||
pr: ${{fromJson(needs.file-check.outputs.pr)}}
|
||||
previous-workflow-run-id: ${{ fromJson(needs.file-check.outputs.runId) }}
|
||||
run_count: ${{fromJson(needs.file-check.outputs.run_count)}}
|
||||
update_snapshot: ${{fromJson(needs.file-check.outputs.update_snapshot)}}
|
||||
specs_to_run: ${{needs.file-check.outputs.specs_to_run}}
|
||||
|
||||
ci-test-limited-result:
|
||||
needs: [file-check, ci-test-limited]
|
||||
|
|
|
|||
54
.github/workflows/ci-test-limited-with-count.yml
vendored
54
.github/workflows/ci-test-limited-with-count.yml
vendored
|
|
@ -19,6 +19,16 @@ on:
|
|||
required: false
|
||||
type: number
|
||||
default: 1
|
||||
update_snapshot:
|
||||
description: 'Give option to update snapshot (true/false)'
|
||||
required: false
|
||||
type: boolean
|
||||
default: false
|
||||
specs_to_run:
|
||||
description: 'Cypress spec file(s) to run'
|
||||
required: false
|
||||
type: string
|
||||
|
||||
workflow_call:
|
||||
inputs:
|
||||
pr:
|
||||
|
|
@ -35,6 +45,15 @@ on:
|
|||
required: false
|
||||
type: number
|
||||
default: 1
|
||||
update_snapshot:
|
||||
description: 'Give option to update snapshot (true/false)'
|
||||
required: false
|
||||
type: boolean
|
||||
default: false
|
||||
specs_to_run:
|
||||
description: 'Cypress spec file(s) to run'
|
||||
required: false
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
ci-test-limited:
|
||||
|
|
@ -111,10 +130,18 @@ jobs:
|
|||
else
|
||||
echo "rerun=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Upload existing snapshot data
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: cypress-existing-compare-snapshots
|
||||
path: ${{ github.workspace }}/app/client/cypress/snapshots
|
||||
overwrite: true
|
||||
|
||||
# Get specs to run
|
||||
- name: Get specs to run
|
||||
if: steps.run_result.outputs.run_result != 'success' && steps.run_result.outputs.run_result != 'failedtest'
|
||||
if: ${{ (inputs.specs_to_run == '' || inputs.specs_to_run == null) && steps.run_result.outputs.run_result != 'success' && steps.run_result.outputs.run_result != 'failedtest' }}
|
||||
run: |
|
||||
specs_to_run=""
|
||||
while IFS= read -r line
|
||||
|
|
@ -349,10 +376,19 @@ jobs:
|
|||
NODE_ENV: development
|
||||
run: |
|
||||
cd app/client
|
||||
npx cypress-repeat-pro run -n ${{ inputs.run_count }} --force \
|
||||
--spec ${{ env.specs_to_run }} \
|
||||
if [[ "${{ inputs.update_snapshot }}" == "true" ]]; then
|
||||
echo "Running Cypress with snapshot updates..."
|
||||
CYPRESS_updateSnapshots=true npx cypress-repeat-pro run -n "${{ inputs.run_count }}" --force \
|
||||
--spec "${{ inputs.specs_to_run }}" \
|
||||
--config-file "cypress_ci_custom.config.ts" \
|
||||
--browser ${{ env.BROWSER_PATH }}
|
||||
--browser "${{ env.BROWSER_PATH }}"
|
||||
else
|
||||
echo "Running Cypress tests without snapshot updates..."
|
||||
npx cypress-repeat-pro run -n "${{ inputs.run_count }}" --force \
|
||||
--spec "${{ env.specs_to_run }}" \
|
||||
--config-file "cypress_ci_custom.config.ts" \
|
||||
--browser "${{ env.BROWSER_PATH }}"
|
||||
fi
|
||||
cat cy-repeat-summary.txt
|
||||
# Define the path for the failure flag file
|
||||
FAILURE_FLAG_FILE="ci_test_status.txt"
|
||||
|
|
@ -453,9 +489,17 @@ jobs:
|
|||
if: always()
|
||||
with:
|
||||
name: server-logs
|
||||
path: app/server/server-logs.log
|
||||
path: ${{ github.workspace }}/app/server/server-logs.log
|
||||
overwrite: true
|
||||
|
||||
- name: Upload new compared snapshot data
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: cypress-new-compare-snapshots
|
||||
path: ${{ github.workspace }}/app/client/cypress/snapshots
|
||||
overwrite: true
|
||||
|
||||
# Set status = success
|
||||
- name: Save the status of the run
|
||||
run: |
|
||||
|
|
|
|||
2
.github/workflows/ci-test-limited.yml
vendored
2
.github/workflows/ci-test-limited.yml
vendored
|
|
@ -418,7 +418,7 @@ jobs:
|
|||
if: failure()
|
||||
with:
|
||||
name: server-logs
|
||||
path: app/server/server-logs.log
|
||||
path: ${{ github.workspace }}/app/server/server-logs.log
|
||||
overwrite: true
|
||||
|
||||
# Set status = success
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user