Skip to content

Commit 143397d

Browse files
authored
Merge pull request #25 from dbones-labs/features/setup-ci-and-cd-2
Features/setup ci and cd 2
2 parents 74add91 + 0da59ba commit 143397d

File tree

2 files changed

+40
-151
lines changed

2 files changed

+40
-151
lines changed

.circleci/config.yml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
version: 2
1+
version: 2.1
2+
23
jobs:
34

45
setup:
56
docker:
6-
- image: dboneslabs/git-tools:latest
7+
- image: dboneslabs/tools-docker-gittools:latest
78
steps:
89
- checkout
910
- run:
@@ -74,7 +75,8 @@ jobs:
7475
mkdir ./results
7576
7677
cd src
77-
dotnet test --logger trx --results-directory ../results /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
78+
dotnet test --no-restore --no-build --configuration Release --logger trx --results-directory ../results /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Exclude="[*.*Tests]*"
79+
find . -type f -name "coverage.opencover.xml" -printf "/%P\n"| while read FILE ; do DIR=$(dirname "$FILE" ); mv ."$FILE" "$PWD"/../results"$DIR".coverage.opencover.xml;done;
7880
7981
cd ../results
8082
ls
@@ -84,16 +86,23 @@ jobs:
8486
paths:
8587
- results
8688
- src
89+
- store_artifacts:
90+
path: results
8791

8892
upload_result:
8993
docker:
90-
- image: byrnedo/alpine-curl
94+
- image: dboneslabs/tools-docker-codecov
9195
steps:
9296
- attach_workspace:
93-
at: ./
97+
at: ./results
9498
- run: |
95-
cd src
96-
bash <(curl -s https://codecov.io/bash) -f "*.Tests/coverage.opencover.xml"
99+
cd results
100+
REPORTS="${PWD}/*.xml"
101+
cp /app/* ${PWD}/
102+
ls
103+
104+
echo "uploading ${REPORTS}"
105+
./codecov.sh -f "${REPORTS}"
97106
98107
publish:
99108
docker:

README.md

Lines changed: 24 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# auditable
22

3+
[![release](https://img.shields.io/github/v/release/dbones-labs/auditable?logo=nuget)](https://github.com/dbones-labs/auditable/releases) [![Nuget](https://img.shields.io/badge/nuget-auditable-blue)](https://github.com/orgs/dbones-labs/packages?repo_name=auditable)
4+
[![docs](https://img.shields.io/badge/docs-auditable-blue)](https://dbones-labs.github.io/auditable/)
5+
6+
[![dbones-labs](https://circleci.com/gh/dbones-labs/auditable.svg?style=shield)](https://app.circleci.com/pipelines/github/dbones-labs/auditable)
7+
[![codecov](https://codecov.io/gh/dbones-labs/auditable/branch/master/graph/badge.svg?token=0AE8TL5PR3)](undefined)
8+
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/efd93328aebe4815a5710df7bbce5d03)](https://www.codacy.com/gh/dbones-labs/auditable/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=dbones-labs/auditable&amp;utm_campaign=Badge_Grade)
9+
10+
311
This is a small auditing framework
412

513
The need for auditing already exists in projects, the requirement to log information to prove something happened, but also to capture who, what and when a business action happened.
@@ -15,156 +23,28 @@ The need for auditing already exists in projects, the requirement to log informa
1523
- capture who with the `IPrincipal` or `IClaimsPrincipal`
1624
- Supports tracing, using the `OpenTelemerty/W3C` specification
1725

18-
## How does this differ from logging?
26+
# Downloads
27+
28+
you can find all packages here:
29+
30+
[![Nuget](https://img.shields.io/badge/nuget-auditable-blue)](https://github.com/orgs/dbones-labs/packages?repo_name=auditable)
31+
32+
33+
## Major releases
34+
35+
[![Nuget](https://img.shields.io/github/v/release/dbones-labs/auditable?logo=nuget)](https://github.com/dbones-labs/auditable/releases)
1936

20-
the following is a typical picture, but the real answer is: It depends (on your requirements)
37+
We use Milestones to represent an notable release
2138

2239

23-
| | Auditing | Logging |
24-
|--------------------------------------------------------------------|---------------------------------------------------------------------|------------------------------------------------------------------------------------------|
25-
| Use | Proof of a business action, with who did it, against what and when. | To understand what is happening with a service, and ensure it can be keep up and running |
26-
| Audience | External Auditors / Business | DevOps Engineer |
27-
| Fails | Loudly (excpetions are thrown) | Sliently (exceptions are swallowed) |
28-
| Process style | Sync | Async |
29-
| (typically) Stored for<br>(really depends on your<br>requirements) | possibly years (depending on your regulators and law) | possibly weeks to months (depending on your requirements) |
40+
## Patch / feature releases
3041

42+
We use a variant of Githubflow, so all feature branches have their own pre-release packages
3143

3244

33-
# Code teaser
3445

35-
Lets take ASPNET Core, please consider using the OpenTelemetry package to get all the data.
46+
# Docs and examples
3647

37-
## 1. Builder
48+
check out our docs for examples and more information
3849

39-
```
40-
var builder = Host
41-
.CreateDefaultBuilder()
42-
.ConfigureAuditable(conf =>
43-
{
44-
conf.Use<AspNet>(); //this is registering the ASPNET dependencies
45-
conf.UseWriter<File>(); //note the default writer is console
46-
})
47-
.ConfigureWebHostDefaults(x =>
48-
{
49-
x.UseStartup<TStartup>().UseTestServer();
50-
});
51-
```
52-
53-
## 2. AspNET startup
54-
55-
```
56-
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
57-
{
58-
app.UseRouting();
59-
60-
app.UseAuthentication();
61-
app.UseAuthorization();
62-
63-
//ensure its after auth*
64-
app.UseAuditable();
65-
66-
app.UseEndpoints(endpoints =>
67-
{
68-
endpoints.MapControllers();
69-
});
70-
71-
}
72-
```
73-
74-
## 3. add some auditable logs
75-
76-
imagine you want to load an account instance from the db and update it.
77-
78-
```
79-
[Route("/Account")]
80-
[Authorize]
81-
public class AccountController : Controller
82-
{
83-
private readonly DocumentSession _session;
84-
private readonly IAuditable _auditable;
85-
private readonly ILogger<TestController> _logger;
86-
87-
public AccountController(
88-
DocumentSession session,
89-
IAuditable auditable,
90-
ILogger<TestController> logger)
91-
{
92-
_session = session;
93-
_auditable = auditable;
94-
_logger = logger;
95-
}
96-
97-
98-
[HttpPut]
99-
public async Task<ActionResult> Put(AccountResource updatedAccount)
100-
{
101-
if (updatedAccount == null) throw new ArgumentNullException(nameof(updatedAccount));
102-
await using var auditContext = _auditable.CreateContext("Account.Update");
103-
104-
var account = await _session.GetById(updatedAccount.Id);
105-
auditContext.WatchTargets(account); //watch for detla's
106-
107-
//modify
108-
account.Name = updatedAccount.Name;
109-
110-
_logger.LogInformation("log out system information as normal");
111-
return new OkResult();
112-
113-
//as we are within a using block, this will write the auditable entry
114-
//at this point.
115-
}
116-
}
117-
```
118-
119-
## output app-dir\1980-01-02-10-03-15_audit-id.auditable
120-
121-
a file is created for this audit entry (without line breaks)
122-
123-
there is some keys bits of information:
124-
125-
- Initiator - is the person making the change (note this should support OAuth2/OIDC)
126-
- Environment - is the server that is running the app, and what version of the app
127-
- Request - is information about the single request (pulling the w3c info using OpenTelemetry)
128-
- Targets - all the objects being observed to see if they were Read, Modified or Deleted
129-
- Id - is the unique id of the Auditable entry
130-
131-
```
132-
{
133-
"Action": "Account.Update",
134-
"DateTime": "1980-01-02T10:03:15Z",
135-
"Initiator": {
136-
"Id": "abc-123",
137-
"Name": "dave"
138-
},
139-
"Environment": {
140-
"Host": "LAPTOP-VRDBEDO2",
141-
"Application": "testhost.x86, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
142-
},
143-
"Request": {
144-
"SpanId": "16ba66e3222c3149",
145-
"TraceId": "4bf92f3577b34da6a3ce929d0e0e4736",
146-
"ParentId": "00f067aa0ba902b7"
147-
},
148-
"Targets": [
149-
{
150-
"Type": "Auditable.AspNetCore.Tests.Account",
151-
"Id": "2",
152-
"Delta": {
153-
"Name": [
154-
"Dave",
155-
"Chan"
156-
]
157-
},
158-
"Style": "Observed",
159-
"Audit": "Modified"
160-
}
161-
],
162-
"Id": "audit-id"
163-
}
164-
```
165-
166-
# Why call it Auditable
167-
168-
All the information we are capturing is to support an Audit from an Auditor (typically external). They will look over the Auditable Entries during their Audit. Once the External Audit of an Application is complete, they will produce an Audit Report.
169-
170-
So by using this your application is `Auditable`.
50+
[![docs](https://img.shields.io/badge/docs-auditable-blue)](https://dbones-labs.github.io/auditable/)

0 commit comments

Comments
 (0)