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

Check unit, fmt, build on ci #211

Merged
merged 14 commits into from
Jul 8, 2024
10 changes: 10 additions & 0 deletions .github/dotnet/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: dotnet setup
description: "base dotnet setup for project"
runs:
using: composite
steps:
- name: setup
id: setup-dotnet
uses: actions/setup-dotnet@v1
with:
dotnet-version: "6.0.x"
14 changes: 14 additions & 0 deletions .github/npm/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: npm setup
description: "base npm setup for project"
runs:
using: composite
steps:
- name: setup dotnet
uses: ./.github/dotnet
- uses: actions/setup-node@v3
with:
node-version: "lts/*"
- name: Run NPM install
shell: sh
run: npm ci
working-directory: ./src/Saunter.UI
54 changes: 28 additions & 26 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# Note: ci.yaml and release.yaml have some similar steps
# If updating dotnet-version, set in both.

name: CI
name: ci

on:
push:
Expand All @@ -10,30 +7,35 @@ on:
pull_request:

jobs:
build:

build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: 'lts/*' # latest LTS version
- uses: actions/setup-dotnet@v2
with:
dotnet-version: '6.0.x' # SDK Version to use; x will use the latest version of the channel
- uses: actions/checkout@v2
- name: setup build
uses: ./.github/npm
- name: Run dotnet build
run: dotnet build --configuration Debug

- name: Run NPM install
run: npm ci
working-directory: ./src/Saunter.UI
- name: Run dotnet build
run: dotnet build --configuration Debug
- name: Run dotnet test
run: dotnet test --no-build
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: setup dotnet
uses: ./.github/dotnet
- name: dotnet format check
run: dotnet format --verify-no-changes *.sln
env:
PATH: ${{ github.env.PATH }}:/home/runner/.dotnet/tools

# Below steps run only on CI, not release
- uses: actions/upload-artifact@v2
with:
name: saunter-bin
path: ./src/Saunter/bin
unit-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: setup build
uses: ./.github/npm
- name: unit test
run: dotnet test ./test/Saunter.Tests/Saunter.Tests.csproj
# TODO: why there are 2 of them....
- name: unit mark test
run: dotnet test ./test/Saunter.Tests.MarkerTypeTests/Saunter.Tests.MarkerTypeTests.csproj
48 changes: 13 additions & 35 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,45 +1,23 @@
# Note: ci.yaml and release.yaml have some similar steps
# If updating dotnet-version, set in both.

name: Release

on:
push:
tags:
- 'v*.*.*' # e.g. v0.1.0
- "v*.*.*" # e.g. v0.1.0

jobs:
release:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: 'lts/*' # latest LTS version
- uses: actions/setup-dotnet@v2
with:
dotnet-version: '6.0.x' # SDK Version to use; x will use the latest version of the channel

- name: Run NPM install
run: npm ci
working-directory: ./src/Saunter.UI
- name: Run dotnet build
run: dotnet build --configuration Debug
- name: Run dotnet test
run: dotnet test --no-build

# Below steps are only on release, not CI.
- name: Set version
# Gets the numeric version from a tag (e.g. v1.2.3 -> 1.2.3)
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
- name: Create Nuget package
run: dotnet pack ./src/Saunter/Saunter.csproj --configuration Release -p:Version="$RELEASE_VERSION" --output ./build
- name: Push Nuget package to Nuget.org
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: dotnet nuget push ./build/*.nupkg --api-key $NUGET_API_KEY --source "https://api.nuget.org/v3/index.json"


- uses: actions/checkout@v2
- name: setup build
uses: ./.github/npm
- name: Set version
# Gets the numeric version from a tag (e.g. v1.2.3 -> 1.2.3)
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
- name: Create Nuget package
run: dotnet pack ./src/Saunter/Saunter.csproj --configuration Release -p:Version="$RELEASE_VERSION" --output ./build
- name: Push Nuget package to Nuget.org
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: dotnet nuget push ./build/*.nupkg --api-key $NUGET_API_KEY --source "https://api.nuget.org/v3/index.json"
3 changes: 1 addition & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ Builds and releases managed with github actions.
### Build

* Local builds are as simple as `dotnet build && dotnet test`
* CI builds on every push
* CI builds,fmt,unit on every push
* [.github/workflows/ci.yaml](./.github/workflows/ci.yaml)
* Build and tests MUST pass before merging to master


### Release

* Locally, packages can be created using `dotnet pack ./src/Saunter/Saunter.csproj`
Expand Down
22 changes: 19 additions & 3 deletions Saunter.sln
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,33 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{6A
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StreetlightsAPI", "examples\StreetlightsAPI\StreetlightsAPI.csproj", "{F188D4A7-BBCB-464F-A370-2BD84D18EA79}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E0D34C77-924E-4F6B-9289-5A2F07D125A8}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{E0D34C77-924E-4F6B-9289-5A2F07D125A8}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
CHANGELOG.md = CHANGELOG.md
.github\workflows\ci.yaml = .github\workflows\ci.yaml
README.md = README.md
.github\workflows\release.yaml = .github\workflows\release.yaml
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Saunter.IntegrationTests.ReverseProxy", "test\Saunter.IntegrationTests.ReverseProxy\Saunter.IntegrationTests.ReverseProxy.csproj", "{7CD09B89-130A-41AF-ADAE-2166C4ED695B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Saunter.Tests.MarkerTypeTests", "test\Saunter.Tests.MarkerTypeTests\Saunter.Tests.MarkerTypeTests.csproj", "{02284473-6DE7-4EE0-8433-2AC295045549}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "actions", "actions", "{D8CB9C0D-9605-457B-979F-C8994B20A926}"
ProjectSection(SolutionItems) = preProject
.github\workflows\ci.yaml = .github\workflows\ci.yaml
.github\workflows\release.yaml = .github\workflows\release.yaml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dotnet", "dotnet", "{69459F9D-DA73-4E84-8BA7-4CE03E2B7664}"
ProjectSection(SolutionItems) = preProject
.github\dotnet\action.yaml = .github\dotnet\action.yaml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "npm", "npm", "{E8FACA22-CFED-4710-89E4-D55F31BF96B3}"
ProjectSection(SolutionItems) = preProject
.github\npm\action.yaml = .github\npm\action.yaml
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -108,6 +122,8 @@ Global
{F188D4A7-BBCB-464F-A370-2BD84D18EA79} = {6ABD4842-47AF-49A5-B057-0EBA64416789}
{7CD09B89-130A-41AF-ADAE-2166C4ED695B} = {6491E321-2D02-44AB-9116-D722FE169595}
{02284473-6DE7-4EE0-8433-2AC295045549} = {6491E321-2D02-44AB-9116-D722FE169595}
{69459F9D-DA73-4E84-8BA7-4CE03E2B7664} = {D8CB9C0D-9605-457B-979F-C8994B20A926}
{E8FACA22-CFED-4710-89E4-D55F31BF96B3} = {D8CB9C0D-9605-457B-979F-C8994B20A926}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2F85D9DA-DBCF-4F13-8C42-5719F1469B2E}
Expand Down
7 changes: 7 additions & 0 deletions test/Saunter.Tests.MarkerTypeTests/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# EditorConfig is awesome: https://EditorConfig.org

root=false

[*.{cs,vb}]

dotnet_code_quality_unused_parameters = non_public
7 changes: 7 additions & 0 deletions test/Saunter.Tests/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# EditorConfig is awesome: https://EditorConfig.org

root=false

[*.{cs,vb}]

dotnet_code_quality_unused_parameters = non_public
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,13 @@ public void PublishMyMessage() { }
public class TenantMessageConsumer
{
[Message(typeof(TenantCreated))]
public void SubscribeTenantCreatedEvent(Guid _, TenantCreated __) { }
public void SubscribeTenantCreatedEvent(Guid id, TenantCreated created) { }

[Message(typeof(TenantUpdated))]
public void SubscribeTenantUpdatedEvent(Guid _, TenantUpdated __) { }
public void SubscribeTenantUpdatedEvent(Guid id, TenantUpdated updated) { }

[Message(typeof(TenantRemoved))]
public void SubscribeTenantRemovedEvent(Guid _, TenantRemoved __) { }
public void SubscribeTenantRemovedEvent(Guid id, TenantRemoved removed) { }
}

[AsyncApi]
Expand All @@ -237,13 +237,13 @@ public void SubscribeTenantRemovedEvent(Guid _, TenantRemoved __) { }
public class TenantMessagePublisher
{
[Message(typeof(TenantCreated))]
public void PublishTenantCreatedEvent(Guid _, TenantCreated __) { }
public void PublishTenantCreatedEvent(Guid id, TenantCreated created) { }

[Message(typeof(TenantUpdated))]
public void PublishTenantUpdatedEvent(Guid _, TenantUpdated __) { }
public void PublishTenantUpdatedEvent(Guid id, TenantUpdated updated) { }

[Message(typeof(TenantRemoved))]
public void PublishTenantRemovedEvent(Guid _, TenantRemoved __) { }
public void PublishTenantRemovedEvent(Guid id, TenantRemoved removed) { }
}

[AsyncApi]
Expand All @@ -254,7 +254,7 @@ public class TenantGenericMessagePublisher
[Message(typeof(AnyTenantCreated))]
[Message(typeof(AnyTenantUpdated))]
[Message(typeof(AnyTenantRemoved))]
public void PublishTenantEvent<TEvent>(Guid _, TEvent __)
public void PublishTenantEvent<TEvent>(Guid id, TEvent @event)
where TEvent : IEvent
{
}
Expand All @@ -266,7 +266,7 @@ public void PublishTenantEvent<TEvent>(Guid _, TEvent __)
public class TenantSingleMessagePublisher
{
[Message(typeof(AnyTenantCreated))]
public void PublishTenantCreated(Guid _, AnyTenantCreated __)
public void PublishTenantCreated(Guid id, AnyTenantCreated created)
{
}
}
Expand All @@ -279,13 +279,13 @@ public void PublishTenantCreated(Guid _, AnyTenantCreated __)
public class OneTenantMessageConsumer
{
[Message(typeof(TenantCreated))]
public void SubscribeTenantCreatedEvent(Guid _, TenantCreated __) { }
public void SubscribeTenantCreatedEvent(Guid id, TenantCreated created) { }

[Message(typeof(TenantUpdated))]
public void SubscribeTenantUpdatedEvent(Guid _, TenantUpdated __) { }
public void SubscribeTenantUpdatedEvent(Guid id, TenantUpdated updated) { }

[Message(typeof(TenantRemoved))]
public void SubscribeTenantRemovedEvent(Guid _, TenantRemoved __) { }
public void SubscribeTenantRemovedEvent(Guid id, TenantRemoved removed) { }
}
}

Expand Down
Loading