-
Notifications
You must be signed in to change notification settings - Fork 0
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
Release v0.2.0 #13
Conversation
- 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
src/context.rs
Outdated
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) | ||
} |
There was a problem hiding this comment.
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.
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.
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the 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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configration File (
|
Has already been merged. |
Base release with the following features
get_input
set_output
get_context
: Returns a hydrated context objectdebug
info
notice
(with annotations)warn
(with annotations)error
(with annotations)is_debug