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: first implementation of cdevents-sdk from json-schema #8

Merged
merged 34 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
36ec9e0
revert: remove useless scaffolded code
davidB Jan 10, 2024
4353836
feat: first working basic `generator`
davidB Jan 10, 2024
82bfe86
feat: first working basic `cdevents` implementation
davidB Jan 10, 2024
ff776e4
refactor: rename crates `cdevents` into `cdevents-sdk`
davidB Jan 13, 2024
a25f150
refactor: replace generation of json object by named types for Subjec…
davidB Jan 14, 2024
f727547
feat: use the same Subject struct for every event and an enum on Content
davidB Jan 14, 2024
085b6ed
fix: use the `context.type` (instead of `$id`) to define the module name
davidB Jan 14, 2024
79551ca
feat: use more precise type for uri & datetime than String
davidB Jan 14, 2024
1428d48
build(deps): remove useless "serde_with"
davidB Jan 14, 2024
479cb5d
build: enable deny_unknown_fields
davidB Jan 14, 2024
3a51cb9
build: apply some recommendation from clippy
davidB Jan 18, 2024
e738b7f
style: reformat
davidB Jan 18, 2024
59210a6
ci: setup ci & linters
davidB Jan 18, 2024
b63b9d6
ci: avoid to install cargo-binstall from source
davidB Jan 18, 2024
c286321
feat: add support for `PartialEq`, `Eq` on `CDEvent`, use wrapper for…
davidB Jan 21, 2024
8d5586f
feat: introduce support for cloudevents
davidB Jan 21, 2024
ba31fb9
feat: enforce mutation to only create coherente cdevents (type match …
davidB Jan 21, 2024
7efb1c4
build: migrate to `mise` (formaly `rtx`)
davidB Jan 23, 2024
449948d
revert: remove CI (wrong PR)
davidB Jan 23, 2024
2a0d732
style: update typo, remove commented code, move comments,... apply re…
davidB Jan 23, 2024
865ebf2
build: update Makefile (to replace justfile)
davidB Jan 23, 2024
de04bb2
style: reformat Cargo.toml
davidB Jan 23, 2024
e0d9e94
build: add missing tool to `mise` configuration
davidB Jan 23, 2024
184e70f
feat: string enum are defined as rust Enum
davidB Jan 28, 2024
d952752
feat(testkit): provide proptest 's arbitraies to generate samples
davidB Jan 28, 2024
ad8f665
test: add test to validate against jsonschema: examples (from spec), …
davidB Jan 28, 2024
97b6a51
fix: enforce non-empty string for `id` and hardcode mapping between c…
davidB Jan 28, 2024
799cd26
build: change clipy configuration to support workspace and features
davidB Jan 30, 2024
a7ca3cc
build: exclude generator from crago-deny scope
davidB Jan 30, 2024
41480b1
ci: run tests and fix clippy call
davidB Jan 30, 2024
25e2dcc
ci: disable test (until fix)
davidB Jan 30, 2024
9bc4e33
ci(revert): restore `lint_check` to lint actions only
davidB Feb 1, 2024
7ead28c
refactor: remove & clean
davidB Feb 1, 2024
6c72ab9
build: add check that generated code is committed
davidB Feb 1, 2024
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
56 changes: 56 additions & 0 deletions .editorconfig
davidB marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# https://editorconfig.org/

root = true

[*]
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
end_of_line = lf
charset = utf-8

[*.conf]
indent_size = 2

[*.md]
#inside code block, indentation could be anything
indent_size = unset

[*.rs]
# https://github.com/rust-dev-tools/fmt-rfcs/blob/master/guide/guide.md
indent_size = 4
# officially the limit is 100, but we have long url (unsplittable) in comment
max_line_length = 200

[{*.bazel,*.bzl,BUILD,WORKSPACE}]
indent_size = 4

# The JSON files contain newlines inconsistently
[*.json]
insert_final_newline = unset

[**/vendor/**]
indent_style = unset
indent_size = unset
insert_final_newline = unset

# Minified JavaScript files shouldn't be changed
[**.min.js]
indent_style = unset
indent_size = unset
insert_final_newline = unset

# Makefiles always use tabs for indentation
[Makefile]
indent_style = tab
indent_size = 4

[justfile]
indent_style = space
indent_size = 4

# Batch files use tabs for indentation
[*.bat]
indent_style = tab
indent_size = 4
12 changes: 12 additions & 0 deletions .github/dependabot.yml
davidB marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2
updates:
- package-ecosystem: "cargo"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "github-actions"
# Workflow files stored in the
# default location of `.github/workflows`
directory: "/"
schedule:
interval: "weekly"
7 changes: 5 additions & 2 deletions .github/workflows/linter.yaml
Copy link
Contributor

@rjtch rjtch Jan 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used lint here in the matrix because i wanted to differentiate with next coming tests ci. Now that you renamed it to task it is not really clear what it is! If it is the linter_ci or the tests_ci.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not simply call this workflow ci (and ci.yml for the filename, github workflow often use this name, and the extension .yml, like what is generated by github and other framework).

We can discuss this point into a next PR. So I'll revert my change.

Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ jobs:
steps:
- name: Run the checkout command
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: "true"
- name: Install rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
Expand All @@ -66,8 +69,8 @@ jobs:
~/.cargo/git/db/
key: ${{ runner.os }}-sdk-rust-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-sdk-rust-
${{ runner.os }}-sdk-rust-
- name: Check cargo version
run: cargo --version
- name: Run lint ${{ matrix.lint_projects }}
- name: Run ${{ matrix.lint_projects }}
run: make -f Makefile lint_${{ matrix.lint_projects }}
201 changes: 201 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,161 @@
# Created by https://www.toptal.com/developers/gitignore/api/git,vim,rust,emacs,jetbrains+all,visualstudiocode
# Edit at https://www.toptal.com/developers/gitignore?templates=git,vim,rust,emacs,jetbrains+all,visualstudiocode

### Emacs ###
# -*- mode: gitignore; -*-
*~
\#*\#
/.emacs.desktop
/.emacs.desktop.lock
*.elc
auto-save-list
tramp
.\#*

# Org-mode
.org-id-locations
*_archive

# flymake-mode
*_flymake.*

# eshell files
/eshell/history
/eshell/lastdir

# elpa packages
/elpa/

# reftex files
*.rel

# AUCTeX auto folder
/auto/

# cask packages
.cask/
dist/

# Flycheck
flycheck_*.el

# server auth directory
/server/

# projectiles files
.projectile

# directory configuration
.dir-locals.el

# network security
/network-security.data


### Git ###
# Created by git for backups. To disable backups in Git:
# $ git config --global mergetool.keepBackup false
*.orig

# Created by git when using merge tools for conflicts
*.BACKUP.*
*.BASE.*
*.LOCAL.*
*.REMOTE.*
*_BACKUP_*.txt
*_BASE_*.txt
*_LOCAL_*.txt
*_REMOTE_*.txt

### JetBrains+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# AWS User-specific
.idea/**/aws.xml

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# SonarLint plugin
.idea/sonarlint/

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### JetBrains+all Patch ###
# Ignore everything but code style settings and run configurations
# that are supposed to be shared within teams.

.idea/*

!.idea/codeStyles
!.idea/runConfigurations

### Rust ###
# Generated by Cargo
# will have compiled files and executables
debug/
Expand All @@ -12,3 +170,46 @@ Cargo.lock

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

### Vim ###
# Swap
[._]*.s[a-v][a-z]
!*.svg # comment out if you don't need vector files
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]

# Session
Session.vim
Sessionx.vim

# Temporary
.netrwhist
# Auto-generated tag files
tags
# Persistent undo
[._]*.un~

### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets

# Local History for Visual Studio Code
.history/

# Built Visual Studio Code Extensions
*.vsix

### VisualStudioCode Patch ###
# Ignore all local history of files
.history
.ionide

# End of https://www.toptal.com/developers/gitignore/api/git,vim,rust,emacs,jetbrains+all,visualstudiocode

megalinter-reports
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "cdevents-spec"]
path = cdevents-spec
url = https://github.com/cdevents/spec.git
branch = spec-v0.3
davidB marked this conversation as resolved.
Show resolved Hide resolved
40 changes: 40 additions & 0 deletions .mega-linter.yml
davidB marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Configuration file for MegaLinter
# See all available variables at https://megalinter.github.io/configuration/ and in linters documentation

APPLY_FIXES: none # all, none, or list of linter keys
# ENABLE: # If you use ENABLE variable, all other languages/formats/tooling-formats will be disabled by default
# ENABLE_LINTERS: # If you use ENABLE_LINTERS variable, all other linters will be disabled by default
DISABLE:
- COPYPASTE # Comment to enable checks of excessive copy-pastes
- SPELL # Comment to enable checks of spelling mistakes
DISABLE_LINTERS:
- DOCKERFILE_DOCKERFILELINT
- MARKDOWN_MARKDOWN_LINK_CHECK
- REPOSITORY_CHECKOV # unstable randomly failed (false negative) on generated k8s manifest
- REPOSITORY_DEVSKIM # issue with "git config --global --add safe.directory ..."
- REPOSITORY_GIT_DIFF
- REPOSITORY_GRYPE
- REPOSITORY_KICS
- REPOSITORY_SYFT
- REPOSITORY_TRUFFLEHOG # too long to search for secret
- RUST_CLIPPY # run via an other way, and current version doesn't support `--deny ... --allow ...`
- SQL_TSQLLINT # "You must install or update .NET to run this application."
SHOW_ELAPSED_TIME: true
FILEIO_REPORTER: false
# DISABLE_ERRORS: true # Uncomment if you want MegaLinter to detect errors but not block CI to pass
FILTER_REGEX_EXCLUDE: "(generated)|(megalinter-reports)|(cdevents-spec.*)|(.gitmodules)|(.sqlx)|(\\.lock)|(\\.ndjson)|(\\.pdf)|(\\.csv)|(\\.zip)|(\\.tar)|(\\.ipynb)|(license.*)|(LICENSE.*)"
SPELL_FILTER_REGEX_INCLUDE: '\\.md$'
PRINT_ALPACA: false
REPOSITORY_SECRETLINT_ARGUMENTS:
- --secretlintignore
- .gitignore
REPOSITORY_TRIVY_ARGUMENTS:
- --skip-dirs
- "cdevents-spec"
RUST_CLIPPY_ARGUMENTS:
- --workspace
- --all-features
- --all-targets
# - --deny warnings
# - --allow deprecated
# - --allow unknown-lints
16 changes: 16 additions & 0 deletions .mise.toml
davidB marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[env]
# RUSTC_WRAPPER = "sccache"
RUST_WITHOUT = "rust-docs"
# ASDF_RUST_PROFILE = "minimal"
MISE_CARGO_BINSTALL = "true"

[tools]
rust = "1.75"
make = "latest"
# # experimental
"cargo:cargo-binstall" = "latest"
"cargo:cargo-nextest" = "0.9"
# "cargo:cargo-hack" = "latest"
"cargo:cargo-deny" = "0.14"
# "cargo:git-cliff" = "latest"
"cargo:dprint" = "0.45"
Loading