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

Support UPM private registry on windows runner. #665

Closed
wants to merge 2 commits into from

Conversation

Shaun-Fong
Copy link

@Shaun-Fong Shaun-Fong commented Aug 31, 2024

Changes

  • Add new input scopedRegistryUrl

Related Issues

Successful Workflow Run Link

PRs don't have access to secrets so you will need to provide a link to a successful run of the workflows from your own
repo.

  • ...

Checklist

  • Read the contribution guide and accept the
    code of conduct
  • Docs (If new inputs or outputs have been added or changes to behavior that should be documented. Please make a PR
    in the documentation repo)
  • Readme (updated or not needed)
  • Tests (added, updated or not needed)

Copy link

Cat Gif

Copy link

coderabbitai bot commented Aug 31, 2024

Important

Review skipped

Review was skipped due to path filters

Files ignored due to path filters (1)
  • dist/platforms/windows/build.ps1 is excluded by !**/dist/**

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

Walkthrough

Walkthrough

The changes introduce new configuration options for handling package management and registry access. Specifically, an optional input parameter scopedRegistryUrl is added to action.yml, along with new properties in the BuildParameters class and environment variables in the ImageEnvironmentFactory and SetupMac classes. Additionally, static getter methods for these parameters are introduced in the Input class. These modifications enhance the flexibility and configurability of the system.

Changes

Files Change Summary
action.yml Added new optional input parameter scopedRegistryUrl for package dependency resolution.
src/model/build-parameters.ts Introduced scopedRegistryUrl and upmRegistryToken properties to the BuildParameters class.
src/model/image-environment-factory.ts Added environment variables SCOPED_REGISTRY_URL and PRIVATE_REGISTRY_TOKEN for registry access.
src/model/input.ts Introduced static getters for scopedRegistryUrl and upmRegistryToken to retrieve input values.
src/model/platform-setup/setup-mac.ts Set new environment variables PRIVATE_REGISTRY_TOKEN and SCOPED_REGISTRY_URL based on buildParameters.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Action
    participant BuildParameters
    participant ImageEnvironmentFactory
    participant SetupMac

    User->>Action: Provide scopedRegistryUrl
    Action->>BuildParameters: Set scopedRegistryUrl
    BuildParameters->>ImageEnvironmentFactory: Pass scopedRegistryUrl
    ImageEnvironmentFactory->>SetupMac: Set SCOPED_REGISTRY_URL
    SetupMac->>ImageEnvironmentFactory: Use SCOPED_REGISTRY_URL for setup
Loading

Poem

🐇 In fields of code, I hop with glee,
New paths for packages, oh what a spree!
Scoped URLs and tokens, a grand delight,
In the world of builds, everything feels right!
With every change, we dance and play,
Celebrating progress, hip-hip-hooray! 🌼


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 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

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 461ecf7 and 753a7b9.

Files ignored due to path filters (3)
  • dist/index.js is excluded by !**/dist/**
  • dist/index.js.map is excluded by !**/dist/**, !**/*.map
  • dist/platforms/windows/build.ps1 is excluded by !**/dist/**
Files selected for processing (5)
  • action.yml (1 hunks)
  • src/model/build-parameters.ts (2 hunks)
  • src/model/image-environment-factory.ts (1 hunks)
  • src/model/input.ts (1 hunks)
  • src/model/platform-setup/setup-mac.ts (1 hunks)
Additional comments not posted (3)
src/model/image-environment-factory.ts (2)

Line range hint 1-17: Review of getEnvVarString method: Approved

The method is well-implemented with appropriate checks and formatting for Docker environment variables. It handles special cases and filters out empty or undefined values effectively.


38-39: Addition of SCOPED_REGISTRY_URL and PRIVATE_REGISTRY_TOKEN: Approved with suggestions

The addition of these environment variables supports the PR's objective to enhance UPM registry support on Windows runners. Ensure that the values for these variables are securely handled, especially PRIVATE_REGISTRY_TOKEN, which should not be exposed in logs or error messages.

Verification successful

Verification Successful: PRIVATE_REGISTRY_TOKEN is Securely Handled

The PRIVATE_REGISTRY_TOKEN is set and used as expected without being exposed in logs or error messages. The implementation aligns with the security requirements. No further action is needed regarding this concern.

  • src/model/image-environment-factory.ts: Environment variable setup.
  • src/model/platform-setup/setup-mac.ts: Environment variable assignment.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that PRIVATE_REGISTRY_TOKEN is not exposed in logs or error messages.

# Test: Search for PRIVATE_REGISTRY_TOKEN in logs. Expect: No occurrences.
rg --type ts -A 5 $'PRIVATE_REGISTRY_TOKEN'

Length of output: 1074

action.yml (1)

264-267: Well-documented addition of scopedRegistryUrl.

The new input parameter scopedRegistryUrl is well-integrated into the action's configuration. It is marked as optional and has a sensible default of an empty string, which ensures backward compatibility. The description is clear and specifies the condition under which this parameter should be used (packageMode is true), which helps in avoiding confusion for the users.

Comment on lines +97 to +98
public scopedRegistryUrl!: string;
public upmRegistryToken!: string;
Copy link

Choose a reason for hiding this comment

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

Addition of scopedRegistryUrl and upmRegistryToken.

The new properties scopedRegistryUrl and upmRegistryToken are added to the BuildParameters class to support enhanced package management capabilities. These properties are correctly declared and integrated into the class's structure. However, it would be beneficial to add documentation comments for these new properties to improve code maintainability and clarity for other developers.

Consider adding documentation comments above these properties:

// URL of the scoped registry used for resolving package dependencies.
public scopedRegistryUrl!: string;

// Token for authenticating with the UPM registry.
public upmRegistryToken!: string;

Comment on lines +193 to +194
process.env.PRIVATE_REGISTRY_TOKEN = buildParameters.upmRegistryToken;
process.env.SCOPED_REGISTRY_URL = buildParameters.scopedRegistryUrl;
Copy link

Choose a reason for hiding this comment

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

Ensure secure handling of sensitive environment variables.

The addition of PRIVATE_REGISTRY_TOKEN and SCOPED_REGISTRY_URL to the environment variables is crucial for supporting private registries. However, ensure that these tokens are handled securely, especially since environment variables can be exposed in logs or error messages. Consider masking these values in logs or using more secure storage mechanisms if applicable.

Comment on lines +244 to +254
static get scopedRegistryUrl(): string {
const input = Input.getInput('scopedRegistryUrl') ?? '';

return input !== '' ? input : '';
}

static get upmRegistryToken(): string {
const input = Input.getInput('UPM_REGISTRY_TOKEN') ?? '';

return input !== '' ? input : '';
}
Copy link

Choose a reason for hiding this comment

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

Review new getter methods for handling registry configurations.

The addition of scopedRegistryUrl and upmRegistryToken methods in the Input class is a positive step towards enhancing configuration flexibility. However, ensure that these methods handle cases where inputs might be absent or malformed. The current implementation defaults to an empty string if the input is not provided, which is a safe default but might lead to runtime errors if not handled properly elsewhere in the code. Consider adding validation or logging to inform when these inputs are not provided.

@Shaun-Fong Shaun-Fong closed this Aug 31, 2024
@Shaun-Fong Shaun-Fong reopened this Aug 31, 2024
Copy link

Cat Gif

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.

1 participant