Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor runtime cache for win-x64 #121

Merged
merged 1 commit into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/actions/save-runtime-cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ runs:
const runtime_caches = await github.rest.actions.getActionsCacheList({
owner: context.repo.owner,
repo: context.repo.repo,
ref: context.ref,
key: `${RUNTIME_CACHE_KEY}`,
})
for (const runtime_cache of runtime_caches.data.actions_caches) {
Expand Down
26 changes: 19 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ jobs:
matrix:
runtime:
- linux-x64
- win-x64
- browser-wasm
uses: ./.github/workflows/cache-runtime.yml
with:
Expand All @@ -39,19 +38,34 @@ jobs:
runs-on: ubuntu-latest

outputs:
win-x64: ${{ steps.lookup-win-x64.outputs.cache-hit }}
osx-arm64: ${{ steps.lookup-osx-arm64.outputs.cache-hit }}

steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4

- name: Lookup win-x64
id: lookup-win-x64
uses: ./.github/actions/lookup-runtime-cache
with:
runtime: win-x64

- name: Lookup osx-arm64
id: lookup-osx-arm64
uses: ./.github/actions/lookup-runtime-cache
with:
runtime: osx-arm64

runtime-win-x64:
needs: lookup-runtime-caches
if: ${{ !needs.lookup-runtime-caches.outputs.win-x64 }}
uses: ./.github/workflows/runtime-win-x64.yml
permissions:
contents: read
actions: write

runtime-osx-arm64:
needs: lookup-runtime-caches
if: ${{ !needs.lookup-runtime-caches.outputs.osx-arm64 }}
Expand All @@ -63,6 +77,7 @@ jobs:
build-dotnet:
needs:
- cache-runtimes
- runtime-win-x64
- runtime-osx-arm64

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

- name: Restore win-x64 artifact
uses: actions/cache/restore@v4
- name: Restore win-x64
uses: ./.github/actions/restore-runtime-cache
with:
path: |
Xmss/runtimes/**
key: runtime-win-x64-${{ hashFiles('.gitmodules', 'libc/libc.c', '.github/workflows/runtime-win-x64.yml') }}
fail-on-cache-miss: true
runtime: win-x64

- name: Restore osx-arm64
uses: ./.github/actions/restore-runtime-cache
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/runtime-osx-arm64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
#
# SPDX-License-Identifier: MIT

# This file requires LF line endings, as it is used in GitHub action hashes.

---
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json

Expand All @@ -23,7 +21,7 @@ permissions:
actions: write

jobs:
build-osx-arm64:
build:
runs-on: macos-latest

steps:
Expand Down Expand Up @@ -58,4 +56,4 @@ jobs:
id: save-runtime-cache
uses: ./.github/actions/save-runtime-cache
with:
runtime: osx-arm64
runtime: ${{ env.RUNTIME }}
36 changes: 5 additions & 31 deletions .github/workflows/runtime-win-x64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ permissions:
actions: write

jobs:
build-win-x64:
build:
runs-on: windows-latest

steps:
Expand All @@ -30,12 +30,6 @@ jobs:
with:
submodules: recursive

- name: Calculate cache key
id: cache-key
run: |
echo "value=runtime-${{ env.RUNTIME }}-${{ hashFiles('.gitmodules', 'libc/libc.c', '.github/workflows/runtime-win-x64.yml') }}" `
>> "$env:GITHUB_OUTPUT"

- name: Configure
run: >
cmake
Expand All @@ -61,28 +55,8 @@ jobs:
mkdir "Xmss\runtimes\${{ env.RUNTIME }}\native"
copy build\src\Release\xmss.dll "Xmss\runtimes\${{ env.RUNTIME }}\native\"

- name: Check existing cache
id: cache-check
uses: actions/cache/restore@v4
with:
path: |
Xmss/runtimes/**
key: ${{ steps.cache-key.outputs.value }}
enableCrossOsArchive: true
lookup-only: true

- name: Delete existing cache
if: ${{ steps.cache-check.outputs.cache-hit }}
run: |
gh extension install actions/gh-actions-cache
gh actions-cache delete "${{ steps.cache-key.outputs.value }}" --confirm
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Save cache
uses: actions/cache/save@v4
- name: Save runtime cache
id: save-runtime-cache
uses: ./.github/actions/save-runtime-cache
with:
path: |
Xmss/runtimes/**
key: ${{ steps.cache-key.outputs.value }}
enableCrossOsArchive: true
runtime: ${{ env.RUNTIME }}
Loading