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

Implement Events Handling (#1) #2

Merged
merged 42 commits into from
Aug 30, 2021
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
6697475
Basic project structure with Event and VersionedEvent impls
ilslv Aug 13, 2021
a6e1847
Add Makefile, GitHub Actions, PR and Issue templates
ilslv Aug 13, 2021
238058d
Add EventInitialized, EventSourced and InitialEvent
ilslv Aug 13, 2021
83f9911
Fix CI
ilslv Aug 13, 2021
f31ca0c
Finally check uniqueness of event_type() and ver() at compile-time!
ilslv Aug 16, 2021
42c5b4d
Add docs explaining unique checks macro shenanigans [skip ci]
ilslv Aug 16, 2021
7dfe985
Add ability to skip uniqueness check for event_type and ver for Event…
ilslv Aug 17, 2021
7df18ef
Add more tests
ilslv Aug 17, 2021
d454eaf
Final touches
ilslv Aug 17, 2021
c61e8bb
Use nightly toolchain on CI
ilslv Aug 17, 2021
32aec5d
Fix CI
ilslv Aug 17, 2021
aa8f2b4
Remove stable and beta toolchains in testing
ilslv Aug 17, 2021
e815e60
CHANGELOG
ilslv Aug 17, 2021
11107d1
Merge branch 'master' into 1-event-sourcing
tyranron Aug 17, 2021
b048ca1
Introduce EventName and EventVersion and support them in proc-macros
ilslv Aug 17, 2021
c6f1ff9
CHANGELOG
ilslv Aug 17, 2021
d7647b6
Merge branch 'master' into 1-event-sourcing
ilslv Aug 17, 2021
c477378
Some corrections [skip ci]
tyranron Aug 17, 2021
5166708
Merge remote-tracking branch 'origin/1-event-sourcing' into 1-event-s…
tyranron Aug 17, 2021
4bd1c85
Replace event_type() with name() everywhere [skip ci]
ilslv Aug 17, 2021
8bc5e8c
Add es feature-gates [skip ci]
ilslv Aug 17, 2021
418b233
Split derive and es feature-gates [skip ci]
ilslv Aug 17, 2021
683456b
Use arcana-core crate for arcana-codegen-impl docs [skip ci]
ilslv Aug 17, 2021
7a8ceb5
WIP [skip ci]
ilslv Aug 17, 2021
8a9b4ec
Cover Event derive macro with docs [skip ci]
ilslv Aug 17, 2021
32f233f
Cover VersionedEvent derive macro with docs [skip ci]
ilslv Aug 17, 2021
18a0c1a
Move events uniqueness check to arcana_codegen crate [skip ci]
ilslv Aug 18, 2021
de5edea
Use only required number of events in uniqueness check [skip ci]
ilslv Aug 20, 2021
fb0260a
Add arcana-codegen-shim [skip ci]
ilslv Aug 20, 2021
d74ae8e
Add MSRV check
ilslv Aug 23, 2021
eff3a0a
Fix CI
ilslv Aug 23, 2021
373d0c1
Remove safety_guard dependency
ilslv Aug 23, 2021
4ad217b
Some corrections [skip ci]
tyranron Aug 24, 2021
088db1a
Corrections
ilslv Aug 25, 2021
8cea01b
Correction
ilslv Aug 25, 2021
0a40645
Disable -Z minimal-versions for now on CI MSRV check
ilslv Aug 25, 2021
8a84f85
Some corrections [skip ci]
tyranron Aug 25, 2021
23306f4
Merge remote-tracking branch 'origin/1-event-sourcing' into 1-event-s…
tyranron Aug 25, 2021
2d2c92d
Try to support generics in internal uniqueness glue code
ilslv Aug 26, 2021
843cae5
Hide docs dependencies behind the feature
ilslv Aug 26, 2021
7685c03
Corrections
ilslv Aug 26, 2021
f522fcf
Corrections
tyranron Aug 30, 2021
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
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ indent_size = 4
[*.toml]
indent_style = space
indent_size = 4
max_line_length = off
128 changes: 128 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: CI

on: [push, pull_request]

env:
RUST_BACKTRACE: 1

jobs:

##########################
# Linting and formatting #
##########################

clippy:
if: ${{ github.ref == 'refs/heads/master'
|| startsWith(github.ref, 'refs/tags/v')
|| !contains(github.event.head_commit.message, '[skip ci]') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
components: clippy

- run: make cargo.lint

rustfmt:
if: ${{ github.ref == 'refs/heads/master'
|| startsWith(github.ref, 'refs/tags/v')
|| !contains(github.event.head_commit.message, '[skip ci]') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
components: rustfmt

- run: make cargo.fmt check=yes




###########
# Testing #
###########

test:
Copy link
Member

Choose a reason for hiding this comment

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

Also let's add tests for MSRV (minimum supported Rust version) from the start.

if: ${{ github.ref == 'refs/heads/master'
|| startsWith(github.ref, 'refs/tags/v')
|| !contains(github.event.head_commit.message, '[skip ci]') }}
strategy:
fail-fast: false
matrix:
crate:
- arcana
- arcana-core
- arcana-codegen
- arcana-codegen-shim
- arcana-codegen-core
os:
- ubuntu
- macOS
- windows
toolchain:
- nightly
runs-on: ${{ matrix.os }}-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.toolchain }}
override: true

- run: make test crate=${{ matrix.crate }}

msrv:
name: MSRV
if: ${{ github.ref == 'refs/heads/master'
|| startsWith(github.ref, 'refs/tags/v')
|| !contains(github.event.head_commit.message, '[skip ci]') }}
strategy:
fail-fast: false
matrix:
msrv: [ '1.54.0' ]
os:
- ubuntu
- macOS
- windows
runs-on: ${{ matrix.os }}-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.msrv }}
override: true

- run: cargo +nightly update -Z minimal-versions

- run: make test




#################
# Documentation #
#################

docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true

- run: make cargo.doc open=no
16 changes: 16 additions & 0 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Project configuration for rustfmt Rust code formatter.
# See full list of configurations at:
# https://github.com/rust-lang-nursery/rustfmt/blob/master/Configurations.md

max_width = 80
format_strings = false
imports_granularity = "Crate"

format_code_in_doc_comments = true
format_macro_matchers = true
use_try_shorthand = true

error_on_line_overflow = true
error_on_unformatted = true

unstable_features = true
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
`arcana` changelog
===================

All user visible changes to this project will be documented in this file. This project uses [Semantic Versioning 2.0.0].




## [0.1.0] · 2021-06-25
[0.1.0]: /../../tree/v0.1.0

### Initially implemented

- Events
- Traits
- `Event`
- `VersionedEvent`
- `EventSourced`
- `EventInitialised`
- Structs
- `InitialEvent` wrapper
- `EventVersion`
- Proc macros
- `Event` derive
- `VersionedEvent` derive




[Semantic Versioning 2.0.0]: https://semver.org
29 changes: 29 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[package]
name = "arcana"
version = "0.1.0-dev"
edition = "2018"
resolver = "2"
description = "Opionated CQRS/ES framework with type magic."
authors = [
"Ilya Solovyiov <[email protected]>",
"Kai Ren <[email protected]>"
]
documentation = "https://docs.rs/arcana-core"
homepage = "https://github.com/arcana-rs/arcana"
repository = "https://github.com/arcana-rs/arcana"
readme = "README.md"

[features]
derive = ["arcana-codegen"]
es = ["arcana-core/es"]

[dependencies]
arcana-core = { version = "0.1.0-dev", path = "./core" }
arcana-codegen = { version = "0.1.0-dev", path = "./codegen", optional = true }

[workspace]
members = ["codegen", "codegen/core", "codegen/shim", "core"]

[[example]]
name = "event"
required-features = ["derive", "es"]
88 changes: 88 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
###############################
# Common defaults/definitions #
###############################

comma := ,

# Checks two given strings for equality.
eq = $(if $(or $(1),$(2)),$(and $(findstring $(1),$(2)),\
$(findstring $(2),$(1))),1)




###########
# Aliases #
###########

docs: cargo.doc


fmt: cargo.fmt


lint: cargo.lint




##################
# Cargo commands #
##################

# Generate crates documentation from Rust sources.
#
# Usage:
# make cargo.doc [crate=<crate-name>] [open=(yes|no)] [clean=(no|yes)]

cargo.doc:
ifeq ($(clean),yes)
@rm -rf target/doc/
endif
cargo doc $(if $(call eq,$(crate),),--workspace,-p $(crate)) \
--all-features \
$(if $(call eq,$(open),no),,--open)


# Format Rust sources with rustfmt.
#
# Usage:
# make cargo.fmt [check=(no|yes)]

cargo.fmt:
cargo fmt --all $(if $(call eq,$(check),yes),-- --check,)


# Lint Rust sources with Clippy.
#
# Usage:
# make cargo.lint

cargo.lint:
cargo clippy --workspace -- -D clippy::pedantic -D warnings




####################
# Testing commands #
####################

# Run Rust tests of project.
#
# Usage:
# make test [crate=<crate-name>]

test:
cargo test $(if $(call eq,$(crate),),--workspace,-p $(crate)) \
--all-features




##################
# .PHONY section #
##################

.PHONY: docs fmt lint test \
cargo.doc cargo.fmt cargo.lint
19 changes: 19 additions & 0 deletions codegen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
name = "arcana-codegen"
version = "0.1.0-dev"
edition = "2018"
resolver = "2"
description = "Code generation of `arcana` crate."
authors = [
"Ilya Solovyiov <[email protected]>",
"Kai Ren <[email protected]>"
]
documentation = "https://docs.rs/arcana-codegen"
homepage = "https://github.com/arcana-rs/arcana/tree/master/codegen"
repository = "https://github.com/arcana-rs/arcana"
readme = "README.md"

[dependencies]
arcana-codegen-shim = { version = "0.1.0-dev", path = "./shim"}
arcana-core = { version = "0.1.0-dev", path = "../core", features = ["es"] }
static_assertions = { version = "1.1", default-features = false }
12 changes: 12 additions & 0 deletions codegen/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
arcana-codegen
==============

Code generation for [`arcana`] crate.

DO NOT use it directly, use [`arcana`] crate instead.





[`arcana`]: https://docs.rs/arcana
21 changes: 21 additions & 0 deletions codegen/core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[package]
name = "arcana-codegen-core"
version = "0.1.0-dev"
edition = "2018"
resolver = "2"
description = "Core implementations of `arcana-codegen` crate."
authors = [
"Ilya Solovyiov <[email protected]>",
"Kai Ren <[email protected]>"
]
documentation = "https://docs.rs/arcana-codegen-core"
homepage = "https://github.com/arcana-rs/arcana/tree/master/codegen/core"
repository = "https://github.com/arcana-rs/arcana"
readme = "README.md"

[dependencies]
arcana-core = { version = "0.1.0-dev", path = "../../core", features = ["es"] }
Copy link
Member

Choose a reason for hiding this comment

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

We shouldn't bloat dependencies with unused ones. If it's required for docs, let's introduce an appropriate feature, disabled by default.

proc-macro2 = { version = "1.0", default-features = false }
quote = { version = "1.0", default-features = false }
syn = { version = "1.0", features = ["derive", "extra-traits", "parsing", "printing"], default-features = false }
synthez = { version = "0.1", default-features = false }
15 changes: 15 additions & 0 deletions codegen/core/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
arcana-codegen-core
===================

Core implementations of [`arcana-codegen`] crate.

DO NOT use it directly, use [`arcana`] crate instead. Unless you need to reuse [`arcana-codegen`] inner machinery in your own [proc macro][1] crate.





[`arcana`]: https://docs.rs/arcana
[`arcana-codegen`]: https://docs.rs/arcana-codegen

[1]: https://doc.rust-lang.org/reference/procedural-macros.html
Loading