Skip to content

Commit b4cd484

Browse files
committed
Fix cache keys for libs build test workflows
1 parent 338697d commit b4cd484

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

.github/workflows/test-php-libs-from-source.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,20 @@ jobs:
9191
if($phpVersion -ne 'master') {
9292
$pv = $phpVersion.Split('.')[0..1] -join '.'
9393
}
94+
$libsBuildRunsKey = 'default'
95+
$libsBuildRuns = @('${{ inputs.libs-build-runs }}' -split ',' | ForEach-Object { $_.Trim() } | Where-Object { $_ -ne '' }) -join ','
96+
if ($libsBuildRuns) {
97+
$libsBuildRunsKey = [System.Convert]::ToHexString(
98+
[System.Security.Cryptography.SHA256]::HashData(
99+
[System.Text.Encoding]::UTF8.GetBytes($libsBuildRuns)
100+
)
101+
).ToLowerInvariant().Substring(0, 16)
102+
}
94103
$vsVersion = (Get-Content -Raw -Path (Join-Path $(pwd).Path '\php\BuildPhp\config\vs.json') | ConvertFrom-Json).php.$pv
95104
$packagesListUrl = "https://downloads.php.net/~windows/php-sdk/deps/series/packages-$pv-$vsVersion-${{ matrix.arch }}-staging.txt"
96105
Invoke-WebRequest -OutFile packages.txt -Uri $packagesListUrl
97106
Add-Content -Value "php-version=$phpVersion" -Path $env:GITHUB_OUTPUT
98-
Add-Content -Value "cache-key=deps-$pv-${{ matrix.arch }}-${{ inputs.libs-build-runs }}" -Path $env:GITHUB_OUTPUT
107+
Add-Content -Value "cache-key=deps-$pv-${{ matrix.arch }}-$libsBuildRunsKey" -Path $env:GITHUB_OUTPUT
99108
Add-Content -Value "cache-dir=C:\deps-$pv-${{ matrix.arch }}" -Path $env:GITHUB_OUTPUT
100109
101110
- name: Cache Deps

.github/workflows/test-php-libs.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,19 @@ jobs:
6969
if('${{inputs.php-version}}' -ne 'master') {
7070
$pv = '${{inputs.php-version}}'.Split('.')[0..1] -join '.'
7171
}
72+
$libsBuildRunsKey = 'default'
73+
$libsBuildRuns = @('${{ inputs.libs-build-runs }}' -split ',' | ForEach-Object { $_.Trim() } | Where-Object { $_ -ne '' }) -join ','
74+
if ($libsBuildRuns) {
75+
$libsBuildRunsKey = [System.Convert]::ToHexString(
76+
[System.Security.Cryptography.SHA256]::HashData(
77+
[System.Text.Encoding]::UTF8.GetBytes($libsBuildRuns)
78+
)
79+
).ToLowerInvariant().Substring(0, 16)
80+
}
7281
$vsVersion = (Get-Content -Raw -Path (Join-Path $(pwd).Path '\php\BuildPhp\config\vs.json') | ConvertFrom-Json).php.$pv
7382
$packagesListUrl = "https://downloads.php.net/~windows/php-sdk/deps/series/packages-$pv-$vsVersion-${{ matrix.arch }}-staging.txt"
7483
Invoke-WebRequest -OutFile packages.txt -Uri $packagesListUrl
75-
Add-Content -Value "cache-key=deps-$pv-${{ matrix.arch }}-${{ inputs.libs-build-runs }}" -Path $env:GITHUB_OUTPUT
84+
Add-Content -Value "cache-key=deps-$pv-${{ matrix.arch }}-$libsBuildRunsKey" -Path $env:GITHUB_OUTPUT
7685
Add-Content -Value "cache-dir=C:\deps-$pv-${{ matrix.arch }}" -Path $env:GITHUB_OUTPUT
7786
7887
- name: Cache Deps

0 commit comments

Comments
 (0)