Skip to content

Commit 42bf7ee

Browse files
authored
Merge pull request #121 from dorssel/cache_win_x64
Refactor runtime cache for win-x64
2 parents 54fad45 + 34a8559 commit 42bf7ee

File tree

4 files changed

+27
-42
lines changed

4 files changed

+27
-42
lines changed

.github/actions/save-runtime-cache/action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ runs:
3434
const runtime_caches = await github.rest.actions.getActionsCacheList({
3535
owner: context.repo.owner,
3636
repo: context.repo.repo,
37+
ref: context.ref,
3738
key: `${RUNTIME_CACHE_KEY}`,
3839
})
3940
for (const runtime_cache of runtime_caches.data.actions_caches) {

.github/workflows/build.yml

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ jobs:
2626
matrix:
2727
runtime:
2828
- linux-x64
29-
- win-x64
3029
- browser-wasm
3130
uses: ./.github/workflows/cache-runtime.yml
3231
with:
@@ -39,19 +38,34 @@ jobs:
3938
runs-on: ubuntu-latest
4039

4140
outputs:
41+
win-x64: ${{ steps.lookup-win-x64.outputs.cache-hit }}
4242
osx-arm64: ${{ steps.lookup-osx-arm64.outputs.cache-hit }}
4343

4444
steps:
4545
- name: Checkout
4646
id: checkout
4747
uses: actions/checkout@v4
4848

49+
- name: Lookup win-x64
50+
id: lookup-win-x64
51+
uses: ./.github/actions/lookup-runtime-cache
52+
with:
53+
runtime: win-x64
54+
4955
- name: Lookup osx-arm64
5056
id: lookup-osx-arm64
5157
uses: ./.github/actions/lookup-runtime-cache
5258
with:
5359
runtime: osx-arm64
5460

61+
runtime-win-x64:
62+
needs: lookup-runtime-caches
63+
if: ${{ !needs.lookup-runtime-caches.outputs.win-x64 }}
64+
uses: ./.github/workflows/runtime-win-x64.yml
65+
permissions:
66+
contents: read
67+
actions: write
68+
5569
runtime-osx-arm64:
5670
needs: lookup-runtime-caches
5771
if: ${{ !needs.lookup-runtime-caches.outputs.osx-arm64 }}
@@ -63,6 +77,7 @@ jobs:
6377
build-dotnet:
6478
needs:
6579
- cache-runtimes
80+
- runtime-win-x64
6681
- runtime-osx-arm64
6782

6883
if: always()
@@ -83,13 +98,10 @@ jobs:
8398
key: runtime-linux-x64-${{ hashFiles('.gitmodules', 'libc/libc.c', '.github/workflows/runtime-linux-x64.yml') }}
8499
fail-on-cache-miss: true
85100

86-
- name: Restore win-x64 artifact
87-
uses: actions/cache/restore@v4
101+
- name: Restore win-x64
102+
uses: ./.github/actions/restore-runtime-cache
88103
with:
89-
path: |
90-
Xmss/runtimes/**
91-
key: runtime-win-x64-${{ hashFiles('.gitmodules', 'libc/libc.c', '.github/workflows/runtime-win-x64.yml') }}
92-
fail-on-cache-miss: true
104+
runtime: win-x64
93105

94106
- name: Restore osx-arm64
95107
uses: ./.github/actions/restore-runtime-cache

.github/workflows/runtime-osx-arm64.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
#
33
# SPDX-License-Identifier: MIT
44

5-
# This file requires LF line endings, as it is used in GitHub action hashes.
6-
75
---
86
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
97

@@ -23,7 +21,7 @@ permissions:
2321
actions: write
2422

2523
jobs:
26-
build-osx-arm64:
24+
build:
2725
runs-on: macos-latest
2826

2927
steps:
@@ -58,4 +56,4 @@ jobs:
5856
id: save-runtime-cache
5957
uses: ./.github/actions/save-runtime-cache
6058
with:
61-
runtime: osx-arm64
59+
runtime: ${{ env.RUNTIME }}

.github/workflows/runtime-win-x64.yml

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ permissions:
2121
actions: write
2222

2323
jobs:
24-
build-win-x64:
24+
build:
2525
runs-on: windows-latest
2626

2727
steps:
@@ -30,12 +30,6 @@ jobs:
3030
with:
3131
submodules: recursive
3232

33-
- name: Calculate cache key
34-
id: cache-key
35-
run: |
36-
echo "value=runtime-${{ env.RUNTIME }}-${{ hashFiles('.gitmodules', 'libc/libc.c', '.github/workflows/runtime-win-x64.yml') }}" `
37-
>> "$env:GITHUB_OUTPUT"
38-
3933
- name: Configure
4034
run: >
4135
cmake
@@ -61,28 +55,8 @@ jobs:
6155
mkdir "Xmss\runtimes\${{ env.RUNTIME }}\native"
6256
copy build\src\Release\xmss.dll "Xmss\runtimes\${{ env.RUNTIME }}\native\"
6357
64-
- name: Check existing cache
65-
id: cache-check
66-
uses: actions/cache/restore@v4
67-
with:
68-
path: |
69-
Xmss/runtimes/**
70-
key: ${{ steps.cache-key.outputs.value }}
71-
enableCrossOsArchive: true
72-
lookup-only: true
73-
74-
- name: Delete existing cache
75-
if: ${{ steps.cache-check.outputs.cache-hit }}
76-
run: |
77-
gh extension install actions/gh-actions-cache
78-
gh actions-cache delete "${{ steps.cache-key.outputs.value }}" --confirm
79-
env:
80-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
81-
82-
- name: Save cache
83-
uses: actions/cache/save@v4
58+
- name: Save runtime cache
59+
id: save-runtime-cache
60+
uses: ./.github/actions/save-runtime-cache
8461
with:
85-
path: |
86-
Xmss/runtimes/**
87-
key: ${{ steps.cache-key.outputs.value }}
88-
enableCrossOsArchive: true
62+
runtime: ${{ env.RUNTIME }}

0 commit comments

Comments
 (0)