Skip to content

Commit ef2c11d

Browse files
authored
Cache NuGet on .csproj files (#372)
* Cache NuGet on .csproj files * Fix restore keys * Formatting Markdown * Fix * Update PipelineWriterTests.cs --------- Co-authored-by: Tom Longhurst <thomhurst@users.noreply.github.com>
1 parent b16cc9d commit ef2c11d

File tree

7 files changed

+14
-14
lines changed

7 files changed

+14
-14
lines changed

.github/workflows/dotnet-mac.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ jobs:
3131
uses: actions/cache@v3
3232
with:
3333
path: ~/.nuget/packages
34-
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
34+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
3535
restore-keys: |
36-
${{ runner.os }}-nuget-
36+
${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
3737
- name: Build ModularPipelines.Analyzers.sln
3838
run: dotnet build ModularPipelines.Analyzers.sln -c Release
3939
- name: Build

.github/workflows/dotnet-windows.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ jobs:
3333
uses: actions/cache@v3
3434
with:
3535
path: ~/.nuget/packages
36-
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
36+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
3737
restore-keys: |
38-
${{ runner.os }}-nuget-
38+
${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
3939
- name: Build ModularPipelines.Analyzers.sln
4040
run: dotnet build ModularPipelines.Analyzers.sln -c Release
4141
- name: Build

.github/workflows/dotnet.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ jobs:
4949
uses: actions/cache@v3
5050
with:
5151
path: ~/.nuget/packages
52-
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
52+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
5353
restore-keys: |
54-
${{ runner.os }}-nuget-
54+
${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
5555
- name: Build ModularPipelines.Analyzers.sln
5656
run: dotnet build ModularPipelines.Analyzers.sln -c Release
5757
- name: Build
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
NULL
1+
null

src/ModularPipelines.GitHub/PipelineWriters/GitHubPipelineFileWriter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ public async Task Write(IPipelineHookContext pipelineHookContext)
5454
With = new
5555
{
5656
path= "~/.nuget/packages",
57-
key= "${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}",
58-
RestoreKeys = "${{ runner.os }}-nuget-",
57+
key= "${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}",
58+
RestoreKeys = "${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}",
5959
},
6060
},
6161
new

src/ModularPipelines/Engine/PipelineFileWriter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ IEnumerable<IBuildSystemPipelineFileWriter> writers
1818
_serviceProvider = serviceProvider;
1919
_writers = writers;
2020
}
21-
21+
2222
public async Task WritePipelineFiles()
2323
{
2424
await _writers
25-
.ForEachAsync(x =>
25+
.ForEachAsync(x =>
2626
x.Write(_serviceProvider.GetRequiredService<IPipelineContext>())
2727
)
2828
.ProcessInParallel();

test/ModularPipelines.UnitTests/PipelineWriterTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ await TestPipelineHostBuilder.Create()
132132
uses: actions/cache@v3
133133
with:
134134
path: ~/.nuget/packages
135-
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
136-
restore-keys: ${{ runner.os }}-nuget-
135+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
136+
restore-keys: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
137137
- name: Run Pipeline
138138
run: dotnet run -c Release --framework net7.0 {{{RandomFilePath}}}
139139
env:
@@ -154,4 +154,4 @@ await TestPipelineHostBuilder.Create()
154154
EMAIL_PASSWORD: ${{ secrets.EMAIL_PASSWORD }}
155155
""".Trim()));
156156
}
157-
}
157+
}

0 commit comments

Comments
 (0)