Skip to content

Commit

Permalink
chore: Greatly improved pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
svrooij committed Aug 9, 2023
1 parent 3ed823d commit c9a7929
Show file tree
Hide file tree
Showing 11 changed files with 144 additions and 69 deletions.
28 changes: 28 additions & 0 deletions .github/matchers/dotnet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"problemMatcher": [
{
"owner": "dotnet-file",
"pattern": [
{
"regexp": "^(.+)\\((\\d+).+\\):\\s(\\w+)\\s(.+)\\:\\s(.*)$",
"file": 1,
"line": 2,
"severity": 3,
"code": 4,
"message": 5
}
]
},
{
"owner": "dotnet-run",
"pattern": [
{
"regexp": "^.+\\s\\:\\s(\\w+)\\s(.*)\\:\\s(.*)$",
"severity": 1,
"code": 2,
"message": 3
}
]
}
]
}
82 changes: 52 additions & 30 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
name: Building library
name: 🛠️ Building library

on:
workflow_dispatch:
push:
branches:
- main
- develop
- feature/*
pull_request:
branches:
- main
Expand All @@ -13,84 +15,104 @@ on:

jobs:
build:
name: Build and test
name: 🛠️ Build and test
runs-on: ubuntu-latest
# strategy:
# matrix:
# dotnet-version: ['3.0', '3.1.x', '5.0.x' ]

steps:
- uses: actions/checkout@v3
# - name: Setup .NET Core SDK ${{ matrix.dotnet-version }}
- name: Setup .NET Core SDK
- name: 👨‍💻 Check-out code
uses: actions/checkout@v3

- name: 👨‍🔧 Setup .NET Core SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.x
- uses: actions/cache@v3

- name: 🔍 Enable problem matchers
run: echo "::add-matcher::.github/matchers/dotnet.json"

- name: 🦸‍♂️ Restore steriods
uses: actions/cache@v3
with:
path: ~/.nuget/packages
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget
- name: Install dependencies
- name: 🎒 Load packages
run: dotnet restore
- name: Build

- name: 🛠️ Build code
run: dotnet build --configuration Release --no-restore
- name: Test
run: dotnet test --configuration Release --no-restore --collect:"XPlat Code Coverage" --no-build --verbosity minimal --logger trx
- name: Test Report
uses: dorny/[email protected]
if: success() || failure() # run this step even if previous step failed
with:
name: Test results # Name of the check run which will be created
path: tests/**/TestResults/*.trx # Path to test results
reporter: dotnet-trx # Format of test results
list-tests: failed # Only list failed tests vs all tests

- name: 🫣 Testing code
run: dotnet test --configuration Release -v minimal --no-build --logger GitHubActions '/p:CollectCoverage=true;CoverletOutputFormat="json,lcov,cobertura";MergeWith=${{github.workspace}}/coverage.json;CoverletOutput=${{github.workspace}}/coverage' -- RunConfiguration.CollectSourceInformation=true

- name: 📝 Code Coverage report
run: |
dotnet tool install --global dotnet-reportgenerator-globaltool --version 5.1.23
reportgenerator -reports:${{github.workspace}}/coverage.cobertura.xml -targetdir:${{github.workspace}}/report -reporttypes:MarkdownSummaryGithub -filefilters:-*.g.cs -verbosity:Warning
sed -i 's/# Summary/## 📝 Code Coverage/g' ${{github.workspace}}/report/SummaryGithub.md
sed -i 's/## Coverage/### 📝 Code Coverage details/g' ${{github.workspace}}/report/SummaryGithub.md
cat ${{github.workspace}}/report/*.md >> $GITHUB_STEP_SUMMARY
publish:
name: Publish nuget library
name: 📦 Publish nuget library
runs-on: ubuntu-latest
if: (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop') && github.event_name == 'push'
needs: [build]
steps:
- uses: actions/checkout@v3
- name: 👨‍💻 Check-out code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup .NET Core SDK
- name: 👨‍🔧 Setup .NET Core SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.x
- uses: actions/cache@v3

- name: 🔍 Enable problem matchers
run: echo "::add-matcher::.github/matchers/dotnet.json"

- name: 🦸‍♂️ Restore steriods
uses: actions/cache@v3
with:
path: ~/.nuget/packages
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget
- name: Install GitVersion
- name: 🛠️ Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '5.x'
- name: Determine Version

- name: 🕵️ Determine Version
uses: gittools/actions/gitversion/[email protected]
with:
useConfigFile: true
additionalArguments: /updateprojectfiles
- name: Install dependencies

- name: 🎒 Load packages
run: dotnet restore
- name: Build

- name: 🛠️ Build code
run: dotnet build --configuration Release --no-restore
- name: Pack Sonos.Base

- name: 📦 Pack Sonos.Base
run: dotnet pack --configuration Release --no-build --no-restore ./src/Sonos.Base/Sonos.Base.csproj
- name: Publish Sonos.Base to nuget.org
- name: ✈️ Publish Sonos.Base to nuget.org
run: dotnet nuget push ./src/Sonos.Base/bin/Release/Sonos.Base.*.nupkg -k $NUGET_AUTH_TOKEN -s https://api.nuget.org/v3/index.json
env:
NUGET_AUTH_TOKEN: ${{ secrets.NUGET_TOKEN }}

- name: Pack Sonos.Base.Events.Http
- name: 📦 Pack Sonos.Base.Events.Http
run: dotnet pack --configuration Release --no-build --no-restore ./src/Sonos.Base.Events.Http/Sonos.Base.Events.Http.csproj
- name: Publish Sonos.Base.Events.Http to nuget.org
- name: ✈️ Publish Sonos.Base.Events.Http to nuget.org
run: dotnet nuget push ./src/Sonos.Base.Events.Http/bin/Release/Sonos.Base.*.nupkg -k $NUGET_AUTH_TOKEN -s https://api.nuget.org/v3/index.json
env:
NUGET_AUTH_TOKEN: ${{ secrets.NUGET_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ _TeamCity*
*.coverage
*.coveragexml

coverage.*

# NCrunch
_NCrunch_*
.*crunch*.local.xml
Expand Down
6 changes: 3 additions & 3 deletions src/Sonos.Base.Events.Http/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@
},
"Microsoft.Extensions.Logging.Abstractions": {
"type": "Transitive",
"resolved": "7.0.0",
"contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw=="
"resolved": "7.0.1",
"contentHash": "pkeBFx0vqMW/A3aUVHh7MPu3WkBhaVlezhSZeb1c9XD0vUReYH1TLFSy5MxJgZfmz5LZzYoErMorlYZiwpOoNA=="
},
"Microsoft.Extensions.Options": {
"type": "Transitive",
Expand All @@ -195,7 +195,7 @@
"type": "Project",
"dependencies": {
"Microsoft.Extensions.Http": "[7.0.0, )",
"Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )"
"Microsoft.Extensions.Logging.Abstractions": "[7.0.1, )"
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Sonos.Base/Sonos.Base.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net7.0' or '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.1" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="System.Text.Json" Version="7.0.2" />
<PackageReference Include="System.Text.Json" Version="7.0.3" />
</ItemGroup>
</Project>
18 changes: 9 additions & 9 deletions src/Sonos.Base/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
},
"Microsoft.Extensions.Logging.Abstractions": {
"type": "Direct",
"requested": "[7.0.0, )",
"resolved": "7.0.0",
"contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==",
"requested": "[7.0.1, )",
"resolved": "7.0.1",
"contentHash": "pkeBFx0vqMW/A3aUVHh7MPu3WkBhaVlezhSZeb1c9XD0vUReYH1TLFSy5MxJgZfmz5LZzYoErMorlYZiwpOoNA==",
"dependencies": {
"System.Buffers": "4.5.1",
"System.Memory": "4.5.5"
Expand All @@ -35,9 +35,9 @@
},
"System.Text.Json": {
"type": "Direct",
"requested": "[7.0.2, )",
"resolved": "7.0.2",
"contentHash": "/LZf/JrGyilojqwpaywb+sSz8Tew7ij4K/Sk+UW8AKfAK7KRhR6mKpKtTm06cYA7bCpGTWfYksIW+mVsdxPegQ==",
"requested": "[7.0.3, )",
"resolved": "7.0.3",
"contentHash": "AyjhwXN1zTFeIibHimfJn6eAsZ7rTBib79JQpzg8WAuR/HKDu9JGNHTuu3nbbXQ/bgI+U4z6HtZmCHNXB1QXrQ==",
"dependencies": {
"Microsoft.Bcl.AsyncInterfaces": "7.0.0",
"System.Buffers": "4.5.1",
Expand Down Expand Up @@ -261,9 +261,9 @@
},
"Microsoft.Extensions.Logging.Abstractions": {
"type": "Direct",
"requested": "[7.0.0, )",
"resolved": "7.0.0",
"contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw=="
"requested": "[7.0.1, )",
"resolved": "7.0.1",
"contentHash": "pkeBFx0vqMW/A3aUVHh7MPu3WkBhaVlezhSZeb1c9XD0vUReYH1TLFSy5MxJgZfmz5LZzYoErMorlYZiwpOoNA=="
},
"Microsoft.Extensions.DependencyInjection": {
"type": "Transitive",
Expand Down
4 changes: 2 additions & 2 deletions src/Sonos.Cli/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
"profiles": {
"Sonos.Cli": {
"commandName": "Project",
"commandLineArgs": "192.168.200.61 events AVTransport",
"commandLineArgs": "192.168.200.61 play playlist 9 spotify:playlist:4P76Xyz8Oh4i6AVInqsikt",
"hotReloadEnabled": false,
"environmentVariables": {
"DOTNET_ENVIRONMENT": "Development",
"SONOSEVENTS__HOST": "192.168.200.127"

}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Sonos.Cli/Sonos.Cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
<PackageReference Include="System.CommandLine.Hosting" Version="0.4.0-alpha.22272.1" />
</ItemGroup>
<ItemGroup>
Expand Down
30 changes: 18 additions & 12 deletions src/Sonos.Cli/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"net7.0": {
"Microsoft.Extensions.Hosting": {
"type": "Direct",
"requested": "[7.0.0, )",
"resolved": "7.0.0",
"contentHash": "4nFc8xCfK26G524ioreZvz/IeIKN/gY1LApoGpaIThKqBdTwauUo4ETCf12lQcoefijqe3Imnfvnk31IezFatg==",
"requested": "[7.0.1, )",
"resolved": "7.0.1",
"contentHash": "aoeMou6XSW84wiqd895OdaGyO9PfH6nohQJ0XBcshRDafbdIU6PQIVl8TpOCssPYq3ciRseP5064hbFyCR9J9w==",
"dependencies": {
"Microsoft.Extensions.Configuration": "7.0.0",
"Microsoft.Extensions.Configuration.Abstractions": "7.0.0",
"Microsoft.Extensions.Configuration.Binder": "7.0.0",
"Microsoft.Extensions.Configuration.Binder": "7.0.3",
"Microsoft.Extensions.Configuration.CommandLine": "7.0.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "7.0.0",
"Microsoft.Extensions.Configuration.FileExtensions": "7.0.0",
Expand All @@ -28,7 +28,8 @@
"Microsoft.Extensions.Logging.Debug": "7.0.0",
"Microsoft.Extensions.Logging.EventLog": "7.0.0",
"Microsoft.Extensions.Logging.EventSource": "7.0.0",
"Microsoft.Extensions.Options": "7.0.0"
"Microsoft.Extensions.Options": "7.0.1",
"System.Diagnostics.DiagnosticSource": "7.0.1"
}
},
"Microsoft.Extensions.Http": {
Expand Down Expand Up @@ -73,8 +74,8 @@
},
"Microsoft.Extensions.Configuration.Binder": {
"type": "Transitive",
"resolved": "7.0.0",
"contentHash": "tgU4u7bZsoS9MKVRiotVMAwHtbREHr5/5zSEV+JPhg46+ox47Au84E3D2IacAaB0bk5ePNaNieTlPrfjbbRJkg==",
"resolved": "7.0.3",
"contentHash": "1eRFwJBrkkncTpvh6mivB8zg4uBVm6+Y6stEJERrVEqZZc8Hvf+N1iIgj2ySYDUQko4J1Gw1rLf1M8bG83F0eA==",
"dependencies": {
"Microsoft.Extensions.Configuration.Abstractions": "7.0.0"
}
Expand Down Expand Up @@ -191,8 +192,8 @@
},
"Microsoft.Extensions.Logging.Abstractions": {
"type": "Transitive",
"resolved": "7.0.0",
"contentHash": "kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw=="
"resolved": "7.0.1",
"contentHash": "pkeBFx0vqMW/A3aUVHh7MPu3WkBhaVlezhSZeb1c9XD0vUReYH1TLFSy5MxJgZfmz5LZzYoErMorlYZiwpOoNA=="
},
"Microsoft.Extensions.Logging.Configuration": {
"type": "Transitive",
Expand Down Expand Up @@ -259,8 +260,8 @@
},
"Microsoft.Extensions.Options": {
"type": "Transitive",
"resolved": "7.0.0",
"contentHash": "lP1yBnTTU42cKpMozuafbvNtQ7QcBjr/CcK3bYOGEMH55Fjt+iecXjT6chR7vbgCMqy3PG3aNQSZgo/EuY/9qQ==",
"resolved": "7.0.1",
"contentHash": "pZRDYdN1FpepOIfHU62QoBQ6zdAoTvnjxFfqAzEd9Jhb2dfhA5i6jeTdgGgcgTWFRC7oT0+3XrbQu4LjvgX1Nw==",
"dependencies": {
"Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0",
"Microsoft.Extensions.Primitives": "7.0.0"
Expand Down Expand Up @@ -296,6 +297,11 @@
"System.CommandLine": "2.0.0-beta4.22272.1"
}
},
"System.Diagnostics.DiagnosticSource": {
"type": "Transitive",
"resolved": "7.0.1",
"contentHash": "T9SLFxzDp0SreCffRDXSAS5G+lq6E8qP4knHS2IBjwCdx2KEvGnGZsq7gFpselYOda7l6gXsJMD93TQsFj/URA=="
},
"System.Diagnostics.EventLog": {
"type": "Transitive",
"resolved": "7.0.0",
Expand All @@ -318,7 +324,7 @@
"type": "Project",
"dependencies": {
"Microsoft.Extensions.Http": "[7.0.0, )",
"Microsoft.Extensions.Logging.Abstractions": "[7.0.0, )"
"Microsoft.Extensions.Logging.Abstractions": "[7.0.1, )"
}
},
"sonos.base.events.http": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,25 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="Moq" Version="4.18.3" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.0" />
<PackageReference Include="Moq" Version="4.20.2" />
<PackageReference Include="xunit" Version="2.5.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.2.0">
<PackageReference Include="coverlet.collector" Version="6.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.msbuild" Version="6.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="GitHubActionsTestLogger" Version="2.3.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit c9a7929

Please sign in to comment.