Skip to content

Commit

Permalink
Release 1.0.1 (#3)
Browse files Browse the repository at this point in the history
* Integrate `TestCov` (#1)

* Update `README.md` (#2)

* Update `README.md`

* Update `ci.yml`
  • Loading branch information
ns-vasilev authored Sep 15, 2023
1 parent 2395cd4 commit db33a0a
Show file tree
Hide file tree
Showing 18 changed files with 255 additions and 62 deletions.
33 changes: 31 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,34 @@ on:
branches:
- main
- dev
paths:
- ".github/workflows/**"
- "Package.swift"
- "Source/**"
- "Tests/**"
pull_request:
branches: [ main ]
paths:
- '.swiftlint.yml'
- ".github/workflows/**"
- "Package.swift"
- "Source/**"
- "Tests/**"

concurrency:
group: ci
cancel-in-progress: true

jobs:
SwiftLint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: GitHub Action for SwiftLint
uses: norio-nomura/action-swiftlint@3.2.1
with:
args: --strict
env:
DIFF_BASE: ${{ github.base_ref }}
Latest:
name: Test Latest (iOS, macOS, tvOS, watchOS)
runs-on: macOS-12
Expand All @@ -26,13 +46,22 @@ jobs:
- destination: "OS=16.1,name=iPhone 14 Pro"
name: "iOS"
scheme: "CQRS"
sdk: iphonesimulator
- destination: "OS=16.1,name=Apple TV"
name: "tvOS"
scheme: "CQRS"
sdk: appletvsimulator
- destination: "OS=9.1,name=Apple Watch Series 8 (45mm)"
name: "watchOS"
scheme: "CQRS"
sdk: watchsimulator
steps:
- uses: actions/checkout@v3
- name: ${{ matrix.name }}
run: xcodebuild test -scheme "${{ matrix.scheme }}" -destination "${{ matrix.destination }}" clean
run: xcodebuild test -scheme "${{ matrix.scheme }}" -destination "${{ matrix.destination }}" clean -enableCodeCoverage YES -resultBundlePath "./${{ matrix.sdk }}.xcresult" | xcpretty -r junit
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3.1.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
xcode: true
xcode_archive_path: "./${{ matrix.sdk }}.xcresult"
File renamed without changes.
102 changes: 102 additions & 0 deletions .swiftpm/xcode/xcshareddata/xcschemes/CQRS.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1410"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "CQRS"
BuildableName = "CQRS"
BlueprintName = "CQRS"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "CQRSTests"
BuildableName = "CQRSTests"
BlueprintName = "CQRSTests"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES"
onlyGenerateCoverageForSpecifiedTargets = "YES">
<CodeCoverageTargets>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "CQRS"
BuildableName = "CQRS"
BlueprintName = "CQRS"
ReferencedContainer = "container:">
</BuildableReference>
</CodeCoverageTargets>
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "CQRSTests"
BuildableName = "CQRSTests"
BlueprintName = "CQRSTests"
ReferencedContainer = "container:">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "CQRS"
BuildableName = "CQRS"
BlueprintName = "CQRS"
ReferencedContainer = "container:">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@
All notable changes to this project will be documented in this file.

#### 1.x Releases
- `1.0.x` Releases - [1.0.0](#100)
- `1.0.x` Releases - [1.0.0](#100) | [1.0.1](#101)

## [1.0.1](https://github.com/space-code/cqrs/releases/tag/1.0.1)
Released on 2023-09-15

### Added
- Integrate CodeCov.

### Updated
- Documentation typos.

## [1.0.0](https://github.com/space-code/cqrs/releases/tag/1.0.0)
Released on 2023-01-20.
Expand Down
23 changes: 14 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
<a href="https://developer.apple.com/"><img alt="Platform" src="https://img.shields.io/badge/platform-ios%20%7C%20osx%20%7C%20watchos%20%7C%20tvos-%23989898"/></a>
<a href="https://developer.apple.com/swift"><img alt="Swift5.7" src="https://img.shields.io/badge/language-Swift5.7-orange.svg"/></a>
<a href="https://github.com/space-code/cqrs"><img alt="CI" src="https://github.com/space-code/cqrs/actions/workflows/ci.yml/badge.svg?branch=main"></a>
<a href="https://github.com/apple/swift-package-manager" alt="RxSwift on Swift Package Manager" title="cqrs on Swift Package Manager"><img src="https://img.shields.io/badge/Swift%20Package%20Manager-compatible-brightgreen.svg" /></a>
<a href="https://github.com/apple/swift-package-manager" alt="CQRS on Swift Package Manager" title="cqrs on Swift Package Manager"><img src="https://img.shields.io/badge/Swift%20Package%20Manager-compatible-brightgreen.svg" /></a>
<a href="https://codecov.io/gh/space-code/cqrs"><img alt="CodeCov" src="https://codecov.io/gh/space-code/cqrs/graph/badge.svg?token=TI0NEXLCTX"></a>
</p>

## Description
`cqrs` is an implementation of the command and query responsibility segregation in Swift
`cqrs` is an implementation of the command and query responsibility segregation in Swift.

- [Usage](#usage)
- [Requirements](#requirements)
Expand All @@ -23,7 +24,9 @@

## Usage

1. Create an instance of a command or a query conforms to `ICommand` or `IQuery` respectively:
1. `ICommand` and `IQuery` contain data for use by an appropriate handler.

Create an instance of a command that conforms to `ICommand` or a query that conforms to `IQuery`, respectively:
```swift
import CQRS

Expand Down Expand Up @@ -58,7 +61,9 @@ final class ExampleQuery: IQueue {
}
```

2. Create an instance of a command handler or a query handler conforms to `ICommandHandler` or `IQueryHandler` respectively:
2. A command handler or a query handler contains the execution logic for a command or a query.

Create an instance of a command handler that conforms to `ICommandHandler` or a query handler that conforms to `IQueryHandler`, respectively:
```swift
import CQRS

Expand All @@ -68,7 +73,7 @@ final class ExampleCommandHandler: ICommandHandler {
// MARK: ICommandHandler

func execute(command: Command) throws {
// write execution logic
// write the execution logic here
}
}
```
Expand All @@ -82,12 +87,12 @@ final class ExampleQueryHandler: IQueryHandler {
// MARK: IQueryHandler

func execute(query: Query) throws -> Query.Result {
// write execution logic
// write the execution logic here
}
}
```

3. Register your handler implementation in container:
3. Register your handler implementation in the container:
```swift
import CQRS

Expand All @@ -102,7 +107,7 @@ let container = DependencyContainer()
container.register { ExampleQueryHandler() }
```

4. Create an instance of a `CommandDispatcher` or a `QueryDispatcher` with created container, like this:
4. Create an instance of a `CommandDispatcher` or a `QueryDispatcher` with the created container, like this:
```swift
import CQRS

Expand Down Expand Up @@ -151,7 +156,7 @@ Once you have your Swift package set up, adding `cqrs` as a dependency is as eas

```swift
dependencies: [
.package(url: "https://github.com/space-code/cqrs.git", .upToNextMajor(from: "1.0.0"))
.package(url: "https://github.com/space-code/cqrs.git", .upToNextMajor(from: "1.0.1"))
]
```

Expand Down
2 changes: 1 addition & 1 deletion Sources/CQRS/Classes/Command/Interfaces/ICommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Copyright © 2023 Space Code. All rights reserved.
//

/// Protocol that describes a command object.
/// The type to which all commands must conform.
///
/// In `CQRS` the command object is only responsible for
/// executing tasks that modify the state of the application.
Expand Down
16 changes: 8 additions & 8 deletions Sources/CQRS/Classes/Command/Interfaces/ICommandDispatcher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
// Copyright © 2023 Space Code. All rights reserved.
//

/// Protocol that describes a command dispatcher.
/// A type that is used for executing commands.
///
/// `ICommandDispatcher` is a centralization way to execute a command.
/// It resolves the right command handler for given command.
/// `ICommandDispatcher` is a centralized way to execute a command.
/// It resolves the appropriate command handler for a given command.
public protocol ICommandDispatcher {
/// Execute a command which conforms to `ICommand` protocol.
/// Executes a command that conforms to the `ICommand` protocol.
///
/// A command dispatch object resolves a command handler for given type of the command.
/// If command handler exists in the container, the command will be executed.
/// A command dispatch object resolves a command handler for the given type of command.
/// If the command handler exists in the container, the command will be executed.
///
/// - Parameter command: A command object.
/// - Parameter command: The command object.
///
/// - Throws: `CQRSError.failedResolve`failed to resolve command handler.
/// - Throws: `CQRSError.failedResolve`if the command handler failed to resolve.
func execute<T: ICommand>(command: T) throws
}
8 changes: 4 additions & 4 deletions Sources/CQRS/Classes/Command/Interfaces/ICommandHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
// Copyright © 2023 Space Code. All rights reserved.
//

/// Protocol that describes a command handler.
/// A type that encapsulates the logic for executing a command.
public protocol ICommandHandler<Command> {
associatedtype Command: ICommand

/// Execute a command.
/// Executes a command.
///
/// - Throws: `CQRSError.failedResolve` failed to resolve command handler.
/// - Throws: `CQRSError.failedResolve` if the command handler failed to resolve.
///
/// - Parameter command: A command object.
/// - Parameter command: The command object.
func execute(command: Command) throws
}
20 changes: 10 additions & 10 deletions Sources/CQRS/Classes/Helpers/Container/IDependencyContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,29 @@
// Copyright © 2023 Space Code. All rights reserved.
//

// Dependency injection container.
/// Dependency injection container.
public protocol IDependencyContainer {
/// Register a command handler in the container.
/// Registers a command handler in the container.
///
/// - Parameter object: A command handler which will be register in the container.
/// - Parameter object: The command handler that will be registered in the container.
func register<T: ICommandHandler>(_ object: T)

/// Register a query handler in the container.
/// Registers a query handler in the container.
///
/// - Parameter object: A query handler which will be register in thr container.
/// - Parameter object: The query handler that will be registered in the container.
func register<Q: IQueryHandler>(_ object: Q)

/// Resolve a command handler that command type is equal to `T`.
/// Resolves a command handler for which the command type is equal to 'T'.
///
/// - Throws: `CQRSError.failedResolve` if command handler could be resolved for the command.
///
/// - Returns: Resolver command handler with `T` command type.
/// - Returns: A resolved command handle with a command of type `T`.
func resolve<T: ICommand>() throws -> any ICommandHandler<T>

/// Resolve a query handler that command type is equal to `Q`.
/// Resolves a query handler for which the command type is equal to 'Q'.
///
/// - Throws: `CQRSError.failedResolve` if query handler could be resolved for the query.
/// - Throws: `CQRSError.failedResolve` if the query handler couldn't be resolved for the query.
///
/// - Returns: Resolver query handler with `Q` command type.
/// - Returns: A resolved query handle with a query of type `Q`.
func resolve<Q: IQuery>() throws -> any IQueryHandler<Q>
}
2 changes: 2 additions & 0 deletions Sources/CQRS/Classes/Models/CQRSError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// Copyright © 2023 Space Code. All rights reserved.
//

/// `CQRSError` is the error type returned by CQRS.
/// It encompasses a few different types of errors, each with their own associated reasons.
public enum CQRSError: Swift.Error {
/// Failed to resolve object from dependency container.
case failedResolve
Expand Down
2 changes: 1 addition & 1 deletion Sources/CQRS/Classes/Query/Interfaces/IQuery.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Copyright © 2023 Space Code. All rights reserved.
//

/// Protocol that describes a query object.
/// The type to which all queries must conform.
///
/// In `CQRS` the query object is only responsible for
/// executing tasks that modify the state of the application.
Expand Down
Loading

0 comments on commit db33a0a

Please sign in to comment.