Skip to content

Commit

Permalink
feat: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kirinnee committed Feb 3, 2025
0 parents commit 58ecdf3
Show file tree
Hide file tree
Showing 37 changed files with 2,072 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"version": 1,
"isRoot": true,
"tools": {
"jetbrains.dotcover.globaltool": {
"version": "2023.2.5",
"commands": ["dotnet-dotcover"],
"rollForward": false
},
"dotnet-sonarscanner": {
"version": "9.0.2",
"commands": ["dotnet-sonarscanner"],
"rollForward": false
}
}
}
4 changes: 4 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
watch_file "./nix/env.nix" "./nix/fmt.nix" "./nix/packages.nix" "./nix/shells.nix" "./nix/pre-commit.nix" "./flake.nix" "./parse.nix"
use flake
PATH_add "$HOME/.dotnet/tools"
echo "ℹ️ Run 'pls setup' to complete setup"
3 changes: 3 additions & 0 deletions .github/actionlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
self-hosted-runner:
labels:
- '*'
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: daily
- package-ecosystem: nuget
directory: /
schedule:
interval: daily
- package-ecosystem: dotnet-sdk
directory: /
schedule:
interval: daily
132 changes: 132 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
name: CI-CD

on:
push:

env:
COVERAGE_THRESHOLD: 80
ATOMI_SERVICE: Boron

jobs:
precommit:
name: Pre-commit Check
runs-on:
- nscloud-ubuntu-22.04-amd64-4x8-with-cache
- nscloud-cache-size-50gb
- nscloud-cache-tag-carboxylic-boron-nix-store-cache
- nscloud-git-mirror-1gb
steps:
# Setup
- uses: AtomiCloud/actions.setup-nix@v1
- uses: AtomiCloud/actions.cache-nuget@v1

# Pre Commit
- name: Run pre-commit
run: nix develop .#ci -c ./scripts/ci/pre-commit.sh

sonarqube:
name: SonarQube
runs-on:
- nscloud-ubuntu-22.04-amd64-4x8-with-cache
- nscloud-cache-size-50gb
- nscloud-cache-tag-carboxylic-boron-sonarqube-cache
- nscloud-git-mirror-1gb
steps:
# Setup
- uses: AtomiCloud/actions.setup-nix@v1
- uses: AtomiCloud/actions.cache-nuget@v1

# Sonarqube
- name: Build and analyze
env:
ATOMI_PLATFORM: 'carboxylic'
ATOMI_SERVICE: 'boron'

SONAR_ORG: 'atomi-cloud'
SONAR_HOST: 'https://sonarcloud.io'
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: nix develop .#sonar -c scripts/ci/sonarqube.sh

test:
name: Test and Coverage
runs-on:
- nscloud-ubuntu-22.04-amd64-4x8-with-cache
- nscloud-cache-size-50gb
- nscloud-cache-tag-carboxylic-boron-test-cache
- nscloud-git-mirror-1gb
steps:
# Setup
- uses: AtomiCloud/actions.setup-nix@v1
- uses: AtomiCloud/actions.cache-nuget@v1

# Test
- name: Run Test
env:
ATOMI_SERVICE: ${{ env.ATOMI_SERVICE }}
run: nix develop .#ci -c ./scripts/ci/test.sh ${{ env.COVERAGE_THRESHOLD }}

publish:
name: Publish Current Commit
runs-on:
- nscloud-ubuntu-22.04-amd64-4x8-with-cache
- nscloud-cache-size-50gb
- nscloud-cache-tag-carboxylic-boron-publish-nuget-cache
- nscloud-git-mirror-1gb
steps:
# Setup
- uses: AtomiCloud/actions.setup-nix@v1
- uses: AtomiCloud/actions.cache-nuget@v1

# Publish
- name: Publish
env:
GITHUB_REPO_REF: ${{ github.repository }}
GITHUB_SHA: ${{ github.sha }}
GITHUB_BRANCH: ${{ env.GITHUB_REF_SLUG_URL }}

RELEASE: 'false'

NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: nix develop .#ci -c scripts/ci/publish.sh

release:
name: Semantic Release
needs:
- precommit
- publish
- test
- sonarqube

if: github.ref == 'refs/heads/main'
runs-on:
- nscloud-ubuntu-22.04-amd64-4x8-with-cache
- nscloud-cache-size-50gb
- nscloud-cache-tag-carboxylic-boron-releaser-nix-store-cache
- nscloud-git-mirror-1gb
steps:
# Setup
- uses: AtomiCloud/actions.setup-nix@v1
- uses: AtomiCloud/actions.cache-npm@v1
- uses: AtomiCloud/actions.cache-nuget@v1

# Release
- name: Release
env:
GITHUB_REPO_REF: ${{ github.repository }}
GITHUB_SHA: ${{ github.sha }}
GITHUB_BRANCH: ${{ env.GITHUB_REF_SLUG_URL }}

GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

run: nix develop .#releaser -c scripts/ci/release.sh
- name: Publish
env:
GITHUB_REPO_REF: ${{ github.repository }}
GITHUB_SHA: ${{ github.sha }}
GITHUB_BRANCH: ${{ env.GITHUB_REF_SLUG_URL }}

RELEASE: 'true'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: nix develop .#ci -c scripts/ci/publish.sh
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
obj
bin
Chsarpier
.DS_Store
.env
.idea
.direnv
.pre-commit-config.yaml
dotCover.Output/
dotCover.Output.*
*.*.DotSettings.user
6 changes: 6 additions & 0 deletions .gitlint
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[general]
contrib=CT1
ignore=B6

[contrib-title-conventional-commits]
types = amend,build,chore,ci,config,dep,docs,feat,fix,perf,refactor,style,test
8 changes: 8 additions & 0 deletions .prettierrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
tabWidth: 2
semi: true
singleQuote: true
bracketSpacing: true
trailingComma: all
arrowParens: avoid
printWidth: 120
singleAttributePerLine: false
28 changes: 28 additions & 0 deletions Boron.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Boron", "Boron\Boron.csproj", "{1B2C2CFB-A0EE-4782-B502-A604FB121D4D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTest", "UnitTest\UnitTest.csproj", "{2770CEC3-5B19-41BA-972B-5796B3EF9DA5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1B2C2CFB-A0EE-4782-B502-A604FB121D4D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1B2C2CFB-A0EE-4782-B502-A604FB121D4D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1B2C2CFB-A0EE-4782-B502-A604FB121D4D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1B2C2CFB-A0EE-4782-B502-A604FB121D4D}.Release|Any CPU.Build.0 = Release|Any CPU
{2770CEC3-5B19-41BA-972B-5796B3EF9DA5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2770CEC3-5B19-41BA-972B-5796B3EF9DA5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2770CEC3-5B19-41BA-972B-5796B3EF9DA5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2770CEC3-5B19-41BA-972B-5796B3EF9DA5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
25 changes: 25 additions & 0 deletions Boron/Boron.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<RootNamespace>CarboxylicBoron</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Description>IDomainProblem is a standardize domain error framework that follows ProblemDetails (RFC 7808)</Description>
<PackageIcon>logo.png</PackageIcon>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<RepositoryUrl>RepositoryUrl</RepositoryUrl>
<Authors>Ernest Ng</Authors>
<VersionPrefix>1.0.0</VersionPrefix>
<PackageId>AtomiCloud.IDomainProblem</PackageId>
<PackageReadmeFile>README.MD</PackageReadmeFile>
</PropertyGroup>
<ItemGroup>
<None Include="..\README.MD" Pack="true" PackagePath="\"/>
<None Include="..\LICENSE" Pack="true" PackagePath="\"/>
<None Include="..\logo.png" Pack="true" PackagePath="\"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="NJsonSchema" Version="11.1.0" />
</ItemGroup>
</Project>
13 changes: 13 additions & 0 deletions Boron/DomainProblemException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace CarboxylicBoron;

/// <summary>
/// Represents an exception that is thrown when a domain problem is encountered.
/// </summary>
/// <param name="problem"></param>
public class DomainProblemException(IDomainProblem problem) : Exception
{
/// <summary>
/// Gets the domain problem that was encountered.
/// </summary>
public IDomainProblem Problem { get; set; } = problem;
}
35 changes: 35 additions & 0 deletions Boron/IDomainProblem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System.Text.Json.Serialization;
using NJsonSchema.Annotations;

namespace CarboxylicBoron;

/// <summary>
/// Represents a domain problem that can be encountered during the execution of a command. Supposed to map to the ProblemDetails
/// RFC 7807 specification. See https://datatracker.ietf.org/doc/html/rfc7807
/// </summary>
public interface IDomainProblem
{
/// <summary>
/// Gets the unique identifier for the problem.
/// </summary>
[JsonIgnore, JsonSchemaIgnore]
public string Id { get; }

/// <summary>
/// The Title of the problem.
/// </summary>
[JsonIgnore, JsonSchemaIgnore]
public string Title { get; }

/// <summary>
/// The Status of the problem.
/// </summary>
[JsonIgnore, JsonSchemaIgnore]
public string Detail { get; }

/// <summary>
/// The Namespace or version of the problem.
/// </summary>
[JsonIgnore, JsonSchemaIgnore]
public string Namespace { get; }
}
14 changes: 14 additions & 0 deletions Boron/Utility.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace CarboxylicBoron;

public static class Utility
{
/// <summary>
/// Converts a domain problem to an exception.
/// </summary>
/// <param name="p">Problem to convert.</param>
/// <returns></returns>
public static DomainProblemException ToException(this IDomainProblem p)
{
return new DomainProblemException(p);
}
}
7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2025 AtomiCloud

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 changes: 20 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# IDomainProblem

[![Sonarcloud Status](https://sonarcloud.io/api/project_badges/measure?project=AtomiCloud_carboxylic.boron&metric=alert_status)](https://sonarcloud.io/dashboard?id=AtomiCloud_carboxylic.boron )
[![SonarCloud Coverage](https://sonarcloud.io/api/project_badges/measure?project=AtomiCloud_carboxylic.boron&metric=coverage)](https://sonarcloud.io/component_measures/metric/coverage/list?id=AtomiCloud_carboxylic.boron)
[![SonarCloud Bugs](https://sonarcloud.io/api/project_badges/measure?project=AtomiCloud_carboxylic.boron&metric=bugs)](https://sonarcloud.io/component_measures/metric/reliability_rating/list?id=AtomiCloud_carboxylic.boron)
[![SonarCloud Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=AtomiCloud_carboxylic.boron&metric=vulnerabilities)](https://sonarcloud.io/component_measures/metric/security_rating/list?id=AtomiCloud_carboxylic.boron)
[![GitHub Release Date](https://img.shields.io/github/release-date/AtomiCloud/carboxylic.boron)](https://github.com/AtomiCloud/carboxylic.boron/releases)
[![GitHub commit activity](https://img.shields.io/github/commit-activity/m/AtomiCloud/carboxylic.boron)](https://github.com/AtomiCloud/carboxylic.boron/commits/main)
![GitHub commits since latest release](https://img.shields.io/github/commits-since/AtomiCloud/carboxylic.boron/latest)
[![NuGet Downloads](https://img.shields.io/nuget/dt/AtomiCloud.IDomainProblem)](https://www.nuget.org/packages/AtomiCloud.IDomainProblem)
![GitHub branch check runs](https://img.shields.io/github/check-runs/AtomiCloud/carboxylic.boron/main)


IDomainProblem is a standardize domain error framework that follows ProblemDetails (RFC 7808)

# Installation

```bash
dotnet add package AtomiCloud.IDomainProblem
```
40 changes: 40 additions & 0 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
version: '3'

env:
COVERAGE_THRESHOLD: 80
ATOMI_SERVICE: Boron

tasks:
setup:
desc: 'Setup the repository'
cmds:
- dotnet restore
- dotnet tool restore
- ./scripts/local/secrets.sh

build:
desc: 'Build the library'
cmds:
- dotnet build

test:
desc: 'Test the library'
cmds:
- dotnet test

test:cover:
desc: 'Test the library with coverage'
silent: true
cmds:
- ./scripts/ci/test.sh ${COVERAGE_THRESHOLD}
test:cover:html:
desc: 'Test the library with html output'
silent: true
cmds:
- dotnet build --no-incremental > /dev/null
- dotnet dotcover test --dcReportType=HTML
test:clean:
desc: 'Clean the test results'
cmds:
- rm -rf ./dotCover.Output
- rm ./dotCover.Output.*
Loading

0 comments on commit 58ecdf3

Please sign in to comment.