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

Ensure backgroundservice is reported as running before each invocation of DoWorkAsync #17

Merged
merged 7 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
40 changes: 38 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ATC coding rules - https://github.com/atc-net/atc-coding-rules
# Version: 1.0.0
# Updated: 25-09-2023
# Version: 1.0.1
# Updated: 03-06-2024
# Location: Root
# Distribution: DotNet8
# Inspired by: https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/code-style-rule-options
Expand Down Expand Up @@ -464,10 +464,46 @@ dotnet_diagnostic.MA0048.severity = error # https://github.com/atc-net
dotnet_diagnostic.CA1014.severity = none # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/CA1014.md
dotnet_diagnostic.CA1068.severity = error # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/CA1068.md
dotnet_diagnostic.CA1305.severity = error
dotnet_diagnostic.CA1308.severity = suggestion # Normalize strings to uppercase
dotnet_diagnostic.CA1510.severity = suggestion # Use ArgumentNullException throw helper
dotnet_diagnostic.CA1511.severity = suggestion # Use ArgumentException throw helper
dotnet_diagnostic.CA1512.severity = suggestion # Use ArgumentOutOfRangeException throw helper
dotnet_diagnostic.CA1513.severity = suggestion # Use ObjectDisposedException throw helper
dotnet_diagnostic.CA1514.severity = error # Avoid redundant length argument
dotnet_diagnostic.CA1707.severity = error # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/CA1707.md
dotnet_diagnostic.CA1812.severity = none
dotnet_diagnostic.CA1822.severity = suggestion
dotnet_diagnostic.CA1849.severity = error # Call async methods when in an async method
dotnet_diagnostic.CA1854.severity = suggestion # Prefer the 'IDictionary.TryGetValue(TKey, out TValue)' method
dotnet_diagnostic.CA1855.severity = suggestion # Prefer 'Clear' over 'Fill'
dotnet_diagnostic.CA1856.severity = error # Incorrect usage of ConstantExpected attribute
dotnet_diagnostic.CA1857.severity = suggestion # A constant is expected for the parameter
dotnet_diagnostic.CA1858.severity = suggestion # Use 'StartsWith' instead of 'IndexOf'
dotnet_diagnostic.CA1859.severity = suggestion # Use concrete types when possible for improved performance
dotnet_diagnostic.CA1860.severity = suggestion # Avoid using 'Enumerable.Any()' extension method
dotnet_diagnostic.CA1861.severity = suggestion # Avoid constant arrays as arguments
dotnet_diagnostic.CA1862.severity = error # Use the 'StringComparison' method overloads to perform case-insensitive string comparisons
dotnet_diagnostic.CA1863.severity = suggestion # Use 'CompositeFormat'
dotnet_diagnostic.CA1864.severity = suggestion # Prefer the 'IDictionary.TryAdd(TKey, TValue)' method
dotnet_diagnostic.CA1865.severity = suggestion # Use char overload
dotnet_diagnostic.CA1866.severity = suggestion # Use char overload
dotnet_diagnostic.CA1867.severity = suggestion # Use char overload
dotnet_diagnostic.CA1868.severity = suggestion # Unnecessary call to 'Contains(item)'
dotnet_diagnostic.CA1869.severity = suggestion # Cache and reuse 'JsonSerializerOptions' instances
dotnet_diagnostic.CA1870.severity = suggestion # Use a cached 'SearchValues' instance
dotnet_diagnostic.CA2007.severity = suggestion # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/CA2007.md
dotnet_diagnostic.CA2017.severity = error # Parameter count mismatch
dotnet_diagnostic.CA2018.severity = error # The count argument to Buffer.BlockCopy should specify the number of bytes to copy
dotnet_diagnostic.CA2019.severity = error # ThreadStatic fields should not use inline initialization
dotnet_diagnostic.CA2021.severity = error # Don't call Enumerable.Cast<T> or Enumerable.OfType<T> with incompatible types
dotnet_diagnostic.CA2250.severity = suggestion # Use ThrowIfCancellationRequested
dotnet_diagnostic.CA2252.severity = suggestion # Opt-in to preview features should be used with caution
dotnet_diagnostic.CA2253.severity = error # Named placeholders should not be numeric values
dotnet_diagnostic.CA2254.severity = suggestion # Template should be a static expression
dotnet_diagnostic.CA2255.severity = suggestion # The ModuleInitializer attribute should not be used in libraries
dotnet_diagnostic.CA2259.severity = error # Ensure ThreadStatic is only used with static fields
dotnet_diagnostic.CA2260.severity = error # Implement generic math interfaces correctly
dotnet_diagnostic.CA2261.severity = error # Do not use ConfigureAwaitOptions.SuppressThrowing with Task<TResult>
dotnet_diagnostic.IDE0005.severity = warning # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/IDE0005.md
dotnet_diagnostic.IDE0058.severity = none # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/IDE0058.md

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
name: "Pre-Integration"
name: Build and test

on:
pull_request:
types:
- opened
- synchronize
- reopened
push:

jobs:
dotnet-build:
build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
Expand All @@ -31,27 +27,6 @@ jobs:
run: dotnet restore

- name: 🛠️ Building library in release mode
run: dotnet build -c Release --no-restore

dotnet-test:
runs-on: ubuntu-latest
needs:
- dotnet-build
steps:
- name: 🛒 Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: ⚙️ Setup dotnet 8.0.x
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'

- name: 🔁 Restore packages
run: dotnet restore

- name: 🛠️ Build
run: dotnet build -c Release --no-restore /p:UseSourceLink=true

- name: 🧪 Run unit tests
Expand Down
82 changes: 0 additions & 82 deletions .github/workflows/post-integration.yml

This file was deleted.

50 changes: 50 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: release-please

on:
push:
branches:
- main

jobs:
release-please:
runs-on: ubuntu-latest
steps:
- name: release-please
id: release
uses: googleapis/release-please-action@v4
with:
token: ${{ secrets.RELEASE_PLEASE_PAT }}

- name: 🛒 Checkout repository
if: ${{ steps.release.outputs.release_created }}
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.RELEASE_PLEASE_PAT }}

- name: ⚙️ Setup dotnet 8.0.x
if: ${{ steps.release.outputs.release_created }}
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'

- name: 🧹 Clean
if: ${{ steps.release.outputs.release_created }}
run: dotnet clean -c Release && dotnet nuget locals all --clear

- name: 🔁 Restore packages
if: ${{ steps.release.outputs.release_created }}
run: dotnet restore

- name: 🛠️ Building library in release mode
if: ${{ steps.release.outputs.release_created }}
run: dotnet build -c Release --no-restore /p:UseSourceLink=true

- name: 🗳️ Creating library package for release
if: ${{ steps.release.outputs.release_created }}
run: dotnet pack -c Release --no-restore -o ${GITHUB_WORKSPACE}/packages /p:PublicRelease=true

- name: 📦 Push packages to NuGet
if: ${{ steps.release.outputs.release_created }}
run: |
dotnet nuget push ${GITHUB_WORKSPACE}/packages/*.nupkg -k ${{ secrets.NUGET_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate --no-symbols
57 changes: 0 additions & 57 deletions .github/workflows/release.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "1.0.53"
}
12 changes: 10 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
<NeutralLanguage>en</NeutralLanguage>
<DefaultLanguage>en-US</DefaultLanguage>
</PropertyGroup>

<PropertyGroup Label="Versioning">
<!-- The 'x-release-please-' comments are used to inform the release-please action that it should update the semver version here -->
<!-- x-release-please-start-version -->
<Version>1.0.53</Version>
<!-- x-release-please-end -->
<IncludeSourceRevisionInInformationalVersion>true</IncludeSourceRevisionInInformationalVersion>
</PropertyGroup>

<PropertyGroup Label="Compile settings">
<Nullable>enable</Nullable>
Expand Down Expand Up @@ -43,10 +51,10 @@
<ItemGroup Label="Code Analyzers">
<PackageReference Include="AsyncFixer" Version="1.6.0" PrivateAssets="All" />
<PackageReference Include="Asyncify" Version="0.9.7" PrivateAssets="All" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.162" PrivateAssets="All" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.169" PrivateAssets="All" />
<PackageReference Include="SecurityCodeScan.VS2019" Version="5.6.7" PrivateAssets="All" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.435" PrivateAssets="All" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.30.0.95878" PrivateAssets="All" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.32.0.97167" PrivateAssets="All" />
</ItemGroup>

</Project>
15 changes: 15 additions & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
"release-type": "simple",
"bootstrap-sha": "f3b07cd737f1930ba7e4f222d4fb90b3783f3ccc",
"pull-request-title-pattern": "chore: release version ${version}",
"pull-request-header": ":robot: Preparing to release next version",
"pull-request-footer": "This pull request was generated by release-please.",
"packages": {
".": {
}
},
"extra-files": [
"Directory.Build.props"
]
}
1 change: 1 addition & 0 deletions src/Atc.Hosting/BackgroundServiceBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ await Task
{
try
{
healthService.SetRunningState(ServiceName, isRunning: true);
await DoWorkAsync(stoppingToken).ConfigureAwait(false);
healthService.SetRunningState(ServiceName, isRunning: true);
}
Expand Down
3 changes: 0 additions & 3 deletions src/Atc.Hosting/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
global using System.Collections.Concurrent;
global using System.Diagnostics.CodeAnalysis;

global using Atc.Hosting.Internal;

global using Cronos;

global using Microsoft.Extensions.DependencyInjection;
global using Microsoft.Extensions.Hosting;
global using Microsoft.Extensions.Logging;
Expand Down
1 change: 0 additions & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.139" PrivateAssets="All" />
</ItemGroup>

</Project>
5 changes: 3 additions & 2 deletions test/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# https://www.meziantou.net/enforcing-asynchronous-code-good-practices-using-a-roslyn-analyzer.htm
dotnet_diagnostic.MA0004.severity = none # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/Meziantou/MA0004.md
dotnet_diagnostic.MA0016.severity = none # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/Meziantou/MA0016.md

dotnet_diagnostic.MA0051.severity = none # Method Length

# Microsoft - Code Analysis
# https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/
Expand Down Expand Up @@ -54,4 +54,5 @@ dotnet_diagnostic.SA1133.severity = none # https://github.com/atc-net
# Custom - Code Analyzers Rules
##########################################

dotnet_diagnostic.CA1062.severity = none # Validate arguments of public methods
dotnet_diagnostic.CA1062.severity = none # Validate arguments of public methods
dotnet_diagnostic.CA2201.severity = none # Do not raise reserved exception types
Loading