Skip to content

Commit

Permalink
Cache NuGet on .csproj files (#372)
Browse files Browse the repository at this point in the history
* Cache NuGet on .csproj files

* Fix restore keys

* Formatting Markdown

* Fix

* Update PipelineWriterTests.cs

---------

Co-authored-by: Tom Longhurst <thomhurst@users.noreply.github.com>
  • Loading branch information
thomhurst and thomhurst authored Jan 12, 2024
1 parent b16cc9d commit ef2c11d
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/dotnet-mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ jobs:
uses: actions/cache@v3
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
- name: Build ModularPipelines.Analyzers.sln
run: dotnet build ModularPipelines.Analyzers.sln -c Release
- name: Build
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/dotnet-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ jobs:
uses: actions/cache@v3
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
- name: Build ModularPipelines.Analyzers.sln
run: dotnet build ModularPipelines.Analyzers.sln -c Release
- name: Build
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ jobs:
uses: actions/cache@v3
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
- name: Build ModularPipelines.Analyzers.sln
run: dotnet build ModularPipelines.Analyzers.sln -c Release
- name: Build
Expand Down
2 changes: 1 addition & 1 deletion src/ModularPipelines.Build/ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
NULL
null
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public async Task Write(IPipelineHookContext pipelineHookContext)
With = new
{
path= "~/.nuget/packages",
key= "${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}",
RestoreKeys = "${{ runner.os }}-nuget-",
key= "${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}",
RestoreKeys = "${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}",
},
},
new
Expand Down
4 changes: 2 additions & 2 deletions src/ModularPipelines/Engine/PipelineFileWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ IEnumerable<IBuildSystemPipelineFileWriter> writers
_serviceProvider = serviceProvider;
_writers = writers;
}

public async Task WritePipelineFiles()
{
await _writers
.ForEachAsync(x =>
.ForEachAsync(x =>
x.Write(_serviceProvider.GetRequiredService<IPipelineContext>())
)
.ProcessInParallel();
Expand Down
6 changes: 3 additions & 3 deletions test/ModularPipelines.UnitTests/PipelineWriterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ await TestPipelineHostBuilder.Create()
uses: actions/cache@v3
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: ${{ runner.os }}-nuget-
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
- name: Run Pipeline
run: dotnet run -c Release --framework net7.0 {{{RandomFilePath}}}
env:
Expand All @@ -154,4 +154,4 @@ await TestPipelineHostBuilder.Create()
EMAIL_PASSWORD: ${{ secrets.EMAIL_PASSWORD }}
""".Trim()));
}
}
}

0 comments on commit ef2c11d

Please sign in to comment.