Skip to content

Commit df357d6

Browse files
committed
Refactor runtime caching
1 parent 42bf7ee commit df357d6

File tree

8 files changed

+61
-223
lines changed

8 files changed

+61
-223
lines changed

.github/workflows/build-runtime.yml

Lines changed: 0 additions & 42 deletions
This file was deleted.

.github/workflows/build.yml

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

2323
jobs:
24-
cache-runtimes:
25-
strategy:
26-
matrix:
27-
runtime:
28-
- linux-x64
29-
- browser-wasm
30-
uses: ./.github/workflows/cache-runtime.yml
31-
with:
32-
runtime: ${{ matrix.runtime }}
33-
permissions:
34-
contents: read
35-
actions: write
36-
3724
lookup-runtime-caches:
3825
runs-on: ubuntu-latest
3926

4027
outputs:
28+
linux-x64: ${{ steps.lookup-linux-x64.outputs.cache-hit }}
4129
win-x64: ${{ steps.lookup-win-x64.outputs.cache-hit }}
4230
osx-arm64: ${{ steps.lookup-osx-arm64.outputs.cache-hit }}
31+
browser-wasm: ${{ steps.lookup-browser-wasm.outputs.cache-hit }}
4332

4433
steps:
4534
- name: Checkout
4635
id: checkout
4736
uses: actions/checkout@v4
4837

38+
- name: Lookup linux-x64
39+
id: lookup-linux-x64
40+
uses: ./.github/actions/lookup-runtime-cache
41+
with:
42+
runtime: linux-x64
43+
4944
- name: Lookup win-x64
5045
id: lookup-win-x64
5146
uses: ./.github/actions/lookup-runtime-cache
@@ -58,6 +53,20 @@ jobs:
5853
with:
5954
runtime: osx-arm64
6055

56+
- name: Lookup browser-wasm
57+
id: lookup-browser-wasm
58+
uses: ./.github/actions/lookup-runtime-cache
59+
with:
60+
runtime: browser-wasm
61+
62+
runtime-linux-x64:
63+
needs: lookup-runtime-caches
64+
if: ${{ !needs.lookup-runtime-caches.outputs.linux-x64 }}
65+
uses: ./.github/workflows/runtime-linux-x64.yml
66+
permissions:
67+
contents: read
68+
actions: write
69+
6170
runtime-win-x64:
6271
needs: lookup-runtime-caches
6372
if: ${{ !needs.lookup-runtime-caches.outputs.win-x64 }}
@@ -74,11 +83,20 @@ jobs:
7483
contents: read
7584
actions: write
7685

86+
runtime-browser-wasm:
87+
needs: lookup-runtime-caches
88+
if: ${{ !needs.lookup-runtime-caches.outputs.browser-wasm }}
89+
uses: ./.github/workflows/runtime-browser-wasm.yml
90+
permissions:
91+
contents: read
92+
actions: write
93+
7794
build-dotnet:
7895
needs:
79-
- cache-runtimes
96+
- runtime-linux-x64
8097
- runtime-win-x64
8198
- runtime-osx-arm64
99+
- runtime-browser-wasm
82100

83101
if: always()
84102

@@ -90,13 +108,10 @@ jobs:
90108
with:
91109
fetch-depth: 0
92110

93-
- name: Restore linux-x64 artifact
94-
uses: actions/cache/restore@v4
111+
- name: Restore linux-x64
112+
uses: ./.github/actions/restore-runtime-cache
95113
with:
96-
path: |
97-
Xmss/runtimes/**
98-
key: runtime-linux-x64-${{ hashFiles('.gitmodules', 'libc/libc.c', '.github/workflows/runtime-linux-x64.yml') }}
99-
fail-on-cache-miss: true
114+
runtime: linux-x64
100115

101116
- name: Restore win-x64
102117
uses: ./.github/actions/restore-runtime-cache
@@ -108,13 +123,10 @@ jobs:
108123
with:
109124
runtime: osx-arm64
110125

111-
- name: Restore browser-wasm artifact
112-
uses: actions/cache/restore@v4
126+
- name: Restore browser-wasm
127+
uses: ./.github/actions/restore-runtime-cache
113128
with:
114-
path: |
115-
Xmss/runtimes/**
116-
key: runtime-browser-wasm-${{ hashFiles('.gitmodules', 'libc/libc.c', '.github/workflows/runtime-browser-wasm.yml') }}
117-
fail-on-cache-miss: true
129+
runtime: browser-wasm
118130

119131
- name: Setup .NET
120132
uses: actions/setup-dotnet@v4

.github/workflows/cache-runtime.yml

Lines changed: 0 additions & 72 deletions
This file was deleted.

.github/workflows/codeql.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,10 @@ jobs:
7575
# echo "Run, Build Application using script"
7676
# ./location_of_script_within_repo/buildscript.sh
7777

78-
- name: Restore browser-wasm artifact
79-
uses: actions/cache/restore@v4
78+
- name: Restore browser-wasm
79+
uses: ./.github/actions/restore-runtime-cache
8080
with:
81-
path: |
82-
Xmss/runtimes/**
83-
key: runtime-browser-wasm-${{ hashFiles('.gitmodules', 'libc/libc.c', '.github/workflows/runtime-browser-wasm.yml') }}
84-
fail-on-cache-miss: true
81+
runtime: browser-wasm
8582

8683
- name: Setup .NET
8784
uses: actions/setup-dotnet@v4

.github/workflows/runtime-browser-wasm.yml

Lines changed: 5 additions & 33 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-browser-wasm:
24+
build:
2725
runs-on: ubuntu-latest
2826

2927
steps:
@@ -32,12 +30,6 @@ jobs:
3230
with:
3331
submodules: recursive
3432

35-
- name: Calculate cache key
36-
id: cache-key
37-
run: |
38-
echo "value=runtime-${{ env.RUNTIME }}-${{ hashFiles('.gitmodules', 'libc/libc.c', '.github/workflows/runtime-browser-wasm.yml') }}" \
39-
>> "$GITHUB_OUTPUT"
40-
4133
- name: Prepare packages
4234
run: |
4335
sudo apt-get update
@@ -59,28 +51,8 @@ jobs:
5951
mkdir -p "Xmss/runtimes/${{ env.RUNTIME }}/nativeassets"
6052
cp build/src/libxmss.a "Xmss/runtimes/${{ env.RUNTIME }}/nativeassets/xmss.a"
6153
62-
- name: Check existing cache
63-
id: cache-check
64-
uses: actions/cache/restore@v4
65-
with:
66-
path: |
67-
Xmss/runtimes/**
68-
key: ${{ steps.cache-key.outputs.value }}
69-
enableCrossOsArchive: true
70-
lookup-only: true
71-
72-
- name: Delete existing cache
73-
if: ${{ steps.cache-check.outputs.cache-hit }}
74-
run: |
75-
gh extension install actions/gh-actions-cache
76-
gh actions-cache delete "${{ steps.cache-key.outputs.value }}" --confirm
77-
env:
78-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79-
80-
- name: Save cache
81-
uses: actions/cache/save@v4
54+
- name: Save runtime cache
55+
id: save-runtime-cache
56+
uses: ./.github/actions/save-runtime-cache
8257
with:
83-
path: |
84-
Xmss/runtimes/**
85-
key: ${{ steps.cache-key.outputs.value }}
86-
enableCrossOsArchive: true
58+
runtime: ${{ env.RUNTIME }}

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

Lines changed: 5 additions & 33 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-linux-x64:
24+
build:
2725
runs-on: ubuntu-latest
2826

2927
steps:
@@ -32,12 +30,6 @@ jobs:
3230
with:
3331
submodules: recursive
3432

35-
- name: Calculate cache key
36-
id: cache-key
37-
run: |
38-
echo "value=runtime-${{ env.RUNTIME }}-${{ hashFiles('.gitmodules', 'libc/libc.c', '.github/workflows/runtime-linux-x64.yml') }}" \
39-
>> "$GITHUB_OUTPUT"
40-
4133
- name: Configure
4234
run: >
4335
cmake
@@ -62,28 +54,8 @@ jobs:
6254
mkdir -p "Xmss/runtimes/${{ env.RUNTIME }}/native"
6355
cp build/src/libxmss.so "Xmss/runtimes/${{ env.RUNTIME }}/native/xmss.so"
6456
65-
- name: Check existing cache
66-
id: cache-check
67-
uses: actions/cache/restore@v4
68-
with:
69-
path: |
70-
Xmss/runtimes/**
71-
key: ${{ steps.cache-key.outputs.value }}
72-
enableCrossOsArchive: true
73-
lookup-only: true
74-
75-
- name: Delete existing cache
76-
if: ${{ steps.cache-check.outputs.cache-hit }}
77-
run: |
78-
gh extension install actions/gh-actions-cache
79-
gh actions-cache delete "${{ steps.cache-key.outputs.value }}" --confirm
80-
env:
81-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
82-
83-
- name: Save cache
84-
uses: actions/cache/save@v4
57+
- name: Save runtime cache
58+
id: save-runtime-cache
59+
uses: ./.github/actions/save-runtime-cache
8560
with:
86-
path: |
87-
Xmss/runtimes/**
88-
key: ${{ steps.cache-key.outputs.value }}
89-
enableCrossOsArchive: true
61+
runtime: ${{ env.RUNTIME }}

Examples/WebAssembly/Properties/launchSettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "http://json.schemastore.org/launchsettings.json",
2+
"$schema": "https://json.schemastore.org/launchsettings.json",
33
"iisSettings": {
44
"windowsAuthentication": false,
55
"anonymousAuthentication": true,

0 commit comments

Comments
 (0)