Skip to content

Commit

Permalink
dotnet caching in workflows (#117)
Browse files Browse the repository at this point in the history
* Create main.yml

* Update dotnet.yml

* Update codeql.yml

* NuGet package locking

* Update codeql.yml

* Update dotnet.yml

* Update dotnet.yml

* Update codeql.yml

* Update nuget-publish.yml

* Rename main.yml to cleanup.yml
  • Loading branch information
JonathanBout authored Jan 24, 2025
1 parent 6043f58 commit 8b47fef
Show file tree
Hide file tree
Showing 19 changed files with 1,388 additions and 68 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Cleanup
on:
delete:
workflow_dispatch:

jobs:
cleanup:
if: github.event.ref_type == 'branch'
runs-on: ubuntu-24.04
steps:
- name: Branch Caches
run: |
echo "Fetching list of cache key"
cacheKeysForPR=$(gh cache list --ref $BRANCH --limit 100 --json id --jq '.[].id')
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
do
gh cache delete $cacheKey
done
echo "Done"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
BRANCH: ${{ github.event.ref }}
2 changes: 2 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ jobs:
uses: actions/[email protected]
if: ${{ matrix.language == 'csharp' }}
with:
cache: true
cache-dependency-path: '**/packages.lock.json'
dotnet-version: |
8.0.x
9.0.x
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
cache-dependency-path: '**/packages.lock.json'
dotnet-version: |
9.0.x
8.0.x
cache: true
- name: Restore dependencies
run: dotnet restore tests/unit/SimpleCDN.Tests.Unit.csproj
- name: Build
Expand All @@ -46,7 +48,9 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
cache-dependency-path: '**/packages.lock.json'
dotnet-version: 9.0.x
cache: true
- name: Restore dependencies
run: dotnet restore tests/integration/SimpleCDN.Tests.Integration.csproj
- name: Build
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/nuget-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ jobs:
- name: Setup Dotnet
uses: actions/setup-dotnet@v4
with:
cache: true
cache-dependency-path: '**/packages.lock.json'
dotnet-version: |
8.0.x
9.0.x
Expand All @@ -50,6 +52,8 @@ jobs:
- name: Setup Dotnet
uses: actions/setup-dotnet@v4
with:
cache: true
cache-dependency-path: '**/packages.lock.json'
dotnet-version: |
8.0.x
9.0.x
Expand Down
27 changes: 14 additions & 13 deletions benchmarks/SimpleCDN.Benchmarks.csproj
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net9.0;net8.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net9.0;net8.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\tests\mocks\SimpleCDN.Tests.Mocks.csproj" />
<ProjectReference Include="..\src\core\SimpleCDN.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\tests\mocks\SimpleCDN.Tests.Mocks.csproj" />
<ProjectReference Include="..\src\core\SimpleCDN.csproj" />
</ItemGroup>

</Project>
Loading

0 comments on commit 8b47fef

Please sign in to comment.