-
Notifications
You must be signed in to change notification settings - Fork 2
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
Implements plugin to notify new release #18
base: main
Are you sure you want to change the base?
Implements plugin to notify new release #18
Conversation
[package] | ||
name = "sleppa_notifier" | ||
description = "Send a pos to a collaboration platform when a new release is published." | ||
version = "0.1.0" |
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.
Perhaps better to set the version to 0.0.0-semver
. However, this means we shall change local references in Cargo.toml
files accordingly, like:
sleppa_notifier = { path = "../sleppa_other_package }
@@ -0,0 +1,7 @@ | |||
/// This module regroups all the constants used in the `sleppa_notifier` crate. |
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.
Constants declaration module.
#[derive(thiserror::Error, Debug)] | ||
pub enum NotifierError { | ||
/// No match found when capturing the number with the regex | ||
#[error("An error occured: {0}.")] |
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.
Note really an explanatory message. Can you be more precise about the nature of this error?
InvalidContext(String), | ||
} | ||
|
||
/// Definition of the commit analyzer result |
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.
Wrong comment
|
||
/// Defines the CreatePost object defined by Mattermost's API | ||
#[derive(Debug, Serialize, Deserialize)] | ||
pub struct CreatePost { |
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.
No verb in data structure. This is not an intention or an action.
/// to login into the instance, an HTTP client and the token to authenticate to. | ||
/// The authentication_token is required. A session token should be retrieved if the authentication is made by | ||
/// an user login. The [login] method does this process. | ||
pub struct Mattermost { |
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.
This is not a Mattermost instance. This does not mean anything. This is more a MM client
} | ||
} | ||
|
||
impl Mattermost { |
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.
MattermostClient
will be a better name
Ok(()) | ||
} | ||
|
||
/// Posts a new message on a Mattermost intance. |
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.
Posts a new message on a Mattermost channel.
|
||
/// Posts a new message on a Mattermost intance. | ||
/// | ||
/// This method posts a given [Post] on the specified Mattermost instance. |
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.
You do not publish on an 'instance'. The comment is not correct.
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.
Something went wrong while saving my first CR. Don't consider this one :)
Description
This pull request implements a plugin to notify a new release on a collaboration platform such as Mattermost, Zulip or Slack.
The plugin uses the context to access the new tag of the repository.
The plugin is generic over the platform and provides a trait
Notify
with an associated methodnotify_release
to publish the post.The posted message looks like :
New release v3.2.1 !
wherev3.2.1
is the new tag.At first, the plugin works with Mattermost only by providing a module named
mattermost
.To post on this platform, the module should access a user with
create_post
persmission in the specified channel.The channel to post to is defined by its
channel_id
which can be retrieved with the team name and GUID :https://your-mattermost-url.com/api/v4/teams
https://your-mattermost-url.com/api/v4/teams/{team_id}/channels/name/{channel_name}
More API's information on :
Related issues
closes #17
How has this been tested?
The crates contain unit tests in the file
tests.rs
.Test configuration:
Rust cargo test
Checklist: