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

fix: Escape dependency jar lock file's name (#77) #79

Merged
merged 2 commits into from
Aug 3, 2024
Merged

fix: Escape dependency jar lock file's name (#77) #79

merged 2 commits into from
Aug 3, 2024

Conversation

warnyul
Copy link
Member

@warnyul warnyul commented Jul 31, 2024

Summary

  • CI
    • Enhanced build process with cross-platform support, allowing builds to run on both Ubuntu and Windows environments.
  • Fix
    - Escape special characters for the name of dependency jar's lock file.

Summary by CodeRabbit

  • New Features

    • Enhanced build process with cross-platform support, allowing builds to run on both Ubuntu and Windows environments.
  • Improvements

    • Improved file handling in the dependency resolution process by sanitizing file names, reducing potential errors related to invalid characters.
    • Reports are now labeled according to the operating system used during the build process, improving clarity.
    • Increased testing versatility with updated artifact upload conditions, ensuring reports are always uploaded.

@warnyul warnyul self-assigned this Jul 31, 2024
Copy link
Contributor

coderabbitai bot commented Jul 31, 2024

Walkthrough

The recent updates enhance the GitHub Actions workflow by introducing a strategy matrix for the build, junit, and kover jobs, enabling them to run across both ubuntu-22.04 and windows-2022, improving cross-platform testing capabilities. Additionally, the JUnit5MavenDependencyResolver class has been updated to ensure valid file names for dependency jars, enhancing robustness and maintainability.

Changes

File Path Change Summary
.github/workflows/build.yml Modified build, junit, and kover jobs to use a strategy matrix for runs-on, enabling builds on Ubuntu and Windows; updated artifact names and ensured reports upload regardless of job outcomes.
robolectric-extension/src/main/kotlin/.../JUnit5MavenDependencyResolver.kt Enhanced createLockFile method to sanitize dependency jar names; added a constant for regex to improve maintainability.

Poem

In the meadow where we play,
New builds spring forth, hip-hip-hooray!
With Windows and Ubuntu too,
Cross-platform dreams now come true!
Hopping high with agile cheer,
Our code takes flight, no need to fear! 🐇✨


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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

@warnyul warnyul changed the title ci: Setup build job for Windows ci: Setup build job for Windows (#77) Jul 31, 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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1c9d036 and 0457290.

Files selected for processing (1)
  • .github/workflows/build.yml (1 hunks)
Additional comments not posted (1)
.github/workflows/build.yml (1)

18-21: LGTM! Ensure correct usage of the matrix.os variable.

The strategy matrix is correctly implemented, allowing the build job to run on both Ubuntu and Windows environments.

However, verify that the matrix.os variable is correctly used in the runs-on attribute.

@warnyul warnyul changed the title ci: Setup build job for Windows (#77) fix: Escape dependency jar lock file's name (#77) Jul 31, 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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0457290 and c307591.

Files selected for processing (2)
  • .github/workflows/build.yml (1 hunks)
  • robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5MavenDependencyResolver.kt (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/build.yml
Additional comments not posted (2)
robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5MavenDependencyResolver.kt (2)

88-90: LGTM!

The addition of the private companion object encapsulating the regex pattern improves code organization and maintainability.


66-67: LGTM! Verify the regex pattern.

The changes to sanitize the shortName using a regex pattern improve the robustness of file handling.

However, ensure that the regex pattern correctly identifies all special characters that need to be replaced.

Verification successful

Regex pattern verification successful.

The regex pattern correctly identifies and replaces special characters with underscores, ensuring valid file names.

  • test<name>.jar was successfully transformed to test_name_.jar.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the regex pattern for sanitizing file names.

# Test: Check if the regex pattern correctly identifies special characters.
echo 'test<name>.jar' | sed 's/[<>:"\\/|\?\*]/_/g'

Length of output: 67

@warnyul warnyul added the bug Something isn't working label Jul 31, 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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c307591 and 6c6679f.

Files selected for processing (2)
  • .github/workflows/build.yml (5 hunks)
  • robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5MavenDependencyResolver.kt (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5MavenDependencyResolver.kt
Additional comments not posted (3)
.github/workflows/build.yml (3)

18-21: LGTM! The strategy matrix enhances cross-platform build capabilities.

The introduction of the strategy matrix for the build job allows the workflow to run on both ubuntu-22.04 and windows-2022, improving cross-platform capabilities.


66-69: LGTM! The artifact name update ensures correct labeling.

Updating the artifact name to include the OS key ensures that the unit test reports are correctly labeled according to the operating system used during the build process.


75-78: LGTM! The artifact name update ensures correct labeling.

Updating the artifact name to include the OS key ensures that the coverage reports are correctly labeled according to the operating system used during the build process.

.github/workflows/build.yml Outdated Show resolved Hide resolved
.github/workflows/build.yml Outdated Show resolved Hide resolved
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: 1

Outside diff range, codebase verification and nitpick comments (1)
robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/FakeMavenManifestFactory.kt (1)

1-2: Add a class-level comment.

Consider adding a comment to describe the purpose of this class, especially since it appears to be a mock implementation for testing.

/**
 * A mock implementation of MavenManifestFactory for testing purposes.
 */
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 6c6679f and 15d7e06.

Files selected for processing (3)
  • .github/workflows/build.yml (5 hunks)
  • robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/FakeMavenManifestFactory.kt (1 hunks)
  • robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5RobolectricTestRunner.kt (2 hunks)
Additional comments not posted (7)
robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/FakeMavenManifestFactory.kt (1)

15-35: Handle potential null values and edge cases.

Ensure that the identify method handles potential null values and edge cases, such as when resourceUrl is null or the path cannot be relativized.

override fun identify(config: Config): ManifestIdentifier {
    val manifestPath = config.manifest
    if (manifestPath == Config.NONE) {
        return ManifestIdentifier(null as String?, null, null, null, null)
    }

    val manifestFile: Path
    val resourceName = if (manifestPath.startsWith("/")) manifestPath else ("/$manifestPath")
    val resourceUrl = javaClass.getResource(resourceName)
    if (resourceUrl != null && "file" == resourceUrl.protocol) {
        val workingDirectory = Paths.get(System.getProperty("user.dir"))
        val absolutePath = Fs.fromUrl(resourceUrl)
        logger.warn { "user.dir=$workingDirectory" }
        logger.warn { "resourceUrl=$resourceUrl" }
        logger.warn { "absolutePath=$absolutePath" }

        manifestFile = workingDirectory.relativize(absolutePath)
        return super.identify(config)
    } else {
        logger.error { "Manifest file not found: $resourceName" }
        return ManifestIdentifier(null as String?, null, null, null, null)
    }
}
robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5RobolectricTestRunner.kt (1)

123-123: LGTM!

The addition of the binding for ManifestFactory to FakeMavenManifestFactory enhances the test runner's flexibility and configurability.

.github/workflows/build.yml (5)

18-21: LGTM!

The introduction of the strategy matrix for running on multiple operating systems enhances the build process's cross-platform capabilities.


65-67: Update artifact name to use OS key for consistency.

The unit test report download step in the junit job uses a hardcoded artifact name. Update it to use the OS key to ensure consistency with the build job.

-          name: ubuntu-unit-test-report
+          name: ${{ matrix.os }}-unit-test-report

74-76: Update artifact name to use OS key for consistency.

The coverage report download step in the kover job uses a hardcoded artifact name. Update it to use the OS key to ensure consistency with the build job.

-          name: ubuntu-kover-report
+          name: ${{ matrix.os }}-kover-report

101-104: LGTM!

The introduction of the strategy matrix for running on multiple operating systems enhances the testing process's cross-platform capabilities.


124-127: LGTM!

The introduction of the strategy matrix for running on multiple operating systems enhances the testing process's cross-platform capabilities.

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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 15d7e06 and 295c368.

Files selected for processing (2)
  • robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/FakeMavenManifestFactory.kt (1 hunks)
  • robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5RobolectricTestRunner.kt (2 hunks)
Files skipped from review as they are similar to previous changes (2)
  • robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/FakeMavenManifestFactory.kt
  • robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5RobolectricTestRunner.kt

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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 295c368 and 13d9245.

Files selected for processing (3)
  • robolectric-extension/build.gradle (1 hunks)
  • robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/FakeMavenManifestFactory.kt (1 hunks)
  • robolectric-extension/src/test/resources/logging.properties (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/FakeMavenManifestFactory.kt
Additional comments not posted (3)
robolectric-extension/src/test/resources/logging.properties (2)

23-23: Increased verbosity in global logging level.

The global logging level has been changed to FINEST, which increases the verbosity of logs. Ensure that this change is intentional, as it may generate a large amount of log data.


25-25: Increased verbosity in ConsoleHandler logging level.

The logging level for ConsoleHandler has been changed to FINEST, which will result in more detailed logs being printed to the console. Ensure that this change is necessary, as it may lead to an overwhelming amount of log data.

robolectric-extension/build.gradle (1)

29-29: Forcing tests to always run.

The outputs.upToDateWhen condition is set to always return false, ensuring that tests are always executed. This is useful for consistent testing but may lead to longer build times.

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: 0

Outside diff range, codebase verification and nitpick comments (1)
robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5RobolectricTestRunner.kt (1)

46-52: Issue Found: Self-referential definition of buildSystemApiProperties

The variable buildSystemApiProperties is defined as val buildSystemApiProperties: Properties? = buildSystemApiProperties, which is self-referential and will cause a compilation error. This needs to be corrected to ensure proper functionality.

  • File: robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5RobolectricTestRunner.kt
  • Line: 46

Please define buildSystemApiProperties correctly before using it in the getManifestFactory method.

Analysis chain

LGTM! But verify the correctness of buildSystemApiProperties.

The code changes are approved.

However, ensure that buildSystemApiProperties is correctly defined and used within the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of `buildSystemApiProperties`.

# Test: Search for the definition and usage of `buildSystemApiProperties`. Expect: Correct definition and usage.
rg --type kotlin -A 5 $'buildSystemApiProperties'

Length of output: 1296


Script:

#!/bin/bash
# Description: Search for the definition of `buildSystemApiProperties` within the entire codebase.

# Test: Search for the definition of `buildSystemApiProperties`. Expect: Correct definition.
rg --type kotlin 'val buildSystemApiProperties'

Length of output: 241

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 13d9245 and be709c3.

Files selected for processing (2)
  • robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/FakeMavenManifestFactory.kt (1 hunks)
  • robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5RobolectricTestRunner.kt (4 hunks)
Files skipped from review as they are similar to previous changes (1)
  • robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/FakeMavenManifestFactory.kt
Additional comments not posted (1)
robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5RobolectricTestRunner.kt (1)

134-134: LGTM! But verify the correctness of the binding.

The code changes are approved.

However, ensure that the binding for ManifestFactory to FakeMavenManifestFactory is correctly defined and used within the codebase.

Verification successful

The binding for ManifestFactory to FakeMavenManifestFactory is correctly defined and used within the codebase.

  • The FakeMavenManifestFactory class extends MavenManifestFactory and overrides the necessary methods.
  • The binding is correctly set up in the JUnit5RobolectricTestRunner file.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of the binding for `ManifestFactory`.

# Test: Search for the usage of `ManifestFactory` and `FakeMavenManifestFactory`. Expect: Correct usage.
rg --type kotlin -A 5 $'ManifestFactory'
rg --type kotlin -A 5 $'FakeMavenManifestFactory'

Length of output: 7628

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: 0

Outside diff range, codebase verification and nitpick comments (1)
.github/workflows/build.yml (1)

18-21: Ensure cross-platform compatibility for setting the Gradle user home directory.

The command $GRADLE_USER_HOME=$RUNNER_TEMP\.gradle uses a Unix-style path separator (/). To ensure compatibility with both Unix and Windows systems, consider using a conditional statement or a cross-platform method for setting the Gradle user home directory.

  • Line 1 of .github/workflows/build.yml: $GRADLE_USER_HOME=$RUNNER_TEMP\.gradle
Analysis chain

LGTM! Ensure shell command compatibility.

The strategy matrix and runs-on changes improve cross-platform compatibility.

Verify that the shell command for changing the Gradle user home is compatible with Windows.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify shell command compatibility for changing Gradle user home on Windows.

# Test: Search for the shell command usage. Expect: Compatible shell command for Windows.
rg --type yaml -A 5 $'name: Change Gradle user home'

Length of output: 53


Script:

#!/bin/bash
# Description: Search for any Gradle-related commands in the GitHub Actions workflow file.

# Test: Search for any Gradle-related commands in the `.github/workflows/build.yml` file.
rg --type yaml 'gradle' .github/workflows/build.yml

Length of output: 340

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between be709c3 and baeaf7c.

Files selected for processing (1)
  • .github/workflows/build.yml (5 hunks)
Additional comments not posted (6)
.github/workflows/build.yml (6)

72-74: LGTM! Artifact upload name updated.

The artifact upload name now includes the OS key, ensuring accurate labeling.


81-83: LGTM! Artifact upload name updated.

The artifact upload name now includes the OS key, ensuring accurate labeling.


108-111: LGTM! Cross-platform compatibility improved.

The strategy matrix and runs-on changes for the junit job improve cross-platform compatibility.


123-123: LGTM! Artifact download name updated.

The artifact download name now includes the OS key, ensuring accurate labeling.


131-134: LGTM! Cross-platform compatibility improved.

The strategy matrix and runs-on changes for the kover job improve cross-platform compatibility.


147-147: LGTM! Artifact download name updated.

The artifact download name now includes the OS key, ensuring accurate labeling.

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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between baeaf7c and 4ba9ce5.

Files selected for processing (1)
  • .github/workflows/build.yml (5 hunks)
Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/build.yml

Copy link

github-actions bot commented Aug 3, 2024

Branch Coverage (ubuntu-22.04)

File Coverage [100.00%]
robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5MavenDependencyResolver.kt 100.00%
Total Project Coverage 69.91%

Copy link

github-actions bot commented Aug 3, 2024

Line Coverage

File Coverage [95.00%]
robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5MavenDependencyResolver.kt 95.00%
Total Project Coverage 92.05%

Copy link

github-actions bot commented Aug 3, 2024

Branch Coverage (windows-2022)

File Coverage [100.00%]
robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5MavenDependencyResolver.kt 100.00%
Total Project Coverage 69.91%

Copy link

github-actions bot commented Aug 3, 2024

Line Coverage (ubuntu-22.04)

File Coverage [95.00%]
robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5MavenDependencyResolver.kt 95.00%
Total Project Coverage 92.05%

Copy link

github-actions bot commented Aug 3, 2024

Line Coverage (windows-2022)

File Coverage [95.00%]
robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5MavenDependencyResolver.kt 95.00%
Total Project Coverage 92.05%

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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4ba9ce5 and 8533449.

Files selected for processing (2)
  • .github/workflows/build.yml (5 hunks)
  • robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5MavenDependencyResolver.kt (2 hunks)
Files skipped from review as they are similar to previous changes (2)
  • .github/workflows/build.yml
  • robolectric-extension/src/main/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5MavenDependencyResolver.kt

@warnyul warnyul merged commit c8dcb14 into main Aug 3, 2024
9 checks passed
@warnyul warnyul deleted the gh-77 branch August 3, 2024 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant