Skip to content

[repo-assist] ci: add NuGet package cache to speed up CI restores #19

@github-actions

Description

@github-actions

🤖 This pull request was created by Repo Assist, an automated AI assistant.

Summary

Adds actions/cache@v4 to the .NET CI workflow to cache the NuGet global packages folder between runs.

What changed

Inserted a Cache NuGet packages step between Setup .NET and Restore:

- name: Cache NuGet packages
  uses: actions/cache@v4
  with:
    path: ~/.nuget/packages
    key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
    restore-keys: |
      ${{ runner.os }}-nuget-

Why

The CI matrix runs three jobs (net8.0, net9.0, net10.0) and each job currently downloads all NuGet packages from scratch. With caching:

  • A cache hit (.csproj files unchanged) makes dotnet restore a near-instant no-op, saving ~30–60s per matrix leg.
  • A cache miss (e.g. after a dependency bump) populates the cache for subsequent runs.
  • The restore-keys fallback ensures partial cache reuse even when package sets change slightly.

Trade-offs

  • Minimal: actions/cache@v4 is a standard GitHub-maintained action, no new dependencies introduced.
  • Cache entries are automatically evicted after 7 days of non-use.

Test Status

✅ This is a workflow-only change (no application or test code modified). The existing test suite is unaffected.

Generated by 🌈 Repo Assist, see workflow run. Learn more.


Warning

Protected Files — Push Permission Denied

This was originally intended as a pull request, but the patch modifies protected files. A human must create the pull request manually.

Protected files

The push was rejected because GitHub Actions does not have workflows permission to push these changes, and is never allowed to make such changes, or other authorization being used does not have this permission.

Create the pull request manually
# Download the patch from the workflow run
gh run download 27484875621 -n agent -D /tmp/agent-27484875621

# Create a new branch
git checkout -b repo-assist/eng-ci-nuget-cache-2026-06-9fc4e41af7f3fe41 main

# Apply the patch (--3way handles cross-repo patches)
git am --3way /tmp/agent-27484875621/aw-repo-assist-eng-ci-nuget-cache-2026-06.patch

# Push the branch and create the pull request
git push origin repo-assist/eng-ci-nuget-cache-2026-06-9fc4e41af7f3fe41
gh pr create --title '[repo-assist] ci: add NuGet package cache to speed up CI restores' --base main --head repo-assist/eng-ci-nuget-cache-2026-06-9fc4e41af7f3fe41 --repo NichUK/DateTimeNano

Generated by 🌈 Repo Assist, see workflow run. Learn more.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions