Commit c4f2da4
[copilot] Add
## Summary
This PR adds caching for the `./externals` directory in the
`copilot-setup-steps.yml` workflow to improve build performance by
avoiding redundant Maven artifact downloads.
## Problem
The `dotnet cake` build process downloads hundreds of Maven artifacts
(AndroidX, Google Play Services, Firebase, etc.) to the `./externals`
directory during the binderator step. Without caching, these artifacts
are re-downloaded on every workflow run, significantly increasing
build time and network usage.
## Solution
Added explicit cache management using GitHub Actions cache:
- **Cache Key**: Based on `config.json` content hash (`externals-${{ hashFiles('config.json') }}`)
- **Cache Path**: `./externals` directory
- **Strategy**: Restore before `dotnet cake`, save after (only on cache miss)
## Implementation Details
```yaml
# Restore cache before build
- name: Restore externals cache
uses: actions/cache/restore@v4
with:
path: ./externals
key: externals-${{ hashFiles('config.json') }}
# Save cache after successful artifact download (only if cache miss)
- name: Save externals cache
uses: actions/cache/save@v4
if: steps.cache-externals-restore.outputs.cache-hit != 'true'
with:
path: ./externals
key: externals-${{ hashFiles('config.json') }}
```
## Benefits
- **Faster builds**: Eliminates re-downloading of Maven artifacts when `config.json` hasn't changed
- **Reduced network usage**: Avoids unnecessary downloads of hundreds of Android library artifacts
- **Improved developer experience**: Faster feedback for workflow runs
- **Cost efficiency**: Reduces GitHub Actions compute time
## Cache Invalidation
The cache automatically invalidates when:
- `config.json` content changes (new/updated Maven artifacts)
- Manual cache clearing through GitHub UI
- 7-day GitHub Actions cache expiration
This ensures builds always use the correct artifacts while maximizing cache efficiency.
Co-authored-by: mattleibow <1096616+mattleibow@users.noreply.github.com>externals directory caching (#1225)1 parent a382db9 commit c4f2da4
1 file changed
Lines changed: 21 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
30 | 40 | | |
31 | 41 | | |
32 | 42 | | |
33 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
34 | 55 | | |
35 | 56 | | |
36 | 57 | | |
| |||
0 commit comments