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

Android CI/CD #583

Merged
merged 39 commits into from
Jan 2, 2025
Merged

Conversation

prateek-kommunicate
Copy link
Contributor

@prateek-kommunicate prateek-kommunicate commented Dec 23, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a new GitHub Actions workflow for automated code linting, building, and testing of pull requests.
    • Added a baseline configuration for lint checks to improve management of lint warnings.
    • Created a lint-baseline.xml file to define lint issues and their resolutions.
    • Added a debug APK generation feature with a download link in pull request comments.
    • Introduced an additional GitHub Actions workflow for running instrumentation tests.
  • Updates

    • Updated Gradle version to 8.10.2 for improved performance and features.
    • Introduced new shell and batch scripts for POSIX-compliant Gradle startup with robust error handling.
    • Enhanced error handling and synchronization in various test cases for improved robustness.

Copy link

coderabbitai bot commented Dec 23, 2024

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This pull request introduces a new GitHub Actions workflow named pr-check.yml, which automates code linting, building, and testing for pull requests targeting the development and master branches. It includes jobs for building the project, performing lint checks, generating debug APKs, and posting PR comments. Additionally, the PR updates the Gradle wrapper to version 8.10.2, adds a lint baseline configuration in the app/build.gradle file, and introduces a new lint-baseline.xml file to manage lint issues. Changes are also made to various test classes to enhance error handling and improve functionality.

Changes

File Change Summary
.github/workflows/pr-check.yml New GitHub Actions workflow for PR checks, including build, lint, debug APK generation, and PR commenting jobs
app/build.gradle Added lintOptions configuration with baseline file lint-baseline.xml
app/lint-baseline.xml New file defining baseline lint issues and their details
gradle/wrapper/gradle-wrapper.properties Updated Gradle distribution URL from 8.10 to 8.10.2
gradlew and gradlew.bat New scripts for Gradle startup with licensing and environment setup
.github/workflows/temp.yml New GitHub Actions workflow for running instrumentation tests on pull requests
app/src/androidTest/java/kommunicate/io/sample/ConversationTest.kt Modifications to wait times, bot IDs, and assertions in test methods
app/src/androidTest/java/kommunicate/io/sample/ConversationWithPreChatTest.kt Enhanced error handling in conversation launch tests
app/src/androidTest/java/kommunicate/io/sample/KMUserDataValidationTest.kt Updated error handling in user metadata validation test
app/src/androidTest/java/kommunicate/io/sample/PseudoNameTest.kt Added lifecycle management and user data retrieval in tests
app/src/androidTest/java/kommunicate/io/sample/utils/KmTestHelper.kt Simplified image validation process by removing CountDownLatch
app/src/androidTest/java/kommunicate/io/sample/utils/Utils.kt Updated waitForLatch function to include a new delay parameter
kommunicate/src/main/AndroidManifest.xml Added tools:replace attribute for android:allowBackup in the application tag
kommunicate/src/main/java/io/kommunicate/KmConversationHelper.java Modified error handling in getLoginHandler method

Possibly related PRs

Poem

🐰 A Rabbit's Workflow Tale 🚀
Lint and build, with actions so bright,
Checking code from morning to night,
Gradle wrapper spinning with glee,
Automating tasks, setting PRs free!
Hop, hop, review - our rabbit's delight! 🌟


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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

Copy link

@CodeRabbit review

Copy link

coderabbitai bot commented Dec 23, 2024

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

🚀 The APK is ready for download (As per the last commit of this PR): Download APK

Copy link

@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: 1

🧹 Nitpick comments (4)
.github/workflows/pr-check.yml (3)

73-73: Optimize file writes by combining echo statements.

ShellCheck (SC2129) flags repeated echo statements. Consider using a block for multiple lines:

-    echo "apiKommunicateIo=${{ secrets.APIKOMMUNICATEIO }}" >> release.secrets.properties
-    echo "apiEuKommunicateIo=${{ secrets.APIEUKOMMUNICATEIO }}" >> release.secrets.properties
+    {
+      echo "apiKommunicateIo=${{ secrets.APIKOMMUNICATEIO }}"
+      echo "apiEuKommunicateIo=${{ secrets.APIEUKOMMUNICATEIO }}"
+    } >> release.secrets.properties

Also applies to: 166-166, 255-255

🧰 Tools
🪛 actionlint (1.7.4)

73-73: shellcheck reported issue in this script: SC2129:style:1:1: Consider using { cmd1; cmd2; } >> file instead of individual redirects

(shellcheck)


278-278: Double quote to prevent word splitting (SC2086).

ShellCheck suggests quoting variables in commands like “echo $GITHUB_SHA” to avoid unintended glob expansion or splitting.

🧰 Tools
🪛 actionlint (1.7.4)

278-278: shellcheck reported issue in this script: SC2086:info:1:40: Double quote to prevent globbing and word splitting

(shellcheck)


4-4: Remove trailing spaces and add a newline at EOF.

YAML linting has flagged trailing spaces and missing newline. Removing them helps maintain code cleanliness.

-  pull_request: 
+  pull_request:
...
-  - name: Clean the project before app build 
+  - name: Clean the project before app build
...
-  path: app/build/outputs/apk/debug/app-debug.apk 
+  path: app/build/outputs/apk/debug/app-debug.apk
...
-            body: "@coderabbit review"
\ No newline at end of file
+            body: "@coderabbit review"
+

Also applies to: 107-107, 195-195, 283-283, 286-286, 323-323, 344-344

🧰 Tools
🪛 yamllint (1.35.1)

[error] 4-4: trailing spaces

(trailing-spaces)

app/lint-baseline.xml (1)

1-779: Regularly update lint baseline.

This file lists current lint issues. Keep it updated so that newly introduced errors are caught by lint instead of being silently ignored.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d1386db and 328c681.

📒 Files selected for processing (6)
  • .github/workflows/pr-check.yml (1 hunks)
  • app/build.gradle (1 hunks)
  • app/lint-baseline.xml (1 hunks)
  • gradle/wrapper/gradle-wrapper.properties (1 hunks)
  • gradlew (1 hunks)
  • gradlew.bat (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • gradle/wrapper/gradle-wrapper.properties
  • gradlew.bat
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/pr-check.yml

73-73: shellcheck reported issue in this script: SC2129:style:1:1: Consider using { cmd1; cmd2; } >> file instead of individual redirects

(shellcheck)


166-166: shellcheck reported issue in this script: SC2129:style:1:1: Consider using { cmd1; cmd2; } >> file instead of individual redirects

(shellcheck)


255-255: shellcheck reported issue in this script: SC2129:style:1:1: Consider using { cmd1; cmd2; } >> file instead of individual redirects

(shellcheck)


278-278: shellcheck reported issue in this script: SC2086:info:1:40: Double quote to prevent globbing and word splitting

(shellcheck)


290-290: the runner of "actions/github-script@v6" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


310-310: the runner of "actions/github-script@v6" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


336-336: the runner of "actions/github-script@v6" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🪛 yamllint (1.35.1)
.github/workflows/pr-check.yml

[error] 4-4: trailing spaces

(trailing-spaces)


[error] 107-107: trailing spaces

(trailing-spaces)


[error] 195-195: trailing spaces

(trailing-spaces)


[error] 283-283: trailing spaces

(trailing-spaces)


[error] 286-286: trailing spaces

(trailing-spaces)


[error] 323-323: trailing spaces

(trailing-spaces)


[error] 344-344: no new line character at the end of file

(new-line-at-end-of-file)

🔇 Additional comments (2)
gradlew (1)

1-252: No major issues detected in the Gradle wrapper script.

This is a standard Gradle wrapper script with extensive POSIX compatibility handling, along with robust environment checks. No code-level changes are needed at this time.

.github/workflows/pr-check.yml (1)

290-290: GitHub Script action version may be outdated.

The runner “actions/github-script@v6” is flagged as too old. Updating to a recent version (e.g., v6.3.0 or higher if available) may resolve potential incompatibilities.

Also applies to: 310-310, 336-336

🧰 Tools
🪛 actionlint (1.7.4)

290-290: the runner of "actions/github-script@v6" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

Comment on lines +49 to +51
lintOptions {
baseline file("lint-baseline.xml")
}
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Lint baseline contains several critical issues that need attention

The lint baseline file contains multiple important issues that should be addressed:

  • Security concerns:
    • Exported service without permission requirements
    • Missing POST_NOTIFICATIONS permission for Android 13+
    • Missing Selected Photos Access handling for Android 14+
  • Outdated dependencies with potential security/performance implications:
    • Firebase Messaging (20.1.0 → 24.1.0)
    • Play Services Location (17.0.0 → 21.3.0)
    • AndroidX Core KTX (1.13.1 → 1.15.0)
  • UI/UX issues:
    • Custom splash screen implementation (should use the platform's splash screen API)
    • Missing content descriptions for accessibility
    • Hardcoded strings instead of using string resources
    • Missing autofill hints on text inputs

Consider addressing these issues rather than suppressing them in the baseline, especially the security-related ones.

🔗 Analysis chain

Ensure lint baseline alignment.

You've introduced a lint baseline. Verify that the baseline file is correctly maintained to avoid ignoring newly introduced critical issues. It's a best practice to periodically update the baseline to keep issues in check.


Let me verify the existence and content of the lint baseline file.


Let me check the content of the lint baseline file found in the app directory.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Check if the lint baseline file exists and show its content
if [ -f "lint-baseline.xml" ]; then
    echo "Lint baseline file exists. Content:"
    cat "lint-baseline.xml"
else
    echo "Lint baseline file not found at repository root"
    # Check if it exists in other directories
    fd -t f "lint-baseline.xml"
fi

Length of output: 185


Script:

#!/bin/bash
# Show content of the lint baseline file in the app directory
cat "app/lint-baseline.xml"

Length of output: 29623

Copy link

@CodeRabbit review

Copy link

coderabbitai bot commented Dec 24, 2024

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

🚀 The APK is ready for download (As per the last commit of this PR): Download APK

Copy link

@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: 6

🧹 Nitpick comments (5)
.github/workflows/temp.yml (2)

3-3: Fix YAML formatting issues

There are several YAML formatting issues that should be addressed:

  1. Trailing spaces on lines 3 and 18
  2. Missing newline at end of file
-on: 
+on:
-    steps: 
+    steps:
 # Add newline at end of file

Also applies to: 18-18, 39-39

🧰 Tools
🪛 yamllint (1.35.1)

[error] 3-3: trailing spaces

(trailing-spaces)


28-29: Review retry configuration

The current retry configuration might not be sufficient for network issues:

  • 3 retries with 500ms delay might be too aggressive
  • Consider exponential backoff
-          retry-count: 3
-          retry-delay: 500
+          retry-count: 5
+          retry-delay: 1000
.github/workflows/pr-check.yml (3)

4-16: LGTM! Well-configured workflow triggers and concurrency settings.

The workflow is properly configured to:

  • Trigger on relevant PR events (opened, reopened, synchronize)
  • Target important branches (development, master)
  • Handle concurrent runs efficiently

Remove the redundant comment on line 8 as it duplicates the configuration itself.

🧰 Tools
🪛 yamllint (1.35.1)

[error] 4-4: trailing spaces

(trailing-spaces)


288-305: Improve error handling for artifact URL retrieval.

The current implementation could fail silently if the artifact is not found immediately after upload.

Add retry logic and better error handling:

  script: |
+   const MAX_RETRIES = 3;
+   const RETRY_DELAY = 5000; // 5 seconds
+   
+   async function sleep(ms) {
+     return new Promise(resolve => setTimeout(resolve, ms));
+   }
+   
+   async function getArtifact(artifactName, attempt = 1) {
    const artifacts = await github.rest.actions.listArtifactsForRepo({
      owner: context.repo.owner,
      repo: context.repo.repo,
    });
-   console.log(`Artifacts: $artifacts`);
+   console.log(`Attempt ${attempt}: Found ${artifacts.data.artifacts.length} artifacts`);
    const artifact = artifacts.data.artifacts.find(a => a.name === artifactName);
    if (artifact) {
      return artifact;
+   } else if (attempt < MAX_RETRIES) {
+     console.log(`Artifact not found, retrying in ${RETRY_DELAY/1000} seconds...`);
+     await sleep(RETRY_DELAY);
+     return getArtifact(artifactName, attempt + 1);
    } else {
-     core.setFailed(`Artifact ${artifactName} not found.`);
+     throw new Error(`Artifact ${artifactName} not found after ${MAX_RETRIES} attempts.`);
    }
+   }
+   
    const artifactName = `Agent-App-${process.env.commit_hash}`;
-   const artifact = artifacts.data.artifacts.find(a => a.name === artifactName);
-   if (artifact) {
+   try {
+     const artifact = await getArtifact(artifactName);
      core.setOutput('artifact_url', artifact.archive_download_url);
      console.log(`Artifact URL: ${artifact.archive_download_url}`);
-   } else {
-     core.setFailed(`Artifact ${artifactName} not found.`);
+   } catch (error) {
+     core.setFailed(error.message);
    }
🧰 Tools
🪛 actionlint (1.7.4)

290-290: the runner of "actions/github-script@v6" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


1-343: Address static analysis warnings.

Several issues were identified by the static analysis tools:

  1. Shell script improvements needed for file redirects
  2. GitHub Script action version needs updating
  3. YAML formatting issues present

Apply the following fixes:

  1. Update GitHub Script action version:
-   uses: actions/github-script@v6
+   uses: actions/github-script@v7
  1. Fix shell script redirects (apply to all similar instances):
-   echo "apiKommunicateIo=${{ secrets.APIKOMMUNICATEIO }}" >> release.secrets.properties
-   echo "apiEuKommunicateIo=${{ secrets.APIEUKOMMUNICATEIO }}" >> release.secrets.properties
+   {
+     echo "apiKommunicateIo=${{ secrets.APIKOMMUNICATEIO }}"
+     echo "apiEuKommunicateIo=${{ secrets.APIEUKOMMUNICATEIO }}"
+   } >> release.secrets.properties
  1. Fix YAML formatting:
  • Remove trailing spaces
  • Add newline at end of file
🧰 Tools
🪛 actionlint (1.7.4)

73-73: shellcheck reported issue in this script: SC2129:style:1:1: Consider using { cmd1; cmd2; } >> file instead of individual redirects

(shellcheck)


166-166: shellcheck reported issue in this script: SC2129:style:1:1: Consider using { cmd1; cmd2; } >> file instead of individual redirects

(shellcheck)


255-255: shellcheck reported issue in this script: SC2129:style:1:1: Consider using { cmd1; cmd2; } >> file instead of individual redirects

(shellcheck)


278-278: shellcheck reported issue in this script: SC2086:info:1:40: Double quote to prevent globbing and word splitting

(shellcheck)


290-290: the runner of "actions/github-script@v6" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


309-309: the runner of "actions/github-script@v6" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


335-335: the runner of "actions/github-script@v6" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🪛 yamllint (1.35.1)

[error] 4-4: trailing spaces

(trailing-spaces)


[error] 107-107: trailing spaces

(trailing-spaces)


[error] 195-195: trailing spaces

(trailing-spaces)


[error] 283-283: trailing spaces

(trailing-spaces)


[error] 286-286: trailing spaces

(trailing-spaces)


[error] 322-322: trailing spaces

(trailing-spaces)


[error] 343-343: no new line character at the end of file

(new-line-at-end-of-file)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 328c681 and ef0688d.

📒 Files selected for processing (2)
  • .github/workflows/pr-check.yml (1 hunks)
  • .github/workflows/temp.yml (1 hunks)
🧰 Additional context used
🪛 yamllint (1.35.1)
.github/workflows/temp.yml

[error] 3-3: trailing spaces

(trailing-spaces)


[error] 18-18: trailing spaces

(trailing-spaces)


[error] 39-39: no new line character at the end of file

(new-line-at-end-of-file)

.github/workflows/pr-check.yml

[error] 4-4: trailing spaces

(trailing-spaces)


[error] 107-107: trailing spaces

(trailing-spaces)


[error] 195-195: trailing spaces

(trailing-spaces)


[error] 283-283: trailing spaces

(trailing-spaces)


[error] 286-286: trailing spaces

(trailing-spaces)


[error] 322-322: trailing spaces

(trailing-spaces)


[error] 343-343: no new line character at the end of file

(new-line-at-end-of-file)

🪛 actionlint (1.7.4)
.github/workflows/pr-check.yml

73-73: shellcheck reported issue in this script: SC2129:style:1:1: Consider using { cmd1; cmd2; } >> file instead of individual redirects

(shellcheck)


166-166: shellcheck reported issue in this script: SC2129:style:1:1: Consider using { cmd1; cmd2; } >> file instead of individual redirects

(shellcheck)


255-255: shellcheck reported issue in this script: SC2129:style:1:1: Consider using { cmd1; cmd2; } >> file instead of individual redirects

(shellcheck)


278-278: shellcheck reported issue in this script: SC2086:info:1:40: Double quote to prevent globbing and word splitting

(shellcheck)


290-290: the runner of "actions/github-script@v6" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


309-309: the runner of "actions/github-script@v6" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


335-335: the runner of "actions/github-script@v6" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🔇 Additional comments (1)
.github/workflows/temp.yml (1)

26-27: Review authentication method

The workflow uses a token for authentication. Ensure that:

  1. The DOWNLOAD_TOKEN secret has minimal required permissions
  2. The token is regularly rotated
  3. Consider using GITHUB_TOKEN if possible for automatic token management
✅ Verification successful

Let me check the workflow file to understand the context of token usage.


Consider using GITHUB_TOKEN for artifact download

Based on the verification:

  1. The workflow is downloading an artifact from the same repository (Kommunicate-Android-Chat-SDK)
  2. The API test confirms that GITHUB_TOKEN has sufficient permissions to access artifacts
  3. GITHUB_TOKEN is automatically created and rotated by GitHub Actions

Replace the custom DOWNLOAD_TOKEN with GITHUB_TOKEN:

Authorization: Bearer ${{ github.token }}

This change will:

  • Eliminate the need to manage a custom token
  • Provide automatic token rotation
  • Follow the principle of least privilege as GITHUB_TOKEN has repository-scoped access
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if GITHUB_TOKEN could be used instead of custom token
gh api \
  -H "Accept: application/vnd.github+json" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  "/repos/Kommunicate-io/Kommunicate-Android-Chat-SDK/actions/artifacts" \
  --jq 'if .total_count > 0 then "GITHUB_TOKEN might be sufficient for artifact access" else "Custom token might be required" end'

Length of output: 338


Script:

#!/bin/bash
# Check the workflow file to understand the token usage
cat .github/workflows/temp.yml

Length of output: 1438

@@ -0,0 +1,39 @@
name: dasd
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Workflow name requires revision

The current workflow name "dasd" is non-descriptive and appears to be a placeholder. Consider using a meaningful name that reflects the workflow's purpose, such as "Download Artifact Workflow" or "Artifact Retrieval".

-name: dasd
+name: Download Artifact Workflow
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
name: dasd
name: Download Artifact Workflow

steps:
- name: Send HTTP request to download artifact
id: request
uses: tyrrrz/action-http-request@master
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Security concern: Avoid using @master reference

Using the @master reference for actions is a security risk as it can lead to unexpected behavior if the action is compromised. Pin to a specific version hash for security.

-        uses: tyrrrz/action-http-request@master
+        uses: tyrrrz/[email protected]
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
uses: tyrrrz/action-http-request@master
uses: tyrrrz/action-http-request@v1.6.1

id: request
uses: tyrrrz/action-http-request@master
with:
url: https://api.github.com/repos/Kommunicate-io/Kommunicate-Android-Chat-SDK/actions/artifacts/2355441843
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Security concern: Hardcoded artifact ID

The artifact ID (2355441843) is hardcoded in the URL. This is not maintainable and could pose security risks if the artifact is sensitive.

Consider:

  1. Parameterizing the artifact ID using workflow inputs or environment variables
  2. Implementing proper artifact lifecycle management
-          url: https://api.github.com/repos/Kommunicate-io/Kommunicate-Android-Chat-SDK/actions/artifacts/2355441843
+          url: https://api.github.com/repos/Kommunicate-io/Kommunicate-Android-Chat-SDK/actions/artifacts/${{ inputs.artifact_id }}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
url: https://api.github.com/repos/Kommunicate-io/Kommunicate-Android-Chat-SDK/actions/artifacts/2355441843
url: https://api.github.com/repos/Kommunicate-io/Kommunicate-Android-Chat-SDK/actions/artifacts/${{ inputs.artifact_id }}

Comment on lines 31 to 39
- name: Print outputs
run: |
echo "Status: ${{ steps.request.outputs.status }}"
echo "Success: ${{ steps.request.outputs.success }}"
echo "Headers: ${{ steps.request.outputs.headers }}"
echo "Body: ${{ steps.request.outputs.body }}"
echo "Artifact downloaded successfully as artifact.zip"
# Optional: Save the body (artifact) to a file if it is binary content
echo "${{ steps.request.outputs.body }}" > artifact.zip
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Improve artifact handling and validation

The current implementation saves the response body directly to a file without proper validation or error handling.

Consider:

  1. Add validation for the response status
  2. Verify the content type and size
  3. Implement proper error handling
       - name: Print outputs
+        if: steps.request.outputs.success == 'true'
         run: |
-          echo "Status: ${{ steps.request.outputs.status }}"
-          echo "Success: ${{ steps.request.outputs.success }}"
-          echo "Headers: ${{ steps.request.outputs.headers }}"
-          echo "Body: ${{ steps.request.outputs.body }}"
-          echo "Artifact downloaded successfully as artifact.zip"
-          # Optional: Save the body (artifact) to a file if it is binary content
-          echo "${{ steps.request.outputs.body }}" > artifact.zip
+          if [[ "${{ steps.request.outputs.status }}" == "200" ]]; then
+            echo "Downloading artifact..."
+            echo "${{ steps.request.outputs.body }}" > artifact.zip
+            if [[ -f "artifact.zip" ]]; then
+              echo "Artifact downloaded successfully"
+            else
+              echo "Failed to save artifact"
+              exit 1
+            fi
+          else
+            echo "Failed to download artifact. Status: ${{ steps.request.outputs.status }}"
+            exit 1
+          fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Print outputs
run: |
echo "Status: ${{ steps.request.outputs.status }}"
echo "Success: ${{ steps.request.outputs.success }}"
echo "Headers: ${{ steps.request.outputs.headers }}"
echo "Body: ${{ steps.request.outputs.body }}"
echo "Artifact downloaded successfully as artifact.zip"
# Optional: Save the body (artifact) to a file if it is binary content
echo "${{ steps.request.outputs.body }}" > artifact.zip
- name: Print outputs
if: steps.request.outputs.success == 'true'
run: |
if [[ "${{ steps.request.outputs.status }}" == "200" ]]; then
echo "Downloading artifact..."
echo "${{ steps.request.outputs.body }}" > artifact.zip
if [[ -f "artifact.zip" ]]; then
echo "Artifact downloaded successfully"
else
echo "Failed to save artifact"
exit 1
fi
else
echo "Failed to download artifact. Status: ${{ steps.request.outputs.status }}"
exit 1
fi
🧰 Tools
🪛 yamllint (1.35.1)

[error] 39-39: no new line character at the end of file

(new-line-at-end-of-file)

build:
name: "Build Project"
runs-on: ubuntu-latest
needs: lint
Copy link

@coderabbitai coderabbitai bot Dec 24, 2024

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix job dependencies to ensure correct execution order.

The current job dependency chain is problematic:

  1. Build job depends on lint job, but lint checks might need generated files from the build
  2. Both debug-apk and comment-on-pr jobs correctly depend on build

Modify the job dependencies to ensure correct execution order:

  build:
    name: "Build Project"
    runs-on: ubuntu-latest
-   needs: lint

  lint:
    name: "Run Lint Checks"
    runs-on: ubuntu-latest
+   needs: build

Also applies to: 204-204, 325-325

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Copy link

Choose a reason for hiding this comment

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

@prateek-kommunicate, thank you for addressing the fix! Looks good.


If you found this review helpful, would you consider giving us a shout-out on X?
Thank you for using CodeRabbit!

Comment on lines +66 to +82
- name: Create local.properties
run: |
echo "sdk.dir=$ANDROID_HOME" > local.properties
echo "GOOGLE_KEY=${{ secrets.GOOGLE_MAPS_API }}" >> local.properties

# Create release.secrets.properties
- name: Create release.secrets.properties
run: |
echo "apiKommunicateIo=${{ secrets.APIKOMMUNICATEIO }}" >> release.secrets.properties
echo "apiEuKommunicateIo=${{ secrets.APIEUKOMMUNICATEIO }}" >> release.secrets.properties
echo "apiCaKommunicateIo=${{ secrets.APICAKOMMUNICATEIO }}" >> release.secrets.properties
echo "apiTestKommuncateIo=${{ secrets.APITESTKOMMUNCATEIO }}" >> release.secrets.properties
echo "kommunicateIo=${{ secrets.KOMMUNICATEIO }}" >> release.secrets.properties
echo "apiInKommunicateIo=${{ secrets.APIINKOMMUNICATEIO }}" >> release.secrets.properties
echo "kommunicateAWS=${{ secrets.KOMMUNICATEAWS }}" >> release.secrets.properties
echo "SENTRY_DSN=${{ secrets.SENTRY_DSN }}" >> release.secrets.properties

Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Refactor repeated configuration setup into a reusable composite action.

The same configuration setup (creating properties files with secrets) is duplicated across three jobs. This increases maintenance overhead and the risk of inconsistencies.

Create a composite action to handle the configuration setup:

# .github/actions/setup-properties/action.yml
name: 'Setup Properties Files'
description: 'Creates necessary properties files with secrets'
runs:
  using: "composite"
  steps:
    - name: Create local.properties
      shell: bash
      run: |
        {
          echo "sdk.dir=$ANDROID_HOME"
          echo "GOOGLE_KEY=${{ secrets.GOOGLE_MAPS_API }}"
        } > local.properties

    - name: Create release.secrets.properties
      shell: bash
      run: |
        {
          echo "apiKommunicateIo=${{ secrets.APIKOMMUNICATEIO }}"
          echo "apiEuKommunicateIo=${{ secrets.APIEUKOMMUNICATEIO }}"
          echo "apiCaKommunicateIo=${{ secrets.APICAKOMMUNICATEIO }}"
          echo "apiTestKommuncateIo=${{ secrets.APITESTKOMMUNCATEIO }}"
          echo "kommunicateIo=${{ secrets.KOMMUNICATEIO }}"
          echo "apiInKommunicateIo=${{ secrets.APIINKOMMUNICATEIO }}"
          echo "kommunicateAWS=${{ secrets.KOMMUNICATEAWS }}"
          echo "SENTRY_DSN=${{ secrets.SENTRY_DSN }}"
        } > release.secrets.properties

Then use it in each job:

- name: Setup Properties
  uses: ./.github/actions/setup-properties

Also applies to: 159-175, 248-264

🧰 Tools
🪛 actionlint (1.7.4)

73-73: shellcheck reported issue in this script: SC2129:style:1:1: Consider using { cmd1; cmd2; } >> file instead of individual redirects

(shellcheck)

Copy link

@CodeRabbit review

Copy link

coderabbitai bot commented Dec 24, 2024

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

🚀 The APK is ready for download (As per the last commit of this PR): Download APK

Copy link

@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: 1

🧹 Nitpick comments (4)
.github/workflows/temp.yml (4)

7-7: Remove redundant comment

The comment is redundant as the branch targeting is already clear from the configuration.

-      - master  # Run only for pull requests targeting the develop and master branch
+      - master

49-52: Enhance test execution reliability

The test execution step could benefit from better error handling and timeout configuration.

       - name: Build and Run Tests
+        timeout-minutes: 30
         run: |
+          # Ensure Gradle wrapper has execute permissions
+          chmod +x ./gradlew
+          # Build with detailed logging on failure
           ./gradlew assembleDebug assembleAndroidTest
-          ./gradlew connectedAndroidTest
+          ./gradlew connectedAndroidTest --info --stacktrace
+        continue-on-error: false

55-59: Improve test results artifact configuration

The artifact upload configuration could benefit from additional settings for better maintainability and resource management.

       - name: Upload Test Results
         uses: actions/upload-artifact@v4
         with:
           name: test-results
           path: app/build/reports/androidTests/
+          retention-days: 14
+          if-no-files-found: error
+          compression-level: 9

Also, add a newline at the end of the file to fix the YAML formatting issue.

🧰 Tools
🪛 yamllint (1.35.1)

[error] 59-59: no new line character at the end of file

(new-line-at-end-of-file)


1-59: Consider splitting the workflow for better maintainability

The current workflow combines environment setup, test execution, and artifact handling. Consider splitting it into reusable workflows:

  1. A reusable environment setup workflow
  2. A main test execution workflow
  3. A reusable artifact handling workflow

This would improve maintainability and allow for better reuse across different Android projects.

Would you like me to provide an example of how to structure these reusable workflows?

🧰 Tools
🪛 actionlint (1.7.4)

20-20: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


24-24: the runner of "actions/setup-java@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🪛 yamllint (1.35.1)

[error] 3-3: trailing spaces

(trailing-spaces)


[error] 53-53: trailing spaces

(trailing-spaces)


[error] 59-59: no new line character at the end of file

(new-line-at-end-of-file)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ef0688d and c670988.

📒 Files selected for processing (1)
  • .github/workflows/temp.yml (1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/temp.yml

20-20: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


24-24: the runner of "actions/setup-java@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🪛 yamllint (1.35.1)
.github/workflows/temp.yml

[error] 3-3: trailing spaces

(trailing-spaces)


[error] 53-53: trailing spaces

(trailing-spaces)


[error] 59-59: no new line character at the end of file

(new-line-at-end-of-file)

🔇 Additional comments (1)
.github/workflows/temp.yml (1)

1-1: Workflow name requires revision

The current workflow name "dasd" is non-descriptive. Consider using a meaningful name that reflects the workflow's purpose.

-name: dasd
+name: Android Instrumentation Tests

.github/workflows/temp.yml Outdated Show resolved Hide resolved
Copy link

@CodeRabbit review

Copy link

coderabbitai bot commented Dec 28, 2024

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

🚀 The APK is ready for download (As per the last commit of this PR): Download APK

Copy link

@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: 4

🧹 Nitpick comments (18)
.github/workflows/temp.yml (6)

3-11: Consider adding path filters to the workflow trigger

The workflow runs instrumentation tests which can be time-consuming. Consider adding path filters to only trigger the workflow when relevant files are changed.

 on: 
   pull_request:
     branches:
       - development
       - master
+    paths:
+      - 'app/**'
+      - 'kommunicatesdk/**'
+      - 'build.gradle'
+      - 'gradle.properties'
     types:
       - synchronize
       - opened
       - reopened
🧰 Tools
🪛 yamllint (1.35.1)

[error] 3-3: trailing spaces

(trailing-spaces)


17-21: Enhance test coverage with multiple API levels

Consider testing against multiple API levels to ensure compatibility across different Android versions. Also, add a name to the matrix combination for better visibility in the GitHub UI.

     strategy:
+      fail-fast: false
       matrix:
-        api-level: [ 30 ]
+        api-level: [ 29, 30, 31 ]
         target: [ google_apis ]
+    name: Instrumentation Tests (API ${{ matrix.api-level }})

41-46: Improve cache key specificity

The current cache key only includes the API level. Consider adding more variables to make the cache key more specific and prevent cache conflicts.

         with:
           path: |
             ~/.android/avd/*
             ~/.android/adb*
-          key: avd-${{ matrix.api-level }}
+          key: avd-${{ matrix.api-level }}-${{ matrix.target }}-${{ hashFiles('build.gradle') }}
+          restore-keys: |
+            avd-${{ matrix.api-level }}-${{ matrix.target }}-
+            avd-${{ matrix.api-level }}-

57-57: Optimize emulator performance settings

The emulator options could be optimized for CI environment. Consider adding memory-related options for better performance.

-          emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
+          emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -memory 2048 -no-snapshot -cores 2

Also applies to: 86-86


69-77: Optimize file creation and enhance security

  1. Use a single redirection for better performance
  2. Consider using environment files for sensitive data
-      - name: Create release.secrets.properties
-        run: |
-          echo "apiKommunicateIo=${{ secrets.APIKOMMUNICATEIO }}" >> release.secrets.properties
-          echo "apiEuKommunicateIo=${{ secrets.APIEUKOMMUNICATEIO }}" >> release.secrets.properties
-          echo "apiCaKommunicateIo=${{ secrets.APICAKOMMUNICATEIO }}" >> release.secrets.properties
-          echo "apiTestKommuncateIo=${{ secrets.APITESTKOMMUNCATEIO }}" >> release.secrets.properties
-          echo "kommunicateIo=${{ secrets.KOMMUNICATEIO }}" >> release.secrets.properties
-          echo "apiInKommunicateIo=${{ secrets.APIINKOMMUNICATEIO }}" >> release.secrets.properties
-          echo "kommunicateAWS=${{ secrets.KOMMUNICATEAWS }}" >> release.secrets.properties
-          echo "SENTRY_DSN=${{ secrets.SENTRY_DSN }}" >> release.secrets.properties
+      - name: Create release.secrets.properties
+        run: |
+          {
+            echo "apiKommunicateIo=${{ secrets.APIKOMMUNICATEIO }}"
+            echo "apiEuKommunicateIo=${{ secrets.APIEUKOMMUNICATEIO }}"
+            echo "apiCaKommunicateIo=${{ secrets.APICAKOMMUNICATEIO }}"
+            echo "apiTestKommuncateIo=${{ secrets.APITESTKOMMUNCATEIO }}"
+            echo "kommunicateIo=${{ secrets.KOMMUNICATEIO }}"
+            echo "apiInKommunicateIo=${{ secrets.APIINKOMMUNICATEIO }}"
+            echo "kommunicateAWS=${{ secrets.KOMMUNICATEAWS }}"
+            echo "SENTRY_DSN=${{ secrets.SENTRY_DSN }}"
+          } > release.secrets.properties
+        shell: bash
🧰 Tools
🪛 actionlint (1.7.4)

69-69: shellcheck reported issue in this script: SC2129:style:1:1: Consider using { cmd1; cmd2; } >> file instead of individual redirects

(shellcheck)


3-3: Fix formatting issues

  1. Remove trailing spaces on lines 3, 78, and 91
  2. Add newline at end of file

Also applies to: 78-78, 91-91, 97-97

🧰 Tools
🪛 yamllint (1.35.1)

[error] 3-3: trailing spaces

(trailing-spaces)

app/src/androidTest/java/kommunicate/io/sample/KMUserDataValidationTest.kt (1)

97-105: Consider asserting specific exception details instead of swallowing.

Catching a general Exception without re-throwing or logging it might lose information about what actually went wrong. If the test aims to confirm certain exceptions, verifying the exception type or message in detail can help avoid false positives.

🧰 Tools
🪛 detekt (1.23.7)

[warning] 102-102: The caught exception is swallowed. The original exception could be lost.

(detekt.exceptions.SwallowedException)

app/src/androidTest/java/kommunicate/io/sample/utils/Utils.kt (1)

86-94: Optional improvement: replace arbitrary sleeps with test synchronization.

This new waitAfterLatch parameter can help reduce flakiness by giving extra time for UI stabilization. However, be cautious that arbitrary waits may slow your tests. When feasible, consider using a more deterministic synchronization mechanism (e.g., IdlingResource or a known event) instead of time-based waits.

app/src/androidTest/java/kommunicate/io/sample/ConversationWithPreChatTest.kt (3)

163-165: Consider event-based synchronization.

Waiting for 5 seconds might ensure stability but can unnecessarily increase test run times. When possible, prefer event-based synchronization (e.g., IdlingResource) to detect actual completion.


328-343: Verify exception details in negative tests.

Catching a general Exception and only checking the message can mask unexpected failures. To improve test accuracy, consider verifying the specific exception subtype or re-throwing it after logging.


379-380: Reduce or replace long waits.

Another 5-second wait to stabilize the test might be necessary, but like earlier comments, consider a more targeted event-based approach to avoid maintaining large arbitrary sleep durations.

app/src/androidTest/java/kommunicate/io/sample/ConversationTest.kt (2)

206-208: Consider avoiding static waits for stability.

Relying on a fixed wait time (waitFor(3000)) can introduce flakiness if the operation completes sooner or later. Consider using an Espresso Idling Resource or a latch-based approach to synchronize the test more reliably.


290-290: Validate large wait times.

A 5-second wait may be appropriate for network operations, but it can slow tests. Confirm that this longer wait is necessary and consider an event-based synchronization when possible.

kommunicate/src/main/java/io/kommunicate/KmConversationHelper.java (1)

622-622: Passing the exception object as the callback failure parameter.

Switching from callback.onFailure(registrationResponse) to callback.onFailure(exception) provides more accurate error information. However, confirm whether the RegistrationResponse contains additional details that might still be valuable. If so, consider including those details in error logs or bundling them in a custom error object.

app/src/androidTest/java/kommunicate/io/sample/PseudoNameTest.kt (4)

51-55: Initialization of chatAPI and tokens

While the initialization flow looks good, consider verifying or logging if the retrieved tokens are valid to prevent unexpected runtime issues.


56-58: Kommunicate initialization in onActivity

Hardcoding the app ID here is okay for testing, but extracting it to a constant or configuration can improve maintainability.


84-85: Performing an explicit delay

While waitFor(3000) might work, using an IdlingResource or more precise synchronization mechanism can reduce test flakiness.


86-87: Asserting dashboard user name

assertNotNull is a good baseline. Optionally, add a direct check to confirm it’s the same user name as generated.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c670988 and ea7381c.

📒 Files selected for processing (9)
  • .github/workflows/temp.yml (1 hunks)
  • app/src/androidTest/java/kommunicate/io/sample/ConversationTest.kt (6 hunks)
  • app/src/androidTest/java/kommunicate/io/sample/ConversationWithPreChatTest.kt (5 hunks)
  • app/src/androidTest/java/kommunicate/io/sample/KMUserDataValidationTest.kt (2 hunks)
  • app/src/androidTest/java/kommunicate/io/sample/PseudoNameTest.kt (3 hunks)
  • app/src/androidTest/java/kommunicate/io/sample/utils/KmTestHelper.kt (1 hunks)
  • app/src/androidTest/java/kommunicate/io/sample/utils/Utils.kt (1 hunks)
  • kommunicate/src/main/AndroidManifest.xml (1 hunks)
  • kommunicate/src/main/java/io/kommunicate/KmConversationHelper.java (1 hunks)
🧰 Additional context used
🪛 detekt (1.23.7)
app/src/androidTest/java/kommunicate/io/sample/KMUserDataValidationTest.kt

[warning] 102-102: The caught exception is swallowed. The original exception could be lost.

(detekt.exceptions.SwallowedException)

🪛 actionlint (1.7.4)
.github/workflows/temp.yml

69-69: shellcheck reported issue in this script: SC2129:style:1:1: Consider using { cmd1; cmd2; } >> file instead of individual redirects

(shellcheck)

🪛 yamllint (1.35.1)
.github/workflows/temp.yml

[error] 3-3: trailing spaces

(trailing-spaces)


[error] 78-78: trailing spaces

(trailing-spaces)


[error] 91-91: trailing spaces

(trailing-spaces)


[error] 97-97: no new line character at the end of file

(new-line-at-end-of-file)

🔇 Additional comments (21)
kommunicate/src/main/AndroidManifest.xml (1)

27-28: Reconsider forcing android:allowBackup in library manifest

The addition of tools:replace="android:allowBackup" forces the library's allowBackup=false setting to override the hosting application's backup settings. While disabling backup can be good for security, this decision should typically be left to the application developer.

Consider these alternatives:

  1. Remove the tools:replace and document the recommended backup settings in your library's documentation
  2. Use tools:node="remove" instead to let the app explicitly set this value
  3. If backup must be disabled, clearly document this behavior in the SDK documentation

This change might break existing applications that rely on backup functionality for their data.

Let's verify if any applications are affected:

.github/workflows/temp.yml (1)

1-1: Workflow name requires revision

The current workflow name "dasd" is non-descriptive and appears to be a placeholder.

app/src/androidTest/java/kommunicate/io/sample/KMUserDataValidationTest.kt (1)

110-112: Looks good for wait synchronization.

The call to waitForLatch(latch, 100) ensures a short post-latch delay, which can stabilize asynchronous test flows. This is fine if the extra wait does not overly increase your test duration.

app/src/androidTest/java/kommunicate/io/sample/ConversationWithPreChatTest.kt (1)

349-351: Latch-based wait approach is acceptable.

This usage of waitForLatch is consistent. Ensure that the latch truly reflects test readiness to avoid extraneous waits.

app/src/androidTest/java/kommunicate/io/sample/ConversationTest.kt (4)

218-218: Verify the newly added bot ID.

You’ve introduced "richmessagetest-apbah" to the bot IDs list. Ensure any required bot configuration or references exist in the system to avoid failures during runtime.


338-338: Ensure consistency with bot ID updates.

You’ve updated the botIds again to include "richmessagetest-apbah". Double-check that the usage in this method and the previous test is consistent—mismatched lists can cause inconsistencies when verifying bot participation in a conversation.


470-470: Confirm the updated assertion text.

The test now checks for the text "trgfdgfd". Ensure this change is intentional and the text is not a placeholder.


513-513: Improved logging context.

Adding groupId to the failure message is beneficial for debugging. This looks good.

app/src/androidTest/java/kommunicate/io/sample/PseudoNameTest.kt (13)

4-5: New imports for lifecycle usage

No issues. These imports are essential for instrumented tests with ActivityScenario and lifecycleScope.


7-8: Added Espresso imports

The added Espresso imports are standard for UI testing and look proper.


17-17: Imported additional utility methods

These helpers (launchConversation, getRandomString, sendMessageAsUser, waitFor, waitForLatch) are clearly used within the test. No issues found.

Also applies to: 19-19, 20-20, 21-21, 22-22


23-23: Coroutine launch import

No concerns. The kotlinx.coroutines.launch import is consistent with the usage in line 73.


27-27: Importing assertNotNull

No problems with adding this import, as it's used to verify that objects are not null.


33-33: Importing CountDownLatch

Using a latch for test synchronization is standard practice in Android tests.


40-40: ActivityScenario for MainActivity

Instantiating ActivityScenario here is a suitable approach for instrumentation testing of MainActivity.


43-43: New property: chatAPI

Declaring private lateinit var chatAPI clearly communicates that it’ll be initialized before usage.


63-64: Using CountDownLatch for synchronization

Creating the latch and counting it down upon conversation readiness is a solid and straightforward concurrency solution.


72-79: Launching conversation within lifecycleScope

This asynchronous call is clean. However, consider capturing and asserting exceptions in invokeOnCompletion to avoid false positives.


80-81: Waiting on the latch

The waitForLatch(latch) approach is correct and ensures the test doesn’t proceed prematurely.


82-82: Sending a random user message

No issues here. Generating random strings for tests is a common approach to ensure uniqueness.


137-160: New function getUserFromDashboardWithUserName

This function clearly retrieves the user via the chatAPI. Failing fast is acceptable in test code, though returning an optional or custom result object could improve clarity in larger test suites.

@prateek-kommunicate prateek-kommunicate merged commit 3352540 into development Jan 2, 2025
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants