Skip to content

Commit 3d801cf

Browse files
committed
🤖 Github Action performance improvements
1 parent 3154e9a commit 3d801cf

3 files changed

Lines changed: 85 additions & 10 deletions

File tree

.github/workflows/MergeToMain.yml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ jobs:
3333
- name: Setup .NET
3434
uses: actions/setup-dotnet@v5
3535

36+
- name: Cache NuGet packages
37+
uses: actions/cache@v4
38+
with:
39+
path: ~/.nuget/packages
40+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
41+
restore-keys: |
42+
${{ runner.os }}-nuget-
43+
3644
- run: dotnet restore --verbosity minimal
3745

3846
- run: dotnet build --configuration Release -p:ContinuousIntegrationBuild=true -p:DebugType=Embedded -p:VersionPrefix=$VERSION_PREFIX --version-suffix $VERSION_SUFFIX
@@ -57,11 +65,14 @@ jobs:
5765
--no-symbols \
5866
--api-key ${{ secrets.GITHUB_TOKEN }} \
5967
--source https://nuget.pkg.github.com/${{ github.repository_owner }}
68+
6069
6170
test:
6271
name: Build and Test with CodeCov (DEBUG)
6372
runs-on: ubuntu-latest
64-
73+
strategy:
74+
matrix:
75+
framework: [net8.0, net10.0]
6576

6677
steps:
6778
- name: Checkout repo
@@ -70,12 +81,20 @@ jobs:
7081
- name: Setup .NET
7182
uses: actions/setup-dotnet@v5
7283

84+
- name: Cache NuGet packages
85+
uses: actions/cache@v4
86+
with:
87+
path: ~/.nuget/packages
88+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
89+
restore-keys: |
90+
${{ runner.os }}-nuget-
91+
7392
- run: dotnet restore --verbosity minimal
7493

7594
- run: dotnet build --configuration Debug
7695

77-
- name: Run tests with code coverage
78-
run: dotnet run --project ./code/WorldDomination.SimpleObservability.Tests/WorldDomination.SimpleObservability.Tests.csproj --configuration Debug --no-build --framework net8.0 -- --coverage --coverage-output-format cobertura --coverage-output coverage.cobertura.xml
96+
- name: Run tests with code coverage (${{ matrix.framework }})
97+
run: dotnet run --project ./code/WorldDomination.SimpleObservability.Tests/WorldDomination.SimpleObservability.Tests.csproj --configuration Debug --no-build --framework ${{ matrix.framework }} -- --coverage --coverage-output-format cobertura --coverage-output coverage.cobertura.xml
7998

8099
- name: Code coverage
81100
uses: codecov/codecov-action@v5

.github/workflows/PullRequest.yml

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ jobs:
1818
- name: Setup .NET
1919
uses: actions/setup-dotnet@v5
2020

21+
- name: Cache NuGet packages
22+
uses: actions/cache@v4
23+
with:
24+
path: ~/.nuget/packages
25+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
26+
restore-keys: |
27+
${{ runner.os }}-nuget-
28+
2129
- run: dotnet restore --verbosity minimal
2230

2331
- run: dotnet build --configuration Debug /p:ContinuousIntegrationBuild=true
@@ -35,6 +43,9 @@ jobs:
3543
build_and_test_release:
3644
name: Build and test (RELEASE)
3745
runs-on: ubuntu-latest
46+
strategy:
47+
matrix:
48+
framework: [net8.0, net10.0]
3849

3950
steps:
4051
- name: Checkout repository
@@ -48,20 +59,27 @@ jobs:
4859
- name: Setup .NET
4960
uses: actions/setup-dotnet@v5
5061

62+
- name: Cache NuGet packages
63+
uses: actions/cache@v4
64+
with:
65+
path: ~/.nuget/packages
66+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
67+
restore-keys: |
68+
${{ runner.os }}-nuget-
69+
5170
- run: dotnet restore --verbosity minimal
5271

5372
- run: dotnet build --configuration Release -p:ContinuousIntegrationBuild=true -p:DebugType=Embedded -p:VersionPrefix=$VERSION_PREFIX --version-suffix $VERSION_SUFFIX
5473

55-
- name: Run tests (net8.0)
56-
run: dotnet run --project ./code/WorldDomination.SimpleObservability.Tests/WorldDomination.SimpleObservability.Tests.csproj --configuration Release --no-build --framework net8.0
57-
58-
- name: Run tests (net10.0)
59-
run: dotnet run --project ./code/WorldDomination.SimpleObservability.Tests/WorldDomination.SimpleObservability.Tests.csproj --configuration Release --no-build --framework net10.0
74+
- name: Run tests (${{ matrix.framework }})
75+
run: dotnet run --project ./code/WorldDomination.SimpleObservability.Tests/WorldDomination.SimpleObservability.Tests.csproj --configuration Release --no-build --framework ${{ matrix.framework }}
6076

6177
- run: dotnet pack --configuration Release --no-build --output ./artifacts -p:DebugType=Embedded -p:VersionPrefix=$VERSION_PREFIX --version-suffix $VERSION_SUFFIX
78+
if: matrix.framework == 'net8.0'
6279

6380
- name: Publish artifacts
6481
uses: actions/upload-artifact@v5
82+
if: matrix.framework == 'net8.0'
6583
with:
6684
name: NuGetPackage.${{ env.VERSION_PREFIX }}-${{ env.VERSION_SUFFIX }}
6785
path: ./artifacts/

.github/workflows/Release.yml

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ env:
1919
DOTNET_NOLOGO: true
2020

2121
jobs:
22-
build_and_create_a_nuget_publish:
23-
name: Build, Create a NuGet and Publish
22+
build_and_create_a_nuget:
23+
name: Build and Create a NuGet
2424
runs-on: ubuntu-latest
2525

2626
steps:
@@ -34,6 +34,14 @@ jobs:
3434
- name: Setup .NET
3535
uses: actions/setup-dotnet@v5
3636

37+
- name: Cache NuGet packages
38+
uses: actions/cache@v4
39+
with:
40+
path: ~/.nuget/packages
41+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
42+
restore-keys: |
43+
${{ runner.os }}-nuget-
44+
3745
- run: dotnet restore --verbosity minimal
3846

3947
- run: dotnet build --configuration Release -p:ContinuousIntegrationBuild=true -p:DebugType=Embedded -p:version=${{ env.RELEASE_VERSION }}
@@ -54,13 +62,43 @@ jobs:
5462
name: NuGetPackage.${{ env.RELEASE_VERSION }}
5563
files: ./artifacts/*
5664

65+
publish_to_gpr:
66+
name: Publish to GitHub Package Registry
67+
runs-on: ubuntu-latest
68+
needs: build_and_create_a_nuget
69+
70+
steps:
71+
- name: Calculate version from the Commit Tag
72+
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
73+
74+
- name: Download artifacts
75+
uses: actions/download-artifact@v5
76+
with:
77+
name: NuGetPackage.${{ env.RELEASE_VERSION }}
78+
path: ./artifacts/
79+
5780
- name: Publish to GPR
5881
run: |
5982
dotnet nuget push "./artifacts/*.nupkg" \
6083
--no-symbols \
6184
--api-key ${{ secrets.GITHUB_TOKEN }} \
6285
--source https://nuget.pkg.github.com/${{ github.repository_owner }}
6386
87+
publish_to_nuget:
88+
name: Publish to NuGet.org
89+
runs-on: ubuntu-latest
90+
needs: build_and_create_a_nuget
91+
92+
steps:
93+
- name: Calculate version from the Commit Tag
94+
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
95+
96+
- name: Download artifacts
97+
uses: actions/download-artifact@v5
98+
with:
99+
name: NuGetPackage.${{ env.RELEASE_VERSION }}
100+
path: ./artifacts/
101+
64102
- name: Publish to nuget.org
65103
run: |
66104
dotnet nuget push "./artifacts/*.nupkg" \

0 commit comments

Comments
 (0)