chore: Added capability of running ITs using ok-to-test (#38355)

## Description
> [!TIP]  
> _Add a TL;DR when the description is longer than 500 words or
extremely technical (helps the content, marketing, and DevRel team)._
>
> _Please also include relevant motivation and context. List any
dependencies that are required for this change. Add links to Notion,
Figma or any other documents that might be relevant to the PR._


Fixes #`Issue Number`  
_or_  
Fixes `Issue URL`
> [!WARNING]  
> _If no issue exists, please create an issue first, and check with the
maintainers if the issue is valid._

## Automation

/ok-to-test tags="@tag.Git" it=true

### 🔍 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/12548211703>
> Commit: 28ec34d9b20246ce54b7deab8e9fa8e136bbd7ff
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=12548211703&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Git`
> Spec:
> <hr>Mon, 30 Dec 2024 15:48:17 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No


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

- **New Features**
- Added optional integration tests trigger across multiple GitHub
Actions workflows
	- Enhanced test configuration and reporting mechanisms

- **Chores**
	- Updated workflow input parameters and descriptions
	- Improved test execution and artifact management

- **Documentation**
	- Added clarifying comments in test scripts about test prerequisites
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Nidhi 2025-01-01 15:30:29 +05:30 committed by GitHub
parent 8cd827754f
commit d718437b6a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 153 additions and 15 deletions

View File

@ -71,6 +71,7 @@ jobs:
shell: bash
outputs:
tags: ${{ steps.parseTags.outputs.tags }}
its: ${{ steps.parseTags.outputs.its }}
spec: ${{ steps.parseTags.outputs.spec }}
matrix: ${{ steps.checkAll.outputs.matrix }}
steps:
@ -129,6 +130,7 @@ jobs:
uses: ./.github/workflows/pr-cypress.yml
secrets: inherit
with:
its: ${{ needs.parse-tags.outputs.its}}
tags: ${{ needs.parse-tags.outputs.tags}}
spec: ${{ needs.parse-tags.outputs.spec}}
matrix: ${{ needs.parse-tags.outputs.matrix}}

View File

@ -3,6 +3,10 @@ name: Cypress test suite
on:
workflow_call:
inputs:
its:
required: false
type: string
default: "false"
tags:
required: true
type: string
@ -45,6 +49,15 @@ jobs:
with:
pr: ${{ github.event.number }}
server-it:
needs: [ server-build, rts-build ]
if: success() && inputs.its == 'true'
uses: ./.github/workflows/server-integration-tests.yml
secrets: inherit
with:
pr: ${{ github.event.number }}
is-pg-build: ${{ github.event.pull_request.base.ref == 'pg' }}
build-docker-image:
needs: [client-build, server-build, rts-build]
# Only run if the build step is successful
@ -69,7 +82,7 @@ jobs:
matrix: ${{ inputs.matrix }}
ci-test-result:
needs: [ci-test]
needs: [ci-test, server-it]
# Only run if the ci-test with matrices step is successful
if: always()
runs-on: ubuntu-latest

View File

@ -21,6 +21,7 @@ module.exports = function ({core, context, github}) {
}
core.setOutput("tags", parseResult.tags ?? "");
core.setOutput("its", parseResult.its ?? "");
core.setOutput("spec", parseResult.spec ?? "");
}
@ -28,18 +29,29 @@ function parseTags(body) {
const allTags = require(process.env.GITHUB_WORKSPACE + "/app/client/cypress/tags.js").Tag;
// "/ok-to-test" matcher. Takes precedence over the "/test" matcher.
const strictMatch = body.match(/^\/ok-to-test tags="(.+?)"/m)?.[1];
if (strictMatch) {
if (strictMatch === "@tag.All") {
return { tags: strictMatch };
}
const parts = strictMatch.split(/\s*,\s*/);
for (const part of parts) {
if (!allTags.includes(part)) {
throw new Error("Unknown tag: " + part);
const okToTestPattern = body.match(/^(\/ok-to-test) tags="(.+?)"( it=true)?/m);
if (okToTestPattern?.[1]) {
var response = {};
const tagsMatch = okToTestPattern?.[2];
if (tagsMatch) {
if (tagsMatch === "@tag.All") {
response = { tags: tagsMatch };
} else {
const parts = tagsMatch.split(/\s*,\s*/);
for (const part of parts) {
if (!allTags.includes(part)) {
throw new Error("Unknown tag: " + part);
}
}
response = { tags: tagsMatch };
}
}
return { tags: strictMatch };
const itsMatch = okToTestPattern?.[3];
if (itsMatch) {
response = { ...response, its: 'true' };
}
return response;
}
// "/test" code-fence matcher.

View File

@ -5,20 +5,20 @@ on:
workflow_call:
inputs:
pr:
description: "This is the PR number in case the workflow is being called in a pull request"
description: "PR number for the workflow"
required: false
type: number
skip-tests:
description: "This is a boolean value in case the workflow is being called in build deploy-preview"
description: "Skip tests flag"
required: false
type: string
default: "false"
branch:
description: "This is the branch to be used for the build."
description: "Branch for the build"
required: false
type: string
is-pg-build:
description: "This is a boolean value in case the workflow is being called for a PG build"
description: "Flag for PG build"
required: false
type: string
default: "false"
@ -210,6 +210,7 @@ jobs:
fi
args=()
if [[ "${{ steps.run_result.outputs.run_result }}" == "failedtest" ]]; then
failed_tests="${{ steps.failed_tests.outputs.tests }}"
args+=("-DfailIfNoTests=false" "-Dsurefire.failIfNoSpecifiedTests=false" "-Dtest=${failed_tests}")

View File

@ -0,0 +1,108 @@
name: Server Integrations Tests Workflow
on:
# This line enables manual triggering of this workflow.
workflow_dispatch:
workflow_call:
inputs:
pr:
description: "This is the PR number in case the workflow is being called in a pull request"
required: false
type: number
is-pg-build:
description: "Flag for PG build"
required: false
type: string
default: "false"
jobs:
run-tests:
runs-on: ubuntu-latest-8-cores
if: |
github.event.pull_request.head.repo.full_name == github.repository ||
github.event_name == 'workflow_dispatch'
defaults:
run:
shell: bash
# Service containers to run with this job. Required for running tests
services:
# Label used to access the service container
redis:
# Docker Hub image for Redis
image: redis
ports:
# Opens tcp port 6379 on the host and service container
- 6379:6379
steps:
# Check out merge commit
- name: Fork based /ok-to-test checkout
if: inputs.pr != 0
uses: actions/checkout@v4
with:
ref: "refs/pull/${{ inputs.pr }}/merge"
# 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
if: inputs.pr == 0
uses: actions/checkout@v4
# Setup Java
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "17"
- name: Conditionally start PostgreSQL
if: |
inputs.is-pg-build == 'true'
run: |
docker run --name appsmith-pg -p 5432:5432 -d -e POSTGRES_PASSWORD=password postgres:alpine postgres -N 1500
- name: Download the server build artifact
uses: actions/download-artifact@v4
with:
name: server-build
path: app/server/dist/
- name: Download the rts build artifact
uses: actions/download-artifact@v4
with:
name: rts-dist
path: app/client/packages/rts/dist
- name: Un-tar the rts folder
run: |
tar -xvf app/client/packages/rts/dist/rts-dist.tar -C app/client/packages/rts/
echo "Cleaning up the rts tar files"
rm app/client/packages/rts/dist/rts-dist.tar
- name: Run rts using the untarred files
run: |
nohup -- node app/client/packages/rts/dist/bundle/server.js &
- name: Run only integration tests on server
env:
ACTIVE_PROFILE: test
APPSMITH_CLOUD_SERVICES_BASE_URL: "https://release-cs.appsmith.com"
APPSMITH_CLOUD_SERVICES_TEMPLATE_UPLOAD_AUTH: ${{ secrets.APPSMITH_CLOUD_SERVICES_TEMPLATE_UPLOAD_AUTH }}
APPSMITH_REDIS_URL: "redis://127.0.0.1:6379"
APPSMITH_ENCRYPTION_PASSWORD: "password"
APPSMITH_ENCRYPTION_SALT: "salt"
APPSMITH_ENVFILE_PATH: /tmp/dummy.env
APPSMITH_VERBOSE_LOGGING_ENABLED: false
run: |
if [[ "${{ inputs.is-pg-build }}" == "true" ]]; then
export APPSMITH_DB_URL="postgresql://postgres:password@localhost:5432/postgres"
else
export APPSMITH_DB_URL="mongodb://localhost:27017/mobtools"
fi
args=()
# Run tests and capture logs
cd app/server
mvn verify -DskipUTs=true "${args[@]}" | tee mvn_integration_test.log

View File

@ -212,6 +212,8 @@ public class GitBranchesIT {
assertThat(autoCommitResponseDTO).isNotNull();
AutoCommitResponseDTO.AutoCommitResponse autoCommitProgress = autoCommitResponseDTO.getAutoCommitResponse();
// This check requires RTS to be running on your local since client side changes come in from there
// Please make sure to run RTS before triggering this test
assertThat(autoCommitProgress).isEqualTo(AutoCommitResponseDTO.AutoCommitResponse.PUBLISHED);
// Wait for auto-commit to complete