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

Implements plugin to notify new release #18

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

GuiBL4
Copy link
Contributor

@GuiBL4 GuiBL4 commented May 30, 2023

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 method notify_release to publish the post.
The posted message looks like : New release v3.2.1 ! where v3.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 :

  • team_id could be retrieved by a GET request on https://your-mattermost-url.com/api/v4/teams
  • channel_id could be retrieved by a GET request on 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:

  • Firmware version: Ubuntu 22.10
  • Hardware: Intel i5-5200U, 4.0GiB RAM
  • Toolchain: Rust cargo test
  • SDK: -

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

crates/sleppa_notifier/Cargo.toml Show resolved Hide resolved
[package]
name = "sleppa_notifier"
description = "Send a pos to a collaboration platform when a new release is published."
version = "0.1.0"

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.

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}.")]

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

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 {

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 {

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 {

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.

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.

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.

Copy link

@binadamu-isiyoonekana binadamu-isiyoonekana left a 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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: status: in progress
Development

Successfully merging this pull request may close these issues.

Implements plugin to notify new release
2 participants