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

Release v0.2.0 #13

Closed
wants to merge 19 commits into from
Closed

Release v0.2.0 #13

wants to merge 19 commits into from

Conversation

Bullrich
Copy link
Owner

Base release with the following features

  • get_input
  • set_output
  • get_context: Returns a hydrated context object
  • logging
    • debug
    • info
    • notice (with annotations)
    • warn (with annotations)
    • error (with annotations)
    • is_debug

Bullrich added 18 commits May 24, 2024 11:58
- Created `Context` ([GitHub's documentation for
Contexts](https://docs.github.com/en/actions/learn-github-actions/contexts))
- Added CI tests


## Summary

- **New Features**
- Introduced a continuous integration workflow to automatically run
tests, formatting, linting, and documentation checks on pull requests
and pushes to the main branch.
- Added a `Context` struct to handle context objects injected by GitHub
actions, enabling better retrieval and parsing of event details and
repository information.

- **Dependencies**
  - Added `json` version `0.12.4` as a new dependency.

- **Documentation**
- Included the content of `README.md` in the main module's documentation
for better reference.
Replaced [ciiiii/toml-editor](https://github.com/ciiiii/toml-editor) as
it is not working for a custom pip package.


## Summary


- **Chores**
- Improved the publish workflow by setting up Python and using
`toml-cli` for version management.
Added all missing information like author, repository and license
Else it will not work as a library
Fixed some issues I didn't handle when migrating to a library.

- added `allow-dirty` to the library being pushed (as the version is
updated)
- removed unused `main`
- Copied method from
[core.ts](https://github.com/actions/toolkit/blob/d1df13e178816d69d96bdc5c753b36a66ad03728/packages/core/src/core.ts#L126)
- Extended error to handle lack of input method.

## Summary 

- **New Features**
- Introduced `get_input` function to handle input retrieval with
space-to-underscore conversion.
  - Added `InputNotFound` error variant for better error handling.
- Added method to produce an
[output](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-output-parameter)
- Copied from
[here](https://github.com/actions/toolkit/blob/d1df13e178816d69d96bdc5c753b36a66ad03728/packages/core/src/core.ts#L192)

## Summary

- **Documentation**
- Updated `README.md` to mark the `set_output` method as complete and
included an example of its usage.

- **Bug Fixes**
- Enhanced error handling with a new `Output` variant in the
`ActionsError` enum.

- **Chores**
  - Added `uuid` dependency with `v4` feature for better UUID handling.
Created many methods for logging
- `debug_log`
- `info`
- `warn_log`
- `error_log`
- `notice_log`
- `is_debug`

## Summary

- **New Features**
- Introduced a new logging module with methods for debug, info, warning,
error, and notice messages.
  - Added a function to check if the code is running on a debug runner.

- **Documentation**
- Updated the documentation link in the `Cargo.toml` file and README.md.
- README.md now includes a badge for GitHub Actions and updated code
snippets for usage and installation.

- **Bug Fixes**
- Enhanced error handling for the `set_output` function in the core
module.
Now it returns an error.

Fixes #7
- Added benchmarks with the library
[divan](https://crates.io/crates/divan)
- Added more steps to the required tests


## Summary

- **New Features**
- Introduced benchmarking for input/output handling and logging to
improve performance insights.

- **Chores**
  - Added `divan` dependency for benchmarking.
  - Updated build workflow to include new benchmark steps.
Now the users can point to specific failing lines


## Summary

- **New Features**
- Enhanced logging capabilities with new `LogParameters` for more
detailed log information.
  - Environment variable `LOG_DEBUG` introduced for better log control.
It currently has all the MVP features, so we can properly release it as a working library

More work to come tho
@Bullrich Bullrich self-assigned this May 28, 2024
Repository owner deleted a comment from coderabbitai bot May 28, 2024
src/context.rs Outdated
Comment on lines 59 to 69
if Path::new(&github_event_path).exists() {
match fs::read_to_string(&github_event_path) {
Ok(content) => match json::parse(&content) {
Ok(parsed_json) => payload = parsed_json,
Err(err) => println!("Failed to parse JSON: {}", err),
},
Err(err) => println!("Failed to read file: {}", err),
}
} else {
println!("GITHUB_EVENT_PATH {} does not exist", github_event_path)
}

Choose a reason for hiding this comment

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

Checking that file exists before reading is a discouraged practice. Even though it's fine in most cases, there aren't any guarantees that file will persist between check and the read.

Instead, attempt reading file, and handle the "not found" error as you do here.
Something like this:

            match fs::read_to_string(&github_event_path) {
                Ok(content) => match json::parse(&content) {
                    Ok(parsed_json) => payload = parsed_json,
                    Err(err) => println!("Failed to parse JSON: {}", err),
                },
                Err(err) if err.kind() === ErrorKind::NotFound => {
                    println!("GITHUB_EVENT_PATH {} does not exist", github_event_path),
                },
                Err(err) => println!("Failed to read file: {}", err),
            }

However, with two error handlers being basically identical, you can simply drop the if Path::new(&github_event_path).exists() { clause.

@Bullrich Bullrich mentioned this pull request Jun 4, 2024
Thanks to @mutantcornholio in #13, we can optimize the method to read
the context to follow better practices.


## Summary

- **Refactor**
- Improved error handling for reading and parsing JSON files to enhance
reliability and user experience.
Copy link

coderabbitai bot commented Jun 4, 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.


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

@Bullrich
Copy link
Owner Author

Has already been merged.

@Bullrich Bullrich closed this Aug 15, 2024
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