@@ -38,12 +38,31 @@ jobs:
38
38
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
39
39
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
40
40
41
+ - name : Set SHA env vars
42
+ shell : bash
43
+ run : |
44
+ vcpkgSha="${{ hashFiles('vcpkg.json') }}"
45
+ nas2dSha="$(git submodule status -- nas2d-core/ | awk '{print $1}')"
46
+ ophdSha="${{ github.sha }}"
47
+
48
+ config="${{ runner.os }}-${{ matrix.platform }}"
49
+ cacheKeyPrefixOphd="buildCache-${config}-"
50
+
51
+ cacheKeyVcpkg="vcpkgCache-${config}-${vcpkgSha}"
52
+ cacheKeyNas2d="nas2dCache-${config}-${nas2dSha}"
53
+ cacheKeyOphd="${cacheKeyPrefixOphd}-${ophdSha}"
54
+
55
+ echo "cacheKeyVcpkg=${cacheKeyVcpkg}" >> $GITHUB_ENV
56
+ echo "cacheKeyNas2d=${cacheKeyNas2d}" >> $GITHUB_ENV
57
+ echo "cacheKeyOphd=${cacheKeyOphd}" >> $GITHUB_ENV
58
+ echo "cacheKeyPrefixOphd=${cacheKeyPrefixOphd}" >> $GITHUB_ENV
59
+
41
60
- name : Restore vcpkg dependency cache
42
61
uses : actions/cache/restore@v4
43
62
id : cacheRestoreVcpkg
44
63
with :
45
64
path : vcpkg_installed
46
- key : vcpkgCache- ${{ runner.os }}-${{ matrix.platform }}-${{ hashFiles('vcpkg.json') }}
65
+ key : ${{ env.cacheKeyVcpkg }}
47
66
48
67
- name : Pre-install vcpkg dependencies - OPHD
49
68
env :
72
91
- name : Set NAS2D modification time
73
92
shell : bash
74
93
run : |
75
- nas2dSha=$(git submodule status -- nas2d-core/ | awk '{print $1}')
76
- echo "nas2dSha=${nas2dSha}" >> $GITHUB_ENV
77
-
78
94
# Set last modification times to that of last build's committer time
79
95
# The committer time should pre-date any cached output modification time
80
96
commitTime=$(git -C nas2d-core/ log -1 --format="%cI")
@@ -87,11 +103,9 @@ jobs:
87
103
if : steps.cacheRestoreVcpkg.outputs.cache-hit == 'true'
88
104
with :
89
105
path : nas2d-core/.build/
90
- key : nas2dCache- ${{ runner.os }}-${{ matrix.platform }}-${{ env.nas2dSha }}
106
+ key : ${{ env.cacheKeyNas2d }}
91
107
92
108
- name : Build NAS2D
93
- # Add additional options to the MSBuild command line here (like platform or verbosity level).
94
- # See https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference
95
109
run : |
96
110
msbuild . /maxCpuCount /warnAsError /property:RunCodeAnalysis=true /target:NAS2D
97
111
@@ -108,8 +122,8 @@ jobs:
108
122
if : github.ref != format('refs/heads/{0}', github.event.repository.default_branch) && steps.cacheRestoreNas2d.outputs.cache-hit == 'true'
109
123
with :
110
124
path : .build
111
- key : buildCache- ${{ runner.os }}-${{ matrix.platform }}-${{ github.sha }}
112
- restore-keys : buildCache- ${{ runner.os }}-${{ matrix.platform }}-
125
+ key : ${{ env.cacheKeyOphd }}
126
+ restore-keys : ${{ env.cacheKeyPrefixOphd }}
113
127
114
128
- name : Set modification times
115
129
if : ${{ hashFiles('.build/lastBuildSha.txt') != '' }}
@@ -141,8 +155,6 @@ jobs:
141
155
echo "${{ github.sha }}" > .build/lastBuildSha.txt
142
156
143
157
- name : Build OPHD
144
- # Add additional options to the MSBuild command line here (like platform or verbosity level).
145
- # See https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference
146
158
run : |
147
159
msbuild . /maxCpuCount /warnAsError /property:RunCodeAnalysis=true
148
160
@@ -151,7 +163,7 @@ jobs:
151
163
if : steps.cacheRestoreOphd.outcome == 'skipped' || steps.cacheRestoreOphd.outputs.cache-hit != 'true'
152
164
with :
153
165
path : .build
154
- key : buildCache- ${{ runner.os }}-${{ matrix.platform }}-${{ github.sha }}
166
+ key : ${{ env.cacheKeyOphd }}
155
167
156
168
- name : Run libOPHD unit tests
157
169
run : .build/${{env.Configuration}}_${{env.Platform}}_testLibOPHD/testLibOPHD.exe
0 commit comments