Skip to content

Commit 48abb06

Browse files
committed
fix(workflows): include runner architecture in cache key calculation
Updated GitHub Actions workflows and `Build.cs` to incorporate runner architecture (`runner.arch`) in the cache key calculation for `.atom` build artifacts. Improves cache precision and supports cross-platform and multi-architecture builds.
1 parent 2a9d4d3 commit 48abb06

File tree

4 files changed

+26
-25
lines changed

4 files changed

+26
-25
lines changed

.github/workflows/Build.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
with:
4343
path: |
4444
${{ github.workspace }}/.atom
45-
key: ${{ format('{0}-atom-build-{1}', runner.os, hashFiles('_atom/**/*.cs', '_atom/appsettings.json', '_atom/packages.lock.json')) }}
45+
key: ${{ format('{0}-{1}-atom-build-{2}', runner.os, runner.arch, hashFiles('_atom/**/*.cs', '_atom/appsettings.json', '_atom/packages.lock.json')) }}
4646

4747
- name: SetupBuildInfo
4848
id: SetupBuildInfo
@@ -72,7 +72,7 @@ jobs:
7272
with:
7373
path: |
7474
${{ github.workspace }}/.atom
75-
key: ${{ format('{0}-atom-build-{1}', runner.os, hashFiles('_atom/**/*.cs', '_atom/appsettings.json', '_atom/packages.lock.json')) }}
75+
key: ${{ format('{0}-{1}-atom-build-{2}', runner.os, runner.arch, hashFiles('_atom/**/*.cs', '_atom/appsettings.json', '_atom/packages.lock.json')) }}
7676

7777
- name: BuildAtom
7878
id: BuildAtom
@@ -92,7 +92,7 @@ jobs:
9292
with:
9393
path: |
9494
${{ github.workspace }}/.atom
95-
key: ${{ format('{0}-atom-build-{1}', runner.os, hashFiles('_atom/**/*.cs', '_atom/appsettings.json', '_atom/packages.lock.json')) }}
95+
key: ${{ format('{0}-{1}-atom-build-{2}', runner.os, runner.arch, hashFiles('_atom/**/*.cs', '_atom/appsettings.json', '_atom/packages.lock.json')) }}
9696

9797
PackProjects:
9898
runs-on: ubuntu-latest
@@ -113,7 +113,7 @@ jobs:
113113
with:
114114
path: |
115115
${{ github.workspace }}/.atom
116-
key: ${{ format('{0}-atom-build-{1}', runner.os, hashFiles('_atom/**/*.cs', '_atom/appsettings.json', '_atom/packages.lock.json')) }}
116+
key: ${{ format('{0}-{1}-atom-build-{2}', runner.os, runner.arch, hashFiles('_atom/**/*.cs', '_atom/appsettings.json', '_atom/packages.lock.json')) }}
117117

118118
- name: PackProjects
119119
id: PackProjects
@@ -183,7 +183,7 @@ jobs:
183183
with:
184184
path: |
185185
${{ github.workspace }}/.atom
186-
key: ${{ format('{0}-atom-build-{1}', runner.os, hashFiles('_atom/**/*.cs', '_atom/appsettings.json', '_atom/packages.lock.json')) }}
186+
key: ${{ format('{0}-{1}-atom-build-{2}', runner.os, runner.arch, hashFiles('_atom/**/*.cs', '_atom/appsettings.json', '_atom/packages.lock.json')) }}
187187

188188
- name: PackTool
189189
id: PackTool
@@ -229,7 +229,7 @@ jobs:
229229
with:
230230
path: |
231231
${{ github.workspace }}/.atom
232-
key: ${{ format('{0}-atom-build-{1}', runner.os, hashFiles('_atom/**/*.cs', '_atom/appsettings.json', '_atom/packages.lock.json')) }}
232+
key: ${{ format('{0}-{1}-atom-build-{2}', runner.os, runner.arch, hashFiles('_atom/**/*.cs', '_atom/appsettings.json', '_atom/packages.lock.json')) }}
233233

234234
- name: TestProjects
235235
id: TestProjects
@@ -373,7 +373,7 @@ jobs:
373373
with:
374374
path: |
375375
${{ github.workspace }}/.atom
376-
key: ${{ format('{0}-atom-build-{1}', runner.os, hashFiles('_atom/**/*.cs', '_atom/appsettings.json', '_atom/packages.lock.json')) }}
376+
key: ${{ format('{0}-{1}-atom-build-{2}', runner.os, runner.arch, hashFiles('_atom/**/*.cs', '_atom/appsettings.json', '_atom/packages.lock.json')) }}
377377

378378
- name: PushToNuget
379379
id: PushToNuget
@@ -1134,7 +1134,7 @@ jobs:
11341134
with:
11351135
path: |
11361136
${{ github.workspace }}/.atom
1137-
key: ${{ format('{0}-atom-build-{1}', runner.os, hashFiles('_atom/**/*.cs', '_atom/appsettings.json', '_atom/packages.lock.json')) }}
1137+
key: ${{ format('{0}-{1}-atom-build-{2}', runner.os, runner.arch, hashFiles('_atom/**/*.cs', '_atom/appsettings.json', '_atom/packages.lock.json')) }}
11381138

11391139
- name: PushToRelease
11401140
id: PushToRelease

.github/workflows/Dependabot Enable auto-merge.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
with:
3333
path: |
3434
${{ github.workspace }}/.atom
35-
key: ${{ format('{0}-atom-build-{1}', runner.os, hashFiles('_atom/**/*.cs', '_atom/appsettings.json', '_atom/packages.lock.json')) }}
35+
key: ${{ format('{0}-{1}-atom-build-{2}', runner.os, runner.arch, hashFiles('_atom/**/*.cs', '_atom/appsettings.json', '_atom/packages.lock.json')) }}
3636

3737
- name: ApproveDependabotPr
3838
id: ApproveDependabotPr

.github/workflows/Validate.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
with:
3838
path: |
3939
${{ github.workspace }}/.atom
40-
key: ${{ format('{0}-atom-build-{1}', runner.os, hashFiles('_atom/**/*.cs', '_atom/appsettings.json', '_atom/packages.lock.json')) }}
40+
key: ${{ format('{0}-{1}-atom-build-{2}', runner.os, runner.arch, hashFiles('_atom/**/*.cs', '_atom/appsettings.json', '_atom/packages.lock.json')) }}
4141

4242
- name: SetupBuildInfo
4343
id: SetupBuildInfo
@@ -67,7 +67,7 @@ jobs:
6767
with:
6868
path: |
6969
${{ github.workspace }}/.atom
70-
key: ${{ format('{0}-atom-build-{1}', runner.os, hashFiles('_atom/**/*.cs', '_atom/appsettings.json', '_atom/packages.lock.json')) }}
70+
key: ${{ format('{0}-{1}-atom-build-{2}', runner.os, runner.arch, hashFiles('_atom/**/*.cs', '_atom/appsettings.json', '_atom/packages.lock.json')) }}
7171

7272
- name: BuildAtom
7373
id: BuildAtom
@@ -87,7 +87,7 @@ jobs:
8787
with:
8888
path: |
8989
${{ github.workspace }}/.atom
90-
key: ${{ format('{0}-atom-build-{1}', runner.os, hashFiles('_atom/**/*.cs', '_atom/appsettings.json', '_atom/packages.lock.json')) }}
90+
key: ${{ format('{0}-{1}-atom-build-{2}', runner.os, runner.arch, hashFiles('_atom/**/*.cs', '_atom/appsettings.json', '_atom/packages.lock.json')) }}
9191

9292
PackProjects:
9393
runs-on: ubuntu-latest
@@ -108,7 +108,7 @@ jobs:
108108
with:
109109
path: |
110110
${{ github.workspace }}/.atom
111-
key: ${{ format('{0}-atom-build-{1}', runner.os, hashFiles('_atom/**/*.cs', '_atom/appsettings.json', '_atom/packages.lock.json')) }}
111+
key: ${{ format('{0}-{1}-atom-build-{2}', runner.os, runner.arch, hashFiles('_atom/**/*.cs', '_atom/appsettings.json', '_atom/packages.lock.json')) }}
112112

113113
- name: PackProjects
114114
id: PackProjects
@@ -136,7 +136,7 @@ jobs:
136136
with:
137137
path: |
138138
${{ github.workspace }}/.atom
139-
key: ${{ format('{0}-atom-build-{1}', runner.os, hashFiles('_atom/**/*.cs', '_atom/appsettings.json', '_atom/packages.lock.json')) }}
139+
key: ${{ format('{0}-{1}-atom-build-{2}', runner.os, runner.arch, hashFiles('_atom/**/*.cs', '_atom/appsettings.json', '_atom/packages.lock.json')) }}
140140

141141
- name: PackTool
142142
id: PackTool
@@ -176,7 +176,7 @@ jobs:
176176
with:
177177
path: |
178178
${{ github.workspace }}/.atom
179-
key: ${{ format('{0}-atom-build-{1}', runner.os, hashFiles('_atom/**/*.cs', '_atom/appsettings.json', '_atom/packages.lock.json')) }}
179+
key: ${{ format('{0}-{1}-atom-build-{2}', runner.os, runner.arch, hashFiles('_atom/**/*.cs', '_atom/appsettings.json', '_atom/packages.lock.json')) }}
180180

181181
- name: TestProjects
182182
id: TestProjects
@@ -247,7 +247,7 @@ jobs:
247247
with:
248248
path: |
249249
${{ github.workspace }}/.atom
250-
key: ${{ format('{0}-atom-build-{1}', runner.os, hashFiles('_atom/**/*.cs', '_atom/appsettings.json', '_atom/packages.lock.json')) }}
250+
key: ${{ format('{0}-{1}-atom-build-{2}', runner.os, runner.arch, hashFiles('_atom/**/*.cs', '_atom/appsettings.json', '_atom/packages.lock.json')) }}
251251

252252
- name: CheckPrForBreakingChanges
253253
id: CheckPrForBreakingChanges

_atom/Build.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ internal partial class Build : BuildDefinition,
4343
Values = FrameworkNames,
4444
};
4545

46+
private const string AtomBuildCacheName = "atom-build";
47+
48+
private const string AtomBuildCacheKey =
49+
"${{ format('{0}-{1}-atom-build-{2}', runner.os, runner.arch, hashFiles('_atom/**/*.cs', '_atom/appsettings.json', '_atom/packages.lock.json')) }}";
50+
51+
private static readonly WorkflowExpression[] AtomBuildCachePaths = ["${{ github.workspace }}/.atom"];
52+
4653
public override IReadOnlyList<IWorkflowOption> GlobalWorkflowOptions =>
4754
field ??=
4855
[
@@ -54,9 +61,7 @@ internal partial class Build : BuildDefinition,
5461
Value = true,
5562
},
5663
new CustomAtomCommand(),
57-
WorkflowOptions.Cache.Restore("atom-build",
58-
"${{ format('{0}-atom-build-{1}', runner.os, hashFiles('_atom/**/*.cs', '_atom/appsettings.json', '_atom/packages.lock.json')) }}",
59-
["${{ github.workspace }}/.atom"]),
64+
WorkflowOptions.Cache.Restore(AtomBuildCacheName, AtomBuildCacheKey, AtomBuildCachePaths),
6065
];
6166

6267
public override IReadOnlyList<WorkflowDefinition> Workflows =>
@@ -82,9 +87,7 @@ internal partial class Build : BuildDefinition,
8287
.BuildAtom
8388
.WithGithubRunsOnMatrix(PlatformNames)
8489
.WithOptions(new CleanAtomDirectory(),
85-
WorkflowOptions.Cache.Save("atom-build",
86-
"${{ format('{0}-atom-build-{1}', runner.os, hashFiles('_atom/**/*.cs', '_atom/appsettings.json', '_atom/packages.lock.json')) }}",
87-
["${{ github.workspace }}/.atom"])),
90+
WorkflowOptions.Cache.Save(AtomBuildCacheName, AtomBuildCacheKey, AtomBuildCachePaths)),
8891
WorkflowTargets.PackProjects.WithSuppressedArtifactPublishing,
8992
WorkflowTargets.PackTool.WithSuppressedArtifactPublishing.WithGithubRunsOnMatrix(PlatformNames),
9093
WorkflowTargets
@@ -134,9 +137,7 @@ internal partial class Build : BuildDefinition,
134137
.BuildAtom
135138
.WithGithubRunsOnMatrix(PlatformNames)
136139
.WithOptions(new CleanAtomDirectory(),
137-
WorkflowOptions.Cache.Save("atom-build",
138-
"${{ format('{0}-atom-build-{1}', runner.os, hashFiles('_atom/**/*.cs', '_atom/appsettings.json', '_atom/packages.lock.json')) }}",
139-
["${{ github.workspace }}/.atom"])),
140+
WorkflowOptions.Cache.Save(AtomBuildCacheName, AtomBuildCacheKey, AtomBuildCachePaths)),
140141
WorkflowTargets.PackProjects,
141142
WorkflowTargets.PackTool.WithGithubRunsOnMatrix(PlatformNames),
142143
WorkflowTargets

0 commit comments

Comments
 (0)