Skip to content

Commit f6ae8dd

Browse files
authored
ci: add caching for NuGet packages in CI workflows (#522)
Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com> <!-- Please use this template for your pull request. --> <!-- Please use the sections that you need and delete other sections --> ## This PR <!-- add the description of the PR here --> This pull request enhances the CI/CD workflows by adding caching for NuGet packages across multiple workflow files. This change aims to improve build performance by avoiding repeated downloads of dependencies. ### Workflow Improvements: * [`.github/workflows/ci.yml`](diffhunk://#diff-b803fcb7f17ed9235f1e5cb1fcd2f5d3b2838429d4368ae4c57ce4436577f03fR39-R46): Added a step to cache NuGet packages in both the main CI job and another job within the same file. This uses the `actions/cache` action to store packages in `~/.nuget/packages` and leverages file hashing for cache keys. [[1]](diffhunk://#diff-b803fcb7f17ed9235f1e5cb1fcd2f5d3b2838429d4368ae4c57ce4436577f03fR39-R46) [[2]](diffhunk://#diff-b803fcb7f17ed9235f1e5cb1fcd2f5d3b2838429d4368ae4c57ce4436577f03fR82-R89) * [`.github/workflows/code-coverage.yml`](diffhunk://#diff-49708f979e226a1e7bd7a68d71b2e91aae8114dd3e9254d9830cd3b4d62d4303R37-R44): Introduced NuGet package caching to the code coverage workflow, improving efficiency during the `dotnet test` step. * [`.github/workflows/e2e.yml`](diffhunk://#diff-3e103440521ada06efd263ae09b259e5507e4b8f7408308dc227621ad9efa31eR32-R39): Added caching for NuGet packages in the end-to-end testing workflow, reducing setup time for dependencies. * [`.github/workflows/release.yml`](diffhunk://#diff-87db21a973eed4fef5f32b267aa60fcee5cbdf03c67fafdc2a9b553bb0b15f34R54-R61): Implemented NuGet package caching in the release workflow to optimize dependency installation during the `dotnet restore` step. ### Notes <!-- any additional notes for this PR --> This is similar to open-feature/dotnet-sdk-contrib#453 --------- Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com>
1 parent fbc2645 commit f6ae8dd

File tree

4 files changed

+40
-0
lines changed

4 files changed

+40
-0
lines changed

.github/workflows/ci.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ jobs:
3636
global-json-file: global.json
3737
source-url: https://nuget.pkg.github.com/open-feature/index.json
3838

39+
- name: Cache NuGet packages
40+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
41+
with:
42+
path: ~/.nuget/packages
43+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
44+
restore-keys: |
45+
${{ runner.os }}-nuget-
46+
3947
- name: Restore
4048
run: dotnet restore
4149

@@ -71,6 +79,14 @@ jobs:
7179
global-json-file: global.json
7280
source-url: https://nuget.pkg.github.com/open-feature/index.json
7381

82+
- name: Cache NuGet packages
83+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
84+
with:
85+
path: ~/.nuget/packages
86+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
87+
restore-keys: |
88+
${{ runner.os }}-nuget-
89+
7490
- name: Restore
7591
run: dotnet restore
7692

.github/workflows/code-coverage.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ jobs:
3434
global-json-file: global.json
3535
source-url: https://nuget.pkg.github.com/open-feature/index.json
3636

37+
- name: Cache NuGet packages
38+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
39+
with:
40+
path: ~/.nuget/packages
41+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
42+
restore-keys: |
43+
${{ runner.os }}-nuget-
44+
3745
- name: Run Test
3846
run: dotnet test --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
3947

.github/workflows/e2e.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ jobs:
2929
global-json-file: global.json
3030
source-url: https://nuget.pkg.github.com/open-feature/index.json
3131

32+
- name: Cache NuGet packages
33+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
34+
with:
35+
path: ~/.nuget/packages
36+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
37+
restore-keys: |
38+
${{ runner.os }}-nuget-
39+
3240
- name: Initialize Tests
3341
run: |
3442
git submodule update --init --recursive

.github/workflows/release.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ jobs:
5151
global-json-file: global.json
5252
source-url: https://nuget.pkg.github.com/open-feature/index.json
5353

54+
- name: Cache NuGet packages
55+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
56+
with:
57+
path: ~/.nuget/packages
58+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
59+
restore-keys: |
60+
${{ runner.os }}-nuget-
61+
5462
- name: Install dependencies
5563
run: dotnet restore
5664

0 commit comments

Comments
 (0)