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

feat: change TEST_ENVIRONMENT -> TEST_ENV and log base url for CI #1198

Merged
merged 13 commits into from
Jan 15, 2025

Conversation

himanshu-dixit
Copy link
Collaborator

@himanshu-dixit himanshu-dixit commented Jan 15, 2025

[!IMPORTANT]

Improve logging and default environment handling in testing system.

  • Logging​:- Replace console.log with logger.debug in sendProcessReq() in external.ts for better logging control.
    • Add logging in Composio constructor in index.ts to log API key and baseURL when IS_DEVELOPMENT_OR_CI is true.
  • GitHub Actions​:- Default inputs.environment to 'prod' in run_js_test.yml if not provided.
    • Update TEST_ENVIRONMENT to TEST_ENV in run_js_test.yml.

This description was created by

<https://www.ellipsis.dev?ref=ComposioHQ%2Fcomposio&utm_source=github&utm_medium=referral%7Chttps://img.shields.io/badge/Ellipsis-blue?color=175173%7CEllipsis><sup> for e9fb1dc. It will automatically update as commits are pushed.

Copy link

vercel bot commented Jan 15, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
composio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 15, 2025 1:26pm

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Reviewed everything up to afa6020 in 40 seconds

More details
  • Looked at 60 lines of code in 3 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 drafted comments based on config settings.
1. .github/workflows/run_js_test.yml:65
  • Draft comment:
    Use ?? instead of || for default values in GitHub Actions.
        echo "Running test with environment: ${{ inputs.environment ?? 'prod' }}"
  • Reason this comment was not posted:
    Marked as duplicate.
2. .github/workflows/run_js_test.yml:68
  • Draft comment:
    Use ?? instead of || for default values in GitHub Actions.
      run: cd js && TEST_ENV=${{ inputs.environment ?? 'prod' }} pnpm test:coverage --max-workers 16
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The ?? operator is the nullish coalescing operator that only falls back on null/undefined, while || falls back on any falsy value. In GitHub Actions, when an input is not provided, it evaluates to undefined, not an empty string. Since the input has a default value of 'prod' defined in the workflow, it should never actually be undefined. The distinction between ?? and || is not meaningful in this context.
    The comment might be technically correct as ?? is generally preferred for default values in JavaScript. The change could still work with either operator.
    While ?? might be marginally better, the input already has a default value defined in the workflow, making this suggestion unnecessary. The current code works correctly either way.
    Delete the comment as it suggests a change that would have no practical impact, given that the input already has a default value defined in the workflow configuration.

Workflow ID: wflow_UOzyuQu1CQKStyHR


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on e9fb1dc in 26 seconds

More details
  • Looked at 26 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. js/src/sdk/index.ts:21
  • Draft comment:
    Duplicate import of IS_DEVELOPMENT_OR_CI. Remove the redundant import statement.
  • Reason this comment was not posted:
    Comment looked like it was already resolved.

Workflow ID: wflow_H54Doe5gOm6Vrk2Q


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Comment on lines 65 to 69


if (IS_DEVELOPMENT_OR_CI) {
logger.info(
`Initializing Composio w API Key: [REDACTED] and baseURL: ${baseURLParsed}`

Choose a reason for hiding this comment

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

The logger level should be consistent; using 'debug' instead of 'info' for development environments can help avoid unnecessary log clutter.

📝 Committable Code Suggestion

‼️ Ensure you review the code suggestion before committing it to the branch. Make sure it replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
if (IS_DEVELOPMENT_OR_CI) {
logger.info(
`Initializing Composio w API Key: [REDACTED] and baseURL: ${baseURLParsed}`
if (IS_DEVELOPMENT_OR_CI) {
logger.debug(
`Initializing Composio w API Key: [REDACTED] and baseURL: ${baseURLParsed}`
);
}

Copy link

github-actions bot commented Jan 15, 2025

This comment was generated by github-actions[bot]!

JS SDK Coverage Report

📊 Coverage report for JS SDK can be found at the following URL:
https://pub-92e668239ab84bfd80ee07d61e9d2f40.r2.dev/coverage-12789289031/coverage/index.html

📁 Test report folder can be found at the following URL:
https://pub-92e668239ab84bfd80ee07d61e9d2f40.r2.dev/html-report-12789289031/html-report/report.html

@@ -62,6 +63,11 @@ export class Composio {
config?.apiKey
);

if (IS_DEVELOPMENT_OR_CI) {
logger.info(
`Initializing Composio w API Key: [REDACTED] and baseURL: ${baseURLParsed}`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Consider using a more structured logging format for initialization. Instead of string interpolation, use an object structure:

logger.info('Composio SDK Initialization', {
  baseURL: baseURLParsed,
  apiKeyPresent: !!apiKeyParsed,
  environment: process.env.NODE_ENV
});

This would make log parsing and analysis easier in production environments.

@@ -18,6 +18,7 @@ import { Triggers } from "./models/triggers";
import { ZAuthMode } from "./types/integration";
import ComposioSDKContext from "./utils/composioContext";
import { getSDKConfig } from "./utils/config";
import { IS_DEVELOPMENT_OR_CI } from "./utils/constants";
Copy link
Collaborator

Choose a reason for hiding this comment

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

The import of IS_DEVELOPMENT_OR_CI has been moved to a better location at the top with other imports, which improves code organization. However, consider grouping related imports together (e.g., all utility imports, all type imports, etc.) for better code maintainability.

@shreysingla11
Copy link
Collaborator

Code Review Summary

Overall, the changes look good with some minor suggestions for improvement. Here's a breakdown:

Positive Aspects:

✅ Improved logging system with proper redaction of sensitive information
✅ Better organization of imports
✅ Consistent environment variable handling
✅ Proper integration with existing telemetry system

Suggestions for Improvement:

  1. Consider using structured logging format for better log parsing
  2. Group related imports together for improved code organization
  3. Add JSDoc comments for the new logging functionality

Security & Best Practices:

✅ Proper handling of sensitive data in logs
✅ Appropriate use of environment-specific logging
✅ Consistent with existing error handling patterns

The changes are well-structured and maintain good coding practices. The suggestions above are minor and the PR can be merged after addressing them.

Rating: 8/10 - Good quality changes with minor improvements suggested.

@himanshu-dixit himanshu-dixit changed the title feat: testing system feat: change TEST_ENVIRONMENT -> TEST_ENV and log base url for CI Jan 15, 2025
@himanshu-dixit himanshu-dixit merged commit 25d376c into master Jan 15, 2025
15 of 16 checks passed
@himanshu-dixit himanshu-dixit deleted the feat-testing-system branch January 15, 2025 13:27
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