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/json config #80

Merged
merged 12 commits into from
May 10, 2024
Merged

Feat/json config #80

merged 12 commits into from
May 10, 2024

Conversation

Renato66
Copy link
Owner

@Renato66 Renato66 commented May 8, 2024

closes #79

@Renato66 Renato66 self-assigned this May 8, 2024
Copy link
Contributor

coderabbitai bot commented May 8, 2024

Warning

Rate Limit Exceeded

@Renato66 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 23 minutes and 39 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.

Commits Files that changed from the base of the PR and between a71cd62 and 7cb2c29.

Walkthrough

The recent changes encompass a shift to JSON5 for managing GitHub Actions inputs, particularly for automating issue labeling. This involves introducing a new configuration file format, updating the workflow for automatic issue labeling, and enhancing domain logic to handle label configurations based on this new format. The addition of the json5 dependency streamlines JSON5 file operations within the project.

Changes

Files Change Summary
.github/workflows/auto-label.json5, .github/workflows/auto-label.yml Introduce label settings and update issue labeling workflow.
package.json Add json5 package as a dependency.
src/domain/getConfigFile.ts, src/domain/getJsonFile.ts Update for JSON5 parsing and configuration handling.
.prettierignore Add auto-label.json5 to the project.

Assessment against linked issues

Objective Addressed Explanation
Refactor to use JSON instead of .yml to handle action inputs (#79)

Poem

Within the code's intricate dance,
JSON5 brings a fresh chance. 🌟
Labels align to a JSON tune,
Issues organized under the moon.
In the coding domain, a rabbit's glee,
Progress leaps on, wild and free! 🐇🌌


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.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

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

CodeRabbit Configration 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
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 30beb16 and a528db7.
Files ignored due to path filters (1)
  • bun.lockb is excluded by !bun.lockb
Files selected for processing (5)
  • .github/workflows/auto-label.json5 (1 hunks)
  • .github/workflows/auto-label.yml (1 hunks)
  • package.json (1 hunks)
  • src/domain/getConfigFile.ts (1 hunks)
  • src/domain/getJsonFile.ts (1 hunks)
Files skipped from review due to trivial changes (2)
  • .github/workflows/auto-label.json5
  • .github/workflows/auto-label.yml
Additional comments not posted (5)
package.json (1)

24-25: The addition of json5 as a dependency aligns with the project's transition to JSON5 for configuration. The version constraint "^2.2.3" is appropriate for receiving updates while maintaining compatibility.

src/domain/getConfigFile.ts (3)

2-2: The import of getLabelConfigs from ./getJsonFile is correctly added to support the new JSON5 configuration handling.


4-9: The expanded Config type definition appropriately includes new fields such as labelsNotAllowed, defaultLabels, labelsSynonyms, and ignoreComments, aligning with the new JSON5 configuration requirements.


11-28: The modifications to getConfigFile function correctly integrate the new JSON5 configuration handling. The use of getLabelConfigs to fetch configurations is appropriate and aligns with the transition to JSON5.

src/domain/getJsonFile.ts (1)

6-24: The implementation of getLabelConfigs function is robust, correctly checking for file existence before reading, and using JSON5 for parsing. The error handling using core.warning is appropriate for actions, providing feedback without failing the workflow unnecessarily.

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

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between a528db7 and 463a660.
Files selected for processing (4)
  • .github/workflows/auto-label.yml (1 hunks)
  • .prettierignore (1 hunks)
  • src/domain/getConfigFile.ts (1 hunks)
  • src/domain/getJsonFile.ts (1 hunks)
Files skipped from review due to trivial changes (1)
  • .prettierignore
Files skipped from review as they are similar to previous changes (2)
  • .github/workflows/auto-label.yml
  • src/domain/getConfigFile.ts
Additional Context Used
GitHub Check Runs (1)
build failure (5)

src/domain/getJsonFile.ts: [failure] 8-8: TypeError: path must be a string or a file descriptor

  at getLabelConfigs (/home/runner/work/auto-label/auto-label/src/domain/getJsonFile.ts:8:23)
  at getConfigFile (/home/runner/work/auto-label/auto-label/src/domain/getConfigFile.ts:23:18)
  at /home/runner/work/auto-label/auto-label/src/runner.ts:20:7
  at run (/home/runner/work/auto-label/auto-label/src/runner.ts:10:26)
  at /home/runner/work/auto-label/auto-label/src/runner.spec.ts:38:11
  at /home/runner/work/auto-label/auto-label/src/runner.spec.ts:37:41

src/domain/getJsonFile.ts: [failure] 8-8: TypeError: path must be a string or a file descriptor

  at getLabelConfigs (/home/runner/work/auto-label/auto-label/src/domain/getJsonFile.ts:8:23)
  at getConfigFile (/home/runner/work/auto-label/auto-label/src/domain/getConfigFile.ts:23:18)
  at /home/runner/work/auto-label/auto-label/src/domain/getConfigFile.spec.ts:14:21

src/domain/getJsonFile.ts: [failure] 8-8: ENOENT: No such file or directory

  at getLabelConfigs (/home/runner/work/auto-label/auto-label/src/domain/getJsonFile.ts:8:23)
  at getConfigFile (/home/runner/work/auto-label/auto-label/src/domain/getConfigFile.ts:23:18)
  at /home/runner/work/auto-label/auto-label/src/domain/getConfigFile.spec.ts:28:20
Additional comments not posted (1)
src/domain/getJsonFile.ts (1)

8-8: Ensure the file path is correctly handled when reading the file.

This script checks all usages of getLabelConfigs to ensure that the path argument passed is always a valid string, addressing the type error reported by the static analysis tool.

Verification successful

The verification process confirms that the file path (configPath) used in fs.readFileSync within getLabelConfigs is correctly handled as a string. This is ensured by the use of getInput<string> in src/domain/getConfigFile.ts, which explicitly defines the type of configPath as a string. Therefore, the concerns raised in the review comment are addressed.

  • File and Line: src/domain/getConfigFile.ts, line where getInput<string> is called for configPath.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the file path passed to `fs.readFileSync` is always a valid string.

# Test: Search for all usages of `getLabelConfigs` to ensure the path argument is always a string.
rg --type typescript $'getLabelConfigs\\('

Length of output: 77



Script:

#!/bin/bash
# Description: Verify that the file path passed to `fs.readFileSync` is always a valid string.

# Corrected Test: Search for all usages of `getLabelConfigs` to ensure the path argument is always a string.
rg --type ts $'getLabelConfigs\\('

Length of output: 107



Script:

#!/bin/bash
# Description: Extract the definition and usage of `configPath` in `src/domain/getConfigFile.ts`.

# Extract lines around the usage of `configPath`.
rg --type ts --context 5 'configPath' src/domain/getConfigFile.ts

Length of output: 701

src/domain/getJsonFile.ts Outdated Show resolved Hide resolved
src/domain/getJsonFile.ts Outdated Show resolved Hide resolved
src/domain/getJsonFile.ts 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: 2

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 463a660 and 062519c.
Files selected for processing (16)
  • .github/workflows/auto-label.json5 (1 hunks)
  • .prettierignore (1 hunks)
  • src/mock/config/config.json (1 hunks)
  • src/mock/config/config.json5 (1 hunks)
  • src/mock/config/config.jsonc (1 hunks)
  • src/mock/config/empty.json (1 hunks)
  • src/mock/config/invalid/invalid1.json (1 hunks)
  • src/mock/config/invalid/invalid2.json (1 hunks)
  • src/mock/config/invalid/invalid3.json (1 hunks)
  • src/mock/config/valid/valid.json (1 hunks)
  • src/domain/getConfigFile.spec.ts (2 hunks)
  • src/domain/getConfigFile.ts (1 hunks)
  • src/domain/getInput.ts (1 hunks)
  • src/domain/getLabelConfigs.spec.ts (1 hunks)
  • src/domain/getLabelConfigs.ts (1 hunks)
  • src/runner.spec.ts (1 hunks)
Files skipped from review due to trivial changes (8)
  • src/mock/config/config.json
  • src/mock/config/config.json5
  • src/mock/config/config.jsonc
  • src/mock/config/empty.json
  • src/mock/config/invalid/invalid1.json
  • src/mock/config/invalid/invalid2.json
  • src/mock/config/invalid/invalid3.json
  • src/mock/config/valid/valid.json
Files skipped from review as they are similar to previous changes (3)
  • .github/workflows/auto-label.json5
  • .prettierignore
  • src/domain/getConfigFile.ts
Additional comments not posted (3)
src/runner.spec.ts (1)

38-47: The changes to the mock setup for getInput are correctly implemented to provide specific responses based on the input.

src/domain/getLabelConfigs.spec.ts (1)

1-55: The test cases added for getLabelConfigs function are comprehensive and well-structured, covering both valid and invalid scenarios effectively.

src/domain/getConfigFile.spec.ts (1)

Line range hint 11-46: The changes to the mock setup for getInput are correctly implemented to provide specific responses based on the input, facilitating accurate testing of the getConfigFile function.

src/domain/getInput.ts Show resolved Hide resolved
src/domain/getLabelConfigs.ts 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: 3

Out of diff range and nitpick comments (3)
README.md (3)

Line range hint 142-142: Add the missing closing bracket ] for proper markdown formatting.

- thanks to [@dielduarte](https://github.com/dielduarte) and [@PauloGoncalvesBH](https://github.com/Pa...
+ thanks to [@dielduarte](https://github.com/dielduarte) and [@PauloGoncalvesBH](https://github.com/PauloGoncalvesBH)]

Line range hint 71-71: Specify the language for the fenced code block to enable proper syntax highlighting.

- ```
+ ```yml

Line range hint 135-135: Specify the language for the fenced code block to enable proper syntax highlighting.

- ```
+ ```json
Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 062519c and 7f3ac23.
Files selected for processing (8)
  • .github/workflows/auto-label.yml (1 hunks)
  • README.md (3 hunks)
  • src/mock/config/auto-label.json (1 hunks)
  • src/mock/config/auto-label.json5 (1 hunks)
  • src/mock/config/auto-label.jsonc (1 hunks)
  • src/domain/getConfigFile.ts (1 hunks)
  • src/domain/getLabelConfigs.spec.ts (1 hunks)
  • src/domain/getLabelConfigs.ts (1 hunks)
Files skipped from review due to trivial changes (3)
  • src/mock/config/auto-label.json
  • src/mock/config/auto-label.json5
  • src/mock/config/auto-label.jsonc
Files skipped from review as they are similar to previous changes (4)
  • .github/workflows/auto-label.yml
  • src/domain/getConfigFile.ts
  • src/domain/getLabelConfigs.spec.ts
  • src/domain/getLabelConfigs.ts
Additional Context Used
LanguageTool (4)
README.md (4)

Near line 97: The word “checkout” is a noun. The verb is spelled with a space.
Context: ...ore your configuration file, you should checkout and point with configuration-file inp...


Near line 142: Unpaired symbol: ‘]’ seems to be missing
Context: ...rte](https://github.com/dielduarte) and [@PauloGoncalvesBH](https://github.com/Pa...


Near line 146: To elevate your writing, try using a synonym here.
Context: ...a label like C: VCombobox it would be hard to match the label in a normal issue, b...


Near line 154: A comma might be missing here.
Context: ...wed Some labels are restricted to repo owners such as needs priority testing `won...

Additional comments not posted (3)
README.md (3)

12-12: Ensure the workflow file auto-label.yml is correctly placed and configured as per the new JSON5 settings.


23-28: The checkout action uses version 4, which is the latest major version. Ensure that all features used here are compatible with this version.


33-53: The JSON5 configuration file is well-formed and includes necessary settings. Ensure that the file is correctly parsed by the application.

Verification successful

The test file src/domain/getLabelConfigs.spec.ts includes tests that verify the parsing of the auto-label.json5 configuration file. The tests check if the function getLabelConfigs can correctly read and parse the configuration from the specified path, and they compare the result against a predefined defaultConfig. The tests cover scenarios where the configuration is valid, invalid, and unreadable, ensuring that the function behaves as expected in different situations.

Given this information, it appears that the application does include logic to parse the auto-label.json5 file and that this functionality is covered by automated tests. This aligns with the review comment's request to ensure that the file is correctly parsed by the application.

Final Response:

The application includes automated tests to verify the parsing of the auto-label.json5 configuration file, as seen in src/domain/getLabelConfigs.spec.ts. These tests confirm that the application can correctly parse and apply settings from this file.

  • Test File: src/domain/getLabelConfigs.spec.ts
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify parsing of `auto-label.json5`.

# Test: Check if the application correctly parses `auto-label.json5` and applies settings.
echo "Please manually verify that the application correctly parses and applies settings from `auto-label.json5`."

Length of output: 290



Script:

#!/bin/bash
# Check if `auto-label.json5` exists in the repository
fd auto-label.json5

# Search for code snippets that might be parsing `auto-label.json5`
rg "auto-label.json5" --files-with-matches

Length of output: 146



Script:

#!/bin/bash
# Retrieve the content of the file that likely contains logic for parsing `auto-label.json5`
cat src/domain/getLabelConfigs.spec.ts

Length of output: 1779

README.md Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md 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: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 7f3ac23 and a71cd62.
Files selected for processing (3)
  • .prettierignore (1 hunks)
  • src/domain/getLabelConfigs.spec.ts (1 hunks)
  • src/domain/getLabelConfigs.ts (1 hunks)
Files skipped from review as they are similar to previous changes (3)
  • .prettierignore
  • src/domain/getLabelConfigs.spec.ts
  • src/domain/getLabelConfigs.ts

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@Renato66 Renato66 merged commit e5af195 into main May 10, 2024
1 check passed
@Renato66 Renato66 deleted the feat/json-config branch May 10, 2024 23:05
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.

refactor to use json instead of .yml to handle action inputs
2 participants