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

feat: add support for cdevents 0.4 #24

Merged
merged 6 commits into from
Aug 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@
[submodule "cdevents-specs/main"]
path = cdevents-specs/main
url = https://github.com/cdevents/spec.git
[submodule "cdevents-specs/spec-v0.4"]
path = cdevents-specs/spec-v0.4
url = https://github.com/cdevents/spec.git
branch = spec-v0.4
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ test:
cargo nextest run --all-features
cargo test --doc

# buid_cdevents-specs:
# git submodule deinit -f --all
# git submodule init
# git submodule add -f https://github.com/cdevents/spec.git cdevents-specs/main
# git submodule add -f -b spec-v0.3 https://github.com/cdevents/spec.git cdevents-specs/spec-v0.3
# git submodule add -f -b spec-v0.4 https://github.com/cdevents/spec.git cdevents-specs/spec-v0.4
# git submodule update -f --rebase -- cdevents-specs/main

.PHONY:
generate \
check check_no_uncommitted_changes_on_sdk \
Expand Down
3 changes: 2 additions & 1 deletion cdevents-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ assert-json-diff = "2.0"
boon = "0.6"
glob = "0.3"
proptest = "1"
rstest = "0.21"
regex = "1.10"
rstest = "0.22"

[features]
default = ["cloudevents"]
Expand Down
11 changes: 10 additions & 1 deletion cdevents-sdk/src/context.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use serde::{Deserialize, Serialize};

use crate::{Id, UriReference};
use crate::{Id, Uri, UriReference};

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
Expand All @@ -12,6 +12,12 @@ pub(crate) struct Context {
pub(crate) ty: String,
#[serde(with = "crate::serde::datetime")]
pub(crate) timestamp: time::OffsetDateTime,
#[serde(rename = "schemaUri", skip_serializing_if = "Option::is_none")]
pub(crate) schema_uri: Option<Uri>,
#[serde(rename = "chainId", skip_serializing_if = "Option::is_none")]
pub(crate) chain_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub(crate) links: Option<serde_json::Value>,
}

impl Default for Context {
Expand All @@ -22,6 +28,9 @@ impl Default for Context {
source: "/undef".try_into().expect("/undef is a valid uri-reference"),
ty: "dev.cdevents.undef.undef.0.0.0".into(),
timestamp: time::OffsetDateTime::now_utc(),
schema_uri: None,
chain_id: None,
links: None,
}
}
}
29 changes: 29 additions & 0 deletions cdevents-sdk/src/generated/artifact_deleted_0_1_0.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// @generated
// by cdevents/sdk-rust/generator (subject.hbs)

#[cfg(feature = "testkit")] use proptest_derive::Arbitrary;
use serde::{Serialize, Deserialize};

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[cfg_attr(feature = "testkit", derive(Arbitrary))]
#[serde(deny_unknown_fields)]
pub struct Content {
#[serde(rename = "user", default, skip_serializing_if = "Option::is_none",)]
pub user: Option<crate::NonEmptyString>,
}

#[cfg(test)]
mod tests {
use proptest::prelude::*;
use super::*;

proptest! {
#[test]
#[cfg(feature = "testkit")]
fn arbitraries_are_json_valid(s in any::<Content>()) {
let json_str = serde_json::to_string(&s).unwrap();
let actual = serde_json::from_str::<Content>(&json_str).unwrap();
assert_eq!(s, actual);
}
}
}
29 changes: 29 additions & 0 deletions cdevents-sdk/src/generated/artifact_downloaded_0_1_0.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// @generated
// by cdevents/sdk-rust/generator (subject.hbs)

#[cfg(feature = "testkit")] use proptest_derive::Arbitrary;
use serde::{Serialize, Deserialize};

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[cfg_attr(feature = "testkit", derive(Arbitrary))]
#[serde(deny_unknown_fields)]
pub struct Content {
#[serde(rename = "user", default, skip_serializing_if = "Option::is_none",)]
pub user: Option<crate::NonEmptyString>,
}

#[cfg(test)]
mod tests {
use proptest::prelude::*;
use super::*;

proptest! {
#[test]
#[cfg(feature = "testkit")]
fn arbitraries_are_json_valid(s in any::<Content>()) {
let json_str = serde_json::to_string(&s).unwrap();
let actual = serde_json::from_str::<Content>(&json_str).unwrap();
assert_eq!(s, actual);
}
}
}
49 changes: 49 additions & 0 deletions cdevents-sdk/src/generated/artifact_packaged_0_2_0.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// @generated
// by cdevents/sdk-rust/generator (subject.hbs)

#[cfg(feature = "testkit")] use proptest_derive::Arbitrary;
use serde::{Serialize, Deserialize};

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[cfg_attr(feature = "testkit", derive(Arbitrary))]
#[serde(deny_unknown_fields)]
pub struct Content {
#[serde(rename = "change",)]
pub change: ContentChange,
#[serde(rename = "sbom", default, skip_serializing_if = "Option::is_none",)]
pub sbom: Option<ContentSbom>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[cfg_attr(feature = "testkit", derive(Arbitrary))]
#[serde(deny_unknown_fields)]
pub struct ContentSbom {
#[serde(rename = "uri",)]
pub uri: crate::UriReference,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[cfg_attr(feature = "testkit", derive(Arbitrary))]
#[serde(deny_unknown_fields)]
pub struct ContentChange {
#[serde(rename = "id",)]
pub id: crate::Id,
#[serde(rename = "source", default, skip_serializing_if = "Option::is_none",)]
pub source: Option<crate::UriReference>,
}

#[cfg(test)]
mod tests {
use proptest::prelude::*;
use super::*;

proptest! {
#[test]
#[cfg(feature = "testkit")]
fn arbitraries_are_json_valid(s in any::<Content>()) {
let json_str = serde_json::to_string(&s).unwrap();
let actual = serde_json::from_str::<Content>(&json_str).unwrap();
assert_eq!(s, actual);
}
}
}
39 changes: 39 additions & 0 deletions cdevents-sdk/src/generated/artifact_published_0_2_0.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// @generated
// by cdevents/sdk-rust/generator (subject.hbs)

#[cfg(feature = "testkit")] use proptest_derive::Arbitrary;
use serde::{Serialize, Deserialize};

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[cfg_attr(feature = "testkit", derive(Arbitrary))]
#[serde(deny_unknown_fields)]
pub struct Content {
#[serde(rename = "sbom", default, skip_serializing_if = "Option::is_none",)]
pub sbom: Option<ContentSbom>,
#[serde(rename = "user", default, skip_serializing_if = "Option::is_none",)]
pub user: Option<crate::NonEmptyString>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[cfg_attr(feature = "testkit", derive(Arbitrary))]
#[serde(deny_unknown_fields)]
pub struct ContentSbom {
#[serde(rename = "uri",)]
pub uri: crate::UriReference,
}

#[cfg(test)]
mod tests {
use proptest::prelude::*;
use super::*;

proptest! {
#[test]
#[cfg(feature = "testkit")]
fn arbitraries_are_json_valid(s in any::<Content>()) {
let json_str = serde_json::to_string(&s).unwrap();
let actual = serde_json::from_str::<Content>(&json_str).unwrap();
assert_eq!(s, actual);
}
}
}
29 changes: 29 additions & 0 deletions cdevents-sdk/src/generated/artifact_signed_0_2_0.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// @generated
// by cdevents/sdk-rust/generator (subject.hbs)

#[cfg(feature = "testkit")] use proptest_derive::Arbitrary;
use serde::{Serialize, Deserialize};

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[cfg_attr(feature = "testkit", derive(Arbitrary))]
#[serde(deny_unknown_fields)]
pub struct Content {
#[serde(rename = "signature",)]
pub signature: crate::NonEmptyString,
}

#[cfg(test)]
mod tests {
use proptest::prelude::*;
use super::*;

proptest! {
#[test]
#[cfg(feature = "testkit")]
fn arbitraries_are_json_valid(s in any::<Content>()) {
let json_str = serde_json::to_string(&s).unwrap();
let actual = serde_json::from_str::<Content>(&json_str).unwrap();
assert_eq!(s, actual);
}
}
}
39 changes: 39 additions & 0 deletions cdevents-sdk/src/generated/branch_created_0_2_0.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// @generated
// by cdevents/sdk-rust/generator (subject.hbs)

#[cfg(feature = "testkit")] use proptest_derive::Arbitrary;
use serde::{Serialize, Deserialize};

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[cfg_attr(feature = "testkit", derive(Arbitrary))]
#[serde(deny_unknown_fields)]
pub struct Content {
#[serde(rename = "repository", default, skip_serializing_if = "Option::is_none",)]
pub repository: Option<ContentRepository>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[cfg_attr(feature = "testkit", derive(Arbitrary))]
#[serde(deny_unknown_fields)]
pub struct ContentRepository {
#[serde(rename = "id",)]
pub id: crate::Id,
#[serde(rename = "source", default, skip_serializing_if = "Option::is_none",)]
pub source: Option<crate::UriReference>,
}

#[cfg(test)]
mod tests {
use proptest::prelude::*;
use super::*;

proptest! {
#[test]
#[cfg(feature = "testkit")]
fn arbitraries_are_json_valid(s in any::<Content>()) {
let json_str = serde_json::to_string(&s).unwrap();
let actual = serde_json::from_str::<Content>(&json_str).unwrap();
assert_eq!(s, actual);
}
}
}
39 changes: 39 additions & 0 deletions cdevents-sdk/src/generated/branch_deleted_0_2_0.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// @generated
// by cdevents/sdk-rust/generator (subject.hbs)

#[cfg(feature = "testkit")] use proptest_derive::Arbitrary;
use serde::{Serialize, Deserialize};

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[cfg_attr(feature = "testkit", derive(Arbitrary))]
#[serde(deny_unknown_fields)]
pub struct Content {
#[serde(rename = "repository", default, skip_serializing_if = "Option::is_none",)]
pub repository: Option<ContentRepository>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[cfg_attr(feature = "testkit", derive(Arbitrary))]
#[serde(deny_unknown_fields)]
pub struct ContentRepository {
#[serde(rename = "id",)]
pub id: crate::Id,
#[serde(rename = "source", default, skip_serializing_if = "Option::is_none",)]
pub source: Option<crate::UriReference>,
}

#[cfg(test)]
mod tests {
use proptest::prelude::*;
use super::*;

proptest! {
#[test]
#[cfg(feature = "testkit")]
fn arbitraries_are_json_valid(s in any::<Content>()) {
let json_str = serde_json::to_string(&s).unwrap();
let actual = serde_json::from_str::<Content>(&json_str).unwrap();
assert_eq!(s, actual);
}
}
}
29 changes: 29 additions & 0 deletions cdevents-sdk/src/generated/build_finished_0_2_0.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// @generated
// by cdevents/sdk-rust/generator (subject.hbs)

#[cfg(feature = "testkit")] use proptest_derive::Arbitrary;
use serde::{Serialize, Deserialize};

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[cfg_attr(feature = "testkit", derive(Arbitrary))]
#[serde(deny_unknown_fields)]
pub struct Content {
#[serde(rename = "artifactId", default, skip_serializing_if = "Option::is_none",)]
pub artifact_id: Option<String>,
}

#[cfg(test)]
mod tests {
use proptest::prelude::*;
use super::*;

proptest! {
#[test]
#[cfg(feature = "testkit")]
fn arbitraries_are_json_valid(s in any::<Content>()) {
let json_str = serde_json::to_string(&s).unwrap();
let actual = serde_json::from_str::<Content>(&json_str).unwrap();
assert_eq!(s, actual);
}
}
}
27 changes: 27 additions & 0 deletions cdevents-sdk/src/generated/build_queued_0_2_0.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// @generated
// by cdevents/sdk-rust/generator (subject.hbs)

#[cfg(feature = "testkit")] use proptest_derive::Arbitrary;
use serde::{Serialize, Deserialize};

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[cfg_attr(feature = "testkit", derive(Arbitrary))]
#[serde(deny_unknown_fields)]
pub struct Content {
}

#[cfg(test)]
mod tests {
use proptest::prelude::*;
use super::*;

proptest! {
#[test]
#[cfg(feature = "testkit")]
fn arbitraries_are_json_valid(s in any::<Content>()) {
let json_str = serde_json::to_string(&s).unwrap();
let actual = serde_json::from_str::<Content>(&json_str).unwrap();
assert_eq!(s, actual);
}
}
}
Loading