refactor: macros use a more common syntax
Some checks failed
Rust / build (push) Successful in 1m15s
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/push-next Pipeline was successful
ci/woodpecker/push/tag-created Pipeline was successful
Release Please / Release-plz (push) Failing after 10m22s
ci/woodpecker/cron/cron-docker-builder Pipeline was successful
ci/woodpecker/cron/push-next Pipeline was successful
ci/woodpecker/cron/tag-created Pipeline was successful
Some checks failed
Rust / build (push) Successful in 1m15s
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/push-next Pipeline was successful
ci/woodpecker/push/tag-created Pipeline was successful
Release Please / Release-plz (push) Failing after 10m22s
ci/woodpecker/cron/cron-docker-builder Pipeline was successful
ci/woodpecker/cron/push-next Pipeline was successful
ci/woodpecker/cron/tag-created Pipeline was successful
Parameters were separated by ':', but are now separated by ','.
This commit is contained in:
parent
ad358ad7c2
commit
8c19680056
18 changed files with 215 additions and 57 deletions
|
@ -1,6 +1,10 @@
|
|||
//
|
||||
use git_next_core::{git::UserNotification, message, server::Shout};
|
||||
|
||||
message!(UpdateShout: Shout: "Updated Shout configuration");
|
||||
message!(UpdateShout, Shout, "Updated Shout configuration");
|
||||
|
||||
message!(NotifyUser: UserNotification: "Request to send the message payload to the notification webhook");
|
||||
message!(
|
||||
NotifyUser,
|
||||
UserNotification,
|
||||
"Request to send the message payload to the notification webhook"
|
||||
);
|
||||
|
|
|
@ -6,22 +6,37 @@ use git_next_core::{
|
|||
message, newtype, ForgeNotification, RegisteredWebhook, RepoConfig, WebhookAuth, WebhookId,
|
||||
};
|
||||
|
||||
message!(LoadConfigFromRepo: "Request to load the `git-next.toml` from the git repo.");
|
||||
message!(CloneRepo: "Request to clone (or open) the git repo.");
|
||||
message!(ReceiveRepoConfig: RepoConfig: r#"Notification that the `git-next.toml` file has been loaded from the repo and parsed.
|
||||
message!(
|
||||
LoadConfigFromRepo,
|
||||
"Request to load the `git-next.toml` from the git repo."
|
||||
);
|
||||
message!(CloneRepo, "Request to clone (or open) the git repo.");
|
||||
message!(
|
||||
ReceiveRepoConfig,
|
||||
RepoConfig,
|
||||
r#"Notification that the `git-next.toml` file has been loaded from the repo and parsed.
|
||||
|
||||
Contains the parsed contents of the `git-next.toml` file."#);
|
||||
message!(ValidateRepo: MessageToken: r#"Request that the state of the branches in the git repo be assessed and generate any followup actions.
|
||||
Contains the parsed contents of the `git-next.toml` file."#
|
||||
);
|
||||
message!(
|
||||
ValidateRepo,
|
||||
MessageToken,
|
||||
r#"Request that the state of the branches in the git repo be assessed and generate any followup actions.
|
||||
|
||||
This is the main function of `git-next` where decisions are made on what branches need to be updated and when.
|
||||
|
||||
Contains a [MessageToken] to reduce duplicate messages being sent. Only messages with the latest [MessageToken] are handled,
|
||||
all others are dropped."#);
|
||||
all others are dropped."#
|
||||
);
|
||||
|
||||
message!(WebhookRegistered: (WebhookId, WebhookAuth): r#"Notification that a webhook has been registered with a forge.
|
||||
message!(
|
||||
WebhookRegistered,
|
||||
(WebhookId, WebhookAuth),
|
||||
r#"Notification that a webhook has been registered with a forge.
|
||||
|
||||
Contains a tuple of the ID for the webhook returned from the forge, and the unique authorisation token that
|
||||
incoming messages from the forge must provide."#);
|
||||
incoming messages from the forge must provide."#
|
||||
);
|
||||
impl WebhookRegistered {
|
||||
pub const fn webhook_id(&self) -> &WebhookId {
|
||||
&self.0 .0
|
||||
|
@ -38,28 +53,51 @@ impl From<RegisteredWebhook> for WebhookRegistered {
|
|||
}
|
||||
}
|
||||
|
||||
message!(UnRegisterWebhook: "Request that the webhook be removed from the forge, so they will stop notifying us.");
|
||||
message!(
|
||||
UnRegisterWebhook,
|
||||
"Request that the webhook be removed from the forge, so they will stop notifying us."
|
||||
);
|
||||
|
||||
newtype!(MessageToken: u32, Copy, Default, Display, PartialOrd, Ord: r#"An incremental token used to identify the current set of messages.
|
||||
newtype!(
|
||||
MessageToken,
|
||||
u32,
|
||||
Copy,
|
||||
Default,
|
||||
Display,
|
||||
PartialOrd,
|
||||
Ord,
|
||||
r#"An incremental token used to identify the current set of messages.
|
||||
|
||||
Primarily used by [ValidateRepo] to reduce duplicate messages. The token is incremented when a new Webhook message is
|
||||
received, marking that message the latest, and causing any previous messages still being processed to be dropped when
|
||||
they next send a [ValidateRepo] message."#);
|
||||
they next send a [ValidateRepo] message."#
|
||||
);
|
||||
impl MessageToken {
|
||||
pub const fn next(self) -> Self {
|
||||
Self(self.0 + 1)
|
||||
}
|
||||
}
|
||||
|
||||
message!(RegisterWebhook: "Requests that a Webhook be registered with the forge.");
|
||||
message!(CheckCIStatus: Commit: r#"Requests that the CI status for the commit be checked.
|
||||
message!(
|
||||
RegisterWebhook,
|
||||
"Requests that a Webhook be registered with the forge."
|
||||
);
|
||||
message!(
|
||||
CheckCIStatus,
|
||||
Commit,
|
||||
r#"Requests that the CI status for the commit be checked.
|
||||
|
||||
Once the CI Status has been received it will be sent via a [ReceiveCIStatus] message.
|
||||
|
||||
Contains the commit from the tip of the `next` branch."#); // next commit
|
||||
message!(ReceiveCIStatus: (Commit, Status): r#"Notification of the status of the CI checks for the commit.
|
||||
Contains the commit from the tip of the `next` branch."#
|
||||
); // next commit
|
||||
message!(
|
||||
ReceiveCIStatus,
|
||||
(Commit, Status),
|
||||
r#"Notification of the status of the CI checks for the commit.
|
||||
|
||||
Contains a tuple of the commit that was checked (the tip of the `next` branch) and the status."#); // commit and it's status
|
||||
Contains a tuple of the commit that was checked (the tip of the `next` branch) and the status."#
|
||||
); // commit and it's status
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct AdvanceNextPayload {
|
||||
|
@ -67,7 +105,23 @@ pub struct AdvanceNextPayload {
|
|||
pub main: Commit,
|
||||
pub dev_commit_history: Vec<Commit>,
|
||||
}
|
||||
message!(AdvanceNext: AdvanceNextPayload: "Request to advance the `next` branch on to the next commit on the `dev branch."); // next commit and the dev commit history
|
||||
message!(AdvanceMain: Commit: "Request to advance the `main` branch on to same commit as the `next` branch."); // next commit
|
||||
message!(WebhookNotification: ForgeNotification: "Notification of a webhook message from the forge.");
|
||||
message!(NotifyUser: UserNotification: "Request to send the message payload to the notification webhook");
|
||||
message!(
|
||||
AdvanceNext,
|
||||
AdvanceNextPayload,
|
||||
"Request to advance the `next` branch on to the next commit on the `dev branch."
|
||||
); // next commit and the dev commit history
|
||||
message!(
|
||||
AdvanceMain,
|
||||
Commit,
|
||||
"Request to advance the `main` branch on to same commit as the `next` branch."
|
||||
); // next commit
|
||||
message!(
|
||||
WebhookNotification,
|
||||
ForgeNotification,
|
||||
"Notification of a webhook message from the forge."
|
||||
);
|
||||
message!(
|
||||
NotifyUser,
|
||||
UserNotification,
|
||||
"Request to send the message payload to the notification webhook"
|
||||
);
|
||||
|
|
|
@ -78,7 +78,7 @@ impl ActorLog {
|
|||
}
|
||||
}
|
||||
|
||||
message!(ExamineActor => RepoActorView: "Request a view of the current state of the [RepoActor].");
|
||||
message!(ExamineActor => RepoActorView, "Request a view of the current state of the [RepoActor].");
|
||||
impl Handler<ExamineActor> for RepoActor {
|
||||
type Result = RepoActorView;
|
||||
|
||||
|
|
|
@ -9,11 +9,15 @@ use git_next_core::{
|
|||
use std::net::SocketAddr;
|
||||
|
||||
// receive server config
|
||||
message!(ReceiveAppConfig: AppConfig: "Notification of newly loaded server configuration.
|
||||
message!(
|
||||
ReceiveAppConfig,
|
||||
AppConfig,
|
||||
"Notification of newly loaded server configuration.
|
||||
|
||||
This message will prompt the `git-next` server to stop and restart all repo-actors.
|
||||
|
||||
Contains the new server configuration.");
|
||||
Contains the new server configuration."
|
||||
);
|
||||
|
||||
// receive valid server config
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Constructor)]
|
||||
|
@ -22,6 +26,10 @@ pub struct ValidAppConfig {
|
|||
pub socket_address: SocketAddr,
|
||||
pub storage: Storage,
|
||||
}
|
||||
message!(ReceiveValidAppConfig: ValidAppConfig: "Notification of validated server configuration.");
|
||||
message!(
|
||||
ReceiveValidAppConfig,
|
||||
ValidAppConfig,
|
||||
"Notification of validated server configuration."
|
||||
);
|
||||
|
||||
message!(Shutdown: "Notification to shutdown the server actor");
|
||||
message!(Shutdown, "Notification to shutdown the server actor");
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//
|
||||
use git_next_core::message;
|
||||
|
||||
message!(ShutdownWebhook: "Request to shutdown the Webhook actor");
|
||||
message!(ShutdownWebhook, "Request to shutdown the Webhook actor");
|
||||
|
|
|
@ -3,4 +3,12 @@ use serde::Serialize;
|
|||
|
||||
use crate::newtype;
|
||||
|
||||
newtype!(BranchName: String, Display, Default, Hash, Serialize: "The name of a Git branch");
|
||||
newtype!(
|
||||
BranchName,
|
||||
String,
|
||||
Display,
|
||||
Default,
|
||||
Hash,
|
||||
Serialize,
|
||||
"The name of a Git branch"
|
||||
);
|
||||
|
|
|
@ -1,6 +1,18 @@
|
|||
use serde::Serialize;
|
||||
|
||||
crate::newtype!(ForgeAlias: String, Hash, PartialOrd, Ord, derive_more::Display, Default, Serialize: "The name of a Forge to connect to");
|
||||
use crate::newtype;
|
||||
|
||||
newtype!(
|
||||
ForgeAlias,
|
||||
String,
|
||||
Hash,
|
||||
PartialOrd,
|
||||
Ord,
|
||||
derive_more::Display,
|
||||
Default,
|
||||
Serialize,
|
||||
"The name of a Forge to connect to"
|
||||
);
|
||||
impl From<&ForgeAlias> for std::path::PathBuf {
|
||||
fn from(value: &ForgeAlias) -> Self {
|
||||
Self::from(&value.0)
|
||||
|
|
|
@ -1,2 +1,10 @@
|
|||
// The hostname of a forge
|
||||
crate::newtype!(Hostname: String, derive_more::Display, Default: "The hostname for the forge");
|
||||
//
|
||||
use crate::newtype;
|
||||
|
||||
newtype!(
|
||||
Hostname,
|
||||
String,
|
||||
derive_more::Display,
|
||||
Default,
|
||||
"The hostname for the forge"
|
||||
);
|
||||
|
|
|
@ -1,6 +1,14 @@
|
|||
//
|
||||
use std::borrow::ToOwned;
|
||||
|
||||
crate::newtype!(RemoteUrl: git_url_parse::GitUrl, derive_more::Display: "The URL of a remote repository");
|
||||
use crate::newtype;
|
||||
|
||||
newtype!(
|
||||
RemoteUrl,
|
||||
git_url_parse::GitUrl,
|
||||
derive_more::Display,
|
||||
"The URL of a remote repository"
|
||||
);
|
||||
impl RemoteUrl {
|
||||
pub fn parse(url: impl Into<String>) -> Option<Self> {
|
||||
Some(Self::new(::git_url_parse::GitUrl::parse(&url.into()).ok()?))
|
||||
|
|
|
@ -3,6 +3,16 @@ use serde::Serialize;
|
|||
|
||||
use crate::newtype;
|
||||
|
||||
newtype!(RepoAlias: String, Display, Default, Hash, PartialOrd, Ord, Serialize: r#"The alias of a repo.
|
||||
newtype!(
|
||||
RepoAlias,
|
||||
String,
|
||||
Display,
|
||||
Default,
|
||||
Hash,
|
||||
PartialOrd,
|
||||
Ord,
|
||||
Serialize,
|
||||
r#"The alias of a repo.
|
||||
|
||||
This is the alias for the repo within `git-next-server.toml`."#);
|
||||
This is the alias for the repo within `git-next-server.toml`."#
|
||||
);
|
||||
|
|
|
@ -122,8 +122,13 @@ impl Listen {
|
|||
}
|
||||
|
||||
newtype!(
|
||||
ListenUrl:
|
||||
String, Serialize, Deserialize, PartialOrd, Ord, Display:
|
||||
ListenUrl,
|
||||
String,
|
||||
Serialize,
|
||||
Deserialize,
|
||||
PartialOrd,
|
||||
Ord,
|
||||
Display,
|
||||
"The base url for receiving all webhooks from all forges"
|
||||
);
|
||||
impl ListenUrl {
|
||||
|
@ -133,9 +138,13 @@ impl ListenUrl {
|
|||
}
|
||||
}
|
||||
|
||||
newtype!(ForgeWebhookUrl: String: "Raw URL from a forge Webhook");
|
||||
newtype!(ForgeWebhookUrl, String, "Raw URL from a forge Webhook");
|
||||
|
||||
newtype!(RepoListenUrl: (ListenUrl, ForgeAlias, RepoAlias): "URL to listen for webhook from forges");
|
||||
newtype!(
|
||||
RepoListenUrl,
|
||||
(ListenUrl, ForgeAlias, RepoAlias),
|
||||
"URL to listen for webhook from forges"
|
||||
);
|
||||
impl Display for RepoListenUrl {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
//
|
||||
use crate::newtype;
|
||||
|
||||
newtype!(WebhookAuth: ulid::Ulid, derive_more::Display: r#"The unique token authorisation for the webhook.
|
||||
newtype!(
|
||||
WebhookAuth,
|
||||
ulid::Ulid,
|
||||
derive_more::Display,
|
||||
r#"The unique token authorisation for the webhook.
|
||||
|
||||
Each monitored repository has it's own unique token, and it is different each time `git-next` runs."#);
|
||||
Each monitored repository has it's own unique token, and it is different each time `git-next` runs."#
|
||||
);
|
||||
impl WebhookAuth {
|
||||
/// Parses the authorisation string as a `Ulid` to create a `WebhookAuth`.
|
||||
///
|
||||
|
|
|
@ -1,2 +1,9 @@
|
|||
//
|
||||
crate::newtype!(WebhookId: String, derive_more::Display: "The ID of the webhook, as returned by the forge when it is registered.");
|
||||
use crate::newtype;
|
||||
|
||||
newtype!(
|
||||
WebhookId,
|
||||
String,
|
||||
derive_more::Display,
|
||||
"The ID of the webhook, as returned by the forge when it is registered."
|
||||
);
|
||||
|
|
|
@ -41,8 +41,26 @@ impl From<webhook::Push> for Commit {
|
|||
}
|
||||
}
|
||||
|
||||
newtype!(Sha: String, Display, Hash,PartialOrd, Ord, Serialize: "The unique SHA for a git commit.");
|
||||
newtype!(Message: String, Display, Hash, PartialOrd, Ord, Serialize: "The commit message for a git commit.");
|
||||
newtype!(
|
||||
Sha,
|
||||
String,
|
||||
Display,
|
||||
Hash,
|
||||
PartialOrd,
|
||||
Ord,
|
||||
Serialize,
|
||||
"The unique SHA for a git commit."
|
||||
);
|
||||
newtype!(
|
||||
Message,
|
||||
String,
|
||||
Display,
|
||||
Hash,
|
||||
PartialOrd,
|
||||
Ord,
|
||||
Serialize,
|
||||
"The commit message for a git commit."
|
||||
);
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Histories {
|
||||
|
|
|
@ -2,9 +2,16 @@ use derive_more::Display;
|
|||
|
||||
use crate::newtype;
|
||||
|
||||
newtype!(Generation: u32, Display, Default, Copy: r#"A counter for the server generation.
|
||||
newtype!(
|
||||
Generation,
|
||||
u32,
|
||||
Display,
|
||||
Default,
|
||||
Copy,
|
||||
r#"A counter for the server generation.
|
||||
|
||||
This counter is increased by one each time the server restarts itself when the configuration file is updated."#);
|
||||
This counter is increased by one each time the server restarts itself when the configuration file is updated."#
|
||||
);
|
||||
impl Generation {
|
||||
pub fn inc(&mut self) {
|
||||
self.0 += 1;
|
||||
|
|
|
@ -5,7 +5,7 @@ use derive_more::Display;
|
|||
|
||||
use crate::git::{commit::Sha, Commit};
|
||||
|
||||
newtype!(GitRef: String, Display: "A git reference to a git commit.");
|
||||
newtype!(GitRef, String, Display, "A git reference to a git commit.");
|
||||
impl From<Commit> for GitRef {
|
||||
fn from(value: Commit) -> Self {
|
||||
Self(value.sha().to_string())
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
#[macro_export]
|
||||
macro_rules! message {
|
||||
($name:ident: $value:ty: $docs:literal) => {
|
||||
git_next_core::newtype!($name: $value: $docs);
|
||||
($name:ident, $value:ty, $docs:literal) => {
|
||||
git_next_core::newtype!($name, $value, $docs);
|
||||
impl actix::prelude::Message for $name {
|
||||
type Result = ();
|
||||
}
|
||||
};
|
||||
($name:ident: $docs:literal) => {
|
||||
git_next_core::newtype!($name: $docs);
|
||||
($name:ident, $docs:literal) => {
|
||||
git_next_core::newtype!($name, $docs);
|
||||
impl actix::prelude::Message for $name {
|
||||
type Result = ();
|
||||
}
|
||||
};
|
||||
($name:ident: $value:ty => $result:ty: $docs:literal) => {
|
||||
git_next_core::newtype!($name is a $value: $docs);
|
||||
($name:ident, $value:ty => $result:ty, $docs:literal) => {
|
||||
git_next_core::newtype!($name, $value, $docs);
|
||||
impl actix::prelude::Message for $name {
|
||||
type Result = $result;
|
||||
}
|
||||
};
|
||||
($name:ident => $result:ty: $docs:literal) => {
|
||||
git_next_core::newtype!($name: $docs);
|
||||
($name:ident => $result:ty, $docs:literal) => {
|
||||
git_next_core::newtype!($name, $docs);
|
||||
impl actix::prelude::Message for $name {
|
||||
type Result = $result;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//
|
||||
#[macro_export]
|
||||
macro_rules! newtype {
|
||||
($name:ident: $docs:literal) => {
|
||||
($name:ident, $docs:literal) => {
|
||||
#[doc = $docs]
|
||||
#[derive(
|
||||
Clone,
|
||||
|
@ -20,7 +20,7 @@ macro_rules! newtype {
|
|||
)]
|
||||
pub struct $name;
|
||||
};
|
||||
($name:ident: $type:ty $(, $derive:ty)*: $docs:literal) => {
|
||||
($name:ident, $type:ty $(, $derive:ty)*, $docs:literal) => {
|
||||
#[doc = $docs]
|
||||
#[derive(
|
||||
Clone,
|
||||
|
|
Loading…
Reference in a new issue