Skip to content

updates #50

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

Merged
merged 5 commits into from
Apr 16, 2025
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
25 changes: 9 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ on:
permissions:
contents: read

env:
# configure sccache to cache the build artifacts (on github caches)
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"

jobs:
tests:
runs-on: ${{ matrix.os }}
Expand All @@ -22,22 +27,10 @@ jobs:
with:
fetch-depth: 0
submodules: "true"
# - uses: jdx/mise-action@v2
- name: install mise until mise-action is allowed
uses: taiki-e/install-action@v2
with:
tool: mise, cargo-nextest, cargo-hack
- name: Rust Cache
uses: actions/cache@v4
continue-on-error: false
with:
path: |
~/.cargo/bin
~/.cargo/registry
~/.cargo/git/db/
key: ${{ runner.os }}-sdk-rust-${{ hashFiles('**/Cargo.toml') }} # no Cargo.lock in this repo
restore-keys: |
${{ runner.os }}-sdk-rust-
- uses: mozilla-actions/[email protected]
- uses: jdx/mise-action@v2
- run: mise install
shell: bash
- run: make generate
- run: make check_no_uncommitted_changes_on_sdk
- run: make check
Expand Down
31 changes: 11 additions & 20 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true

env:
# configure sccache to cache the build artifacts (on github caches)
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"

jobs:
lint_commits:
name: Lint Commit Messages
Expand Down Expand Up @@ -48,27 +53,13 @@ jobs:
with:
fetch-depth: 0
submodules: "true"
- name: Install rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
components: clippy, rustfmt
- name: Install development tools
uses: taiki-e/install-action@v2
with:
tool: cargo-deny, dprint
- name: Rust Cache
uses: actions/cache@v4
continue-on-error: false
with:
path: |
~/.cargo/bin
~/.cargo/registry
~/.cargo/git/db/
key: ${{ runner.os }}-sdk-rust-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-sdk-rust-
- uses: mozilla-actions/[email protected]
- uses: jdx/mise-action@v2
- run: mise install
shell: bash
- name: Check cargo version
run: cargo --version
- name: Run ${{ matrix.lint_projects }}
run: make -f Makefile lint_${{ matrix.lint_projects }}
- run: ${SCCACHE_PATH} --show-stats
shell: bash
24 changes: 16 additions & 8 deletions .github/workflows/release-plz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ on:
push:
branches:
- main
workflow_dispatch:

env:
# configure sccache to cache the build artifacts (on github caches)
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"

jobs:
# Release unpublished packages.
Expand All @@ -21,15 +27,16 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Run release-plz
uses: release-plz/[email protected]
- uses: mozilla-actions/[email protected]
- uses: dtolnay/rust-toolchain@stable
- uses: release-plz/[email protected]
with:
command: release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
- run: ${SCCACHE_PATH} --show-stats
shell: bash

# Create a PR with the new versions and changelog, preparing the next release.
release-plz-pr:
Expand All @@ -46,12 +53,13 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Run release-plz
uses: release-plz/[email protected]
- uses: mozilla-actions/[email protected]
- uses: dtolnay/rust-toolchain@stable
- uses: release-plz/[email protected]
with:
command: release-pr
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
- run: ${SCCACHE_PATH} --show-stats
shell: bash
4 changes: 2 additions & 2 deletions .mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ MISE_CARGO_BINSTALL = "true"

[tools]
"aqua:cargo-bins/cargo-binstall" = "1"
rust = "1.85"
rust = { version = "1.85", profile = "default" }
make = "latest"
# # experimental
"cargo:cargo-nextest" = "0.9"
# "cargo:cargo-hack" = "latest"
"cargo:cargo-hack" = "0.6"
"cargo:cargo-deny" = "0.16"
# "cargo:git-cliff" = "latest"
"cargo:dprint" = "0.45"
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ test:
# 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

update_cdevents-specs:
git submodule update --recursive --remote

.PHONY:
generate \
check check_no_uncommitted_changes_on_sdk \
Expand Down
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The SDK can be used to create CDEvents and send them as CloudEvents, as well as
Import the modules in your code

```toml
cdevents-sdk = "0.1.0"
cdevents-sdk = "0.1"
```

To send a CDEvent as CloudEvent:
Expand Down Expand Up @@ -60,6 +60,24 @@ fn main() -> Result<(), Box<dyn Error>> {

See the [CloudEvents](https://github.com/cloudevents/sdk-rust) docs as well.

## Features

- [x] support cdevents spec 0.3.0
- [x] support cdevents spec 0.4.1
- [ ] support of custom event
- [ ] compile-time generation of type for custom event
- [ ] runtime validation (download of jsonschemas & validation)
- [x] serialize/deserialize of custom event (type `dev.cdeventsx.{subject}.{predicate}.{version}`)
- [x] partial validation of custom event (`subject.content` is not validated, stored as json)
- [x] Cloudevents support (provide wrapper/extractor for CDEvent)
- [x] CDEvent stored into static types (=> no use of jsonshema at runtime)
- [x] rutime validation for scalar types (purl, datetime, uri-reference)
- [ ] report clear and readable error messages on deserialization
- [x] provide type with builder pattern (fluent)
- [x] provide random/sample generator for CDEvent (property based testing)
- [x] test `serialization(deserialization(of spec's examples & conformances)) == spec's examples & conformances`
- [x] test `serialization(random CDEvent) matches the jsonschemas`

## References

- [CDEvents](https://cdevents.dev)
Expand Down
2 changes: 1 addition & 1 deletion cdevents-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ authors.workspace = true
edition.workspace = true
license.workspace = true
publish = true
readme = "README.md"
repository.workspace = true
rust-version.workspace = true
description = "A Rust SDK for CDEvents"
readme = "README.md"

[dependencies]
cloudevents-sdk = { version = "0.8", optional = true, default-features = false }
Expand Down
41 changes: 0 additions & 41 deletions cdevents-sdk/src/generated/change_created_0_2_0.rs

This file was deleted.

Loading
Loading