Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 3 commits into
base: release
Choose a base branch
from

Conversation

nidhi-nair
Copy link
Contributor

@nidhi-nair nidhi-nair commented Dec 24, 2024

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

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12486019294
Commit: 3807767
Cypress dashboard.
Tags: @tag.Git
Spec:


Tue, 24 Dec 2024 21:26:04 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

@nidhi-nair nidhi-nair requested review from sharat87 and a team as code owners December 24, 2024 14:18
Copy link
Contributor

coderabbitai bot commented Dec 24, 2024

Walkthrough

This pull request introduces enhancements to the CI/CD workflow and testing infrastructure across multiple files. The changes focus on improving test execution flexibility, workflow automation, and artifact management. The modifications span GitHub Actions workflows, Maven configuration, and test utility classes, with a primary goal of providing more granular control over test runs and streamlining the integration testing process.

Changes

File Change Summary
.github/workflows/pr-automation.yml Added new perform-it job with conditional execution based on its output
.github/workflows/scripts/test-tag-parser.js Enhanced tag parsing logic with more flexible regex matching and expanded response object
.github/workflows/server-build.yml Added its input parameter, updated test execution logic, improved error handling
app/server/appsmith-server/src/test/it/com/appsmith/server/git/templates/contexts/GitContext.java Added artifactType to ExtensionContext.Store
app/server/appsmith-server/src/test/utils/com/appsmith/server/git/GitServerInitializerExtension.java Replaced ApplicationService with ArtifactService, updated SSH key pair management
app/server/pom.xml Added test skipping properties, configured Maven plugins for flexible test execution

Sequence Diagram

sequenceDiagram
    participant PA as PR Automation Workflow
    participant ST as Tag Parser Script
    participant SB as Server Build Workflow
    
    PA->>ST: Parse PR Tags
    ST-->>PA: Return Tag Response
    PA->>SB: Trigger Build with Parameters
    SB->>SB: Conditional Test Execution
    SB-->>PA: Build and Test Results
Loading

Possibly Related PRs

Suggested Labels

skip-changelog, ok-to-test, CI, Test

Suggested Reviewers

  • sondermanish

Poem

🚀 Workflows dance, tests take flight,
Automation's magic, shining bright!
Parsing tags with regex might,
CI/CD pipeline, pure delight!
Code flows smooth, no more fright! 🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Dec 24, 2024
@nidhi-nair nidhi-nair added the ok-to-test Required label for CI label Dec 24, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
app/server/appsmith-server/src/test/utils/com/appsmith/server/git/GitServerInitializerExtension.java (1)

40-40: Ensure null-safety on the injected ArtifactService.

While Spring typically injects this service correctly, consider verifying that it is not null before use, especially for test scenarios.

.github/workflows/server-build.yml (1)

223-231: Remove trailing whitespace on line 223.

The test execution logic is correct, but there's a formatting issue.

-            
+
🧰 Tools
🪛 yamllint (1.35.1)

[error] 223-223: trailing spaces

(trailing-spaces)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c0d393a and 292b79d.

📒 Files selected for processing (6)
  • .github/workflows/pr-automation.yml (1 hunks)
  • .github/workflows/scripts/test-tag-parser.js (1 hunks)
  • .github/workflows/server-build.yml (3 hunks)
  • app/server/appsmith-server/src/test/it/com/appsmith/server/git/templates/contexts/GitContext.java (1 hunks)
  • app/server/appsmith-server/src/test/utils/com/appsmith/server/git/GitServerInitializerExtension.java (3 hunks)
  • app/server/pom.xml (3 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/pr-automation.yml

139-139: property "its" is not defined in object type {matrix: string; spec: string; tags: string}

(expression)


143-143: input "its" is typed as string by reusable workflow "./.github/workflows/server-build.yml". bool value cannot be assigned

(expression)


144-144: input "is-pg-build" is typed as string by reusable workflow "./.github/workflows/server-build.yml". bool value cannot be assigned

(expression)

🪛 yamllint (1.35.1)
.github/workflows/server-build.yml

[error] 223-223: trailing spaces

(trailing-spaces)

🔇 Additional comments (10)
app/server/appsmith-server/src/test/it/com/appsmith/server/git/templates/contexts/GitContext.java (1)

28-28: Storing the artifactType in the context store looks good.

This addition helps keep the artifact type readily accessible for downstream test extensions and setups.

app/server/appsmith-server/src/test/utils/com/appsmith/server/git/GitServerInitializerExtension.java (3)

4-4: Importing ArtifactService is appropriate.

Replacing ApplicationService with ArtifactService aligns with the move toward a dedicated artifact management approach.


59-59: Make sure the artifact type is present in the store.

If artifactType is missing or null, the subsequent SSH key generation may fail. Consider adding a fallback or appropriate error handling.


67-67: Verify the error handling of the createOrUpdateSshKeyPair call.

This call returns a reactive type. Ensure any exceptions are properly handled, e.g., logging or cleanup if the call fails.

app/server/pom.xml (4)

114-130: Unit test configuration is well-structured.

The maven-surefire-plugin is properly configured for unit tests with appropriate skip conditions and dependencies.


131-148: Integration test configuration is properly set up.

The maven-failsafe-plugin configuration correctly separates integration tests and includes necessary system properties.


46-48: LGTM! Test skip properties are well-structured.

The properties follow Maven conventions and provide granular control over test execution.

Let's verify these properties are used consistently across the project:

✅ Verification successful

Properties are correctly configured and used in the Maven build

The verification shows that the skip properties are used consistently within the app/server/pom.xml:

  • skipTests is correctly used as the master switch
  • skipITs and skipUTs are properly referenced in their respective build configurations
  • No conflicting or inconsistent usage found in other pom files
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for usage of skip properties in pom files
rg -U "skip(ITs|UTs|Tests)" -g "pom.xml"

Length of output: 356


80-103: Test source directories are properly configured.

The build-helper-maven-plugin configuration correctly adds multiple test source directories.

Let's verify the test directory structure exists:

.github/workflows/server-build.yml (2)

8-28: Workflow inputs are well-defined and documented.

The input parameters are clearly described with appropriate defaults.

Also applies to: 42-46


238-238: LGTM! Maven command correctly uses 'verify' phase.

The change to 'mvn verify' is appropriate for running both unit and integration tests.

Comment on lines +31 to +52
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?.[2];
if (itsMatch) {
response = { ...response, its: 'true' };
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix capturing group usage for it=true.

Line 49 reuses okToTestPattern?.[2], but this group already captures tags rather than the optional it=true segment. Update line 49 to capture group 3 (e.g. okToTestPattern?.[3]). Also ensure you provide an output in the job if you intend to use its downstream.

Below is an example diff to capture it=true correctly:

- const itsMatch = okToTestPattern?.[2];
+ const itsMatch = okToTestPattern?.[3];
  if (itsMatch) {
    response = { ...response, its: 'true' };
  }

Additionally, if you want to pass its out of this step, define:

core.setOutput("tags", parseResult.tags ?? "");
core.setOutput("spec", parseResult.spec ?? "");
+core.setOutput("its", parseResult.its ?? "");

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +136 to +144

perform-it:
needs: [ parse-tags ]
if: success() && needs.parse-tags.outputs.its == 'true'
uses: ./.github/workflows/server-build.yml
secrets: inherit
with:
its: 'true'
is-pg-build: ${{ github.event.pull_request.base.ref == 'pg' }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Address mismatch with its output and input types.

According to static analysis, the perform-it job relies on needs.parse-tags.outputs.its, which isn't set by the parse-tags step. Also, the reusable workflow declares its as a string, so avoid passing a Boolean expression directly to is-pg-build. Align them properly, for example:

    ...
    outputs:
      tags: ${{ steps.parseTags.outputs.tags }}
      spec: ${{ steps.parseTags.outputs.spec }}
+     its: ${{ steps.parseTags.outputs.its }} # Ensure we set this in `test-tag-parser.js`

  perform-it:
    needs: [ parse-tags ]
    if: success() && needs.parse-tags.outputs.its == 'true'
    uses: ./.github/workflows/server-build.yml
    secrets: inherit
    with:
      its: 'true'
-     is-pg-build: ${{ github.event.pull_request.base.ref == 'pg' }}
+     is-pg-build: ${{ github.event.pull_request.base.ref == 'pg' ? 'true' : 'false' }}

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 actionlint (1.7.4)

139-139: property "its" is not defined in object type {matrix: string; spec: string; tags: string}

(expression)


143-143: input "its" is typed as string by reusable workflow "./.github/workflows/server-build.yml". bool value cannot be assigned

(expression)


144-144: input "is-pg-build" is typed as string by reusable workflow "./.github/workflows/server-build.yml". bool value cannot be assigned

(expression)

@nidhi-nair nidhi-nair changed the base branch from release to chore/mvn-its December 24, 2024 14:37
Base automatically changed from chore/mvn-its to release December 24, 2024 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant