Skip to content

Commit c8e9da4

Browse files
committed
COMP: Refresh stale Plus build cache nightly
The Plus build directory cache (plus-latest-x64/Win32) is stored under a fixed key that actions/cache never overwrites once created, so it would otherwise never pick up changes after the first nightly run. Add a clear-plus-cache step to build-plus.yml, gated by a new input, and have nightly.yml request it automatically on schedule (or via a manual clear-plus-cache dispatch input) so the cache can't go stale indefinitely.
1 parent 7cc854d commit c8e9da4

2 files changed

Lines changed: 22 additions & 23 deletions

File tree

‎.github/workflows/build-plus.yml‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ on:
2626
plus-cache-key:
2727
required: false
2828
type: string
29+
clear-plus-cache:
30+
required: false
31+
type: boolean
32+
default: false
2933

3034
# Plus build options
3135
plus-config:
@@ -68,6 +72,8 @@ on:
6872
jobs:
6973
build:
7074
runs-on: ${{ inputs.os }}
75+
permissions:
76+
actions: write
7177

7278
steps:
7379
- name: Restore VTK Cache
@@ -82,6 +88,15 @@ jobs:
8288
path: itk-install
8389
key: ${{ inputs.itk-cache-key }}
8490

91+
# actions/cache never overwrites an existing key, so a fixed plus-cache-key
92+
# (e.g. plus-latest-x64) would otherwise never refresh once created.
93+
- name: Clear Plus Cache
94+
if: ${{ inputs.clear-plus-cache && inputs.plus-cache-key != '' }}
95+
shell: bash
96+
env:
97+
GH_TOKEN: ${{ github.token }}
98+
run: gh cache delete "${{ inputs.plus-cache-key }}" --repo ${{ github.repository }} || true
99+
85100
- name: Plus Cache
86101
if: ${{ inputs.plus-cache-key != '' }}
87102
id: cache-plus

‎.github/workflows/nightly.yml‎

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,6 @@ on:
1212
- cron: "43 5 * * *" # Run nightly at 5:43 UTC. Picked a time when the load may be lower. https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#schedule
1313

1414
jobs:
15-
########
16-
# CLEAR STALE PLUS BUILD CACHE
17-
# The Plus build cache is stored under a fixed key (not tied to the commit
18-
# being built), so actions/cache never overwrites it once created. Clear it
19-
# every night (and on-demand via the clear-plus-cache input) so nightly
20-
# builds don't keep reusing an arbitrarily stale build directory.
21-
clear_plus_cache:
22-
if: ${{ github.event_name == 'schedule' || inputs.clear-plus-cache == true }}
23-
runs-on: ubuntu-latest
24-
permissions:
25-
actions: write
26-
steps:
27-
- name: Delete cached Plus build directories
28-
env:
29-
GH_TOKEN: ${{ github.token }}
30-
run: |
31-
gh cache delete plus-latest-x64 --repo ${{ github.repository }} || true
32-
gh cache delete plus-latest-Win32 --repo ${{ github.repository }} || true
33-
3415
########
3516
# BUILD AND CACHE VTK
3617
update_vtk_x64:
@@ -92,8 +73,7 @@ jobs:
9273
build-type: ${{ matrix.build_type }}
9374

9475
build_plus_x64:
95-
needs: [update_vtk_x64, update_itk_x64, clear_plus_cache]
96-
if: always() && !failure() && !cancelled()
76+
needs: [update_vtk_x64, update_itk_x64]
9777
uses: ./.github/workflows/build-plus.yml
9878
strategy:
9979
fail-fast: false
@@ -112,6 +92,10 @@ jobs:
11292
vtk-cache-key: ${{ needs.update_vtk_x64.outputs.cache-key }}
11393
itk-cache-key: ${{ needs.update_itk_x64.outputs.cache-key }}
11494
plus-cache-key: plus-latest-x64
95+
# actions/cache never overwrites this fixed key once created, so clear it
96+
# ourselves every night (and on-demand via the clear-plus-cache input) to
97+
# avoid an arbitrarily stale build directory sticking around forever.
98+
clear-plus-cache: ${{ github.event_name == 'schedule' || inputs.clear-plus-cache == true }}
11599
archive-name: PlusApp-Win64
116100
plus-config: >-
117101
-DVTK_DIR=${{ needs.update_vtk_x64.outputs.install-path }}
@@ -310,8 +294,7 @@ jobs:
310294
-DPLUS_USE_MICRONTRACKER:BOOL=ON
311295
312296
build_plus_Win32:
313-
needs: [update_vtk_Win32, update_itk_Win32, clear_plus_cache]
314-
if: always() && !failure() && !cancelled()
297+
needs: [update_vtk_Win32, update_itk_Win32]
315298
uses: ./.github/workflows/build-plus.yml
316299
strategy:
317300
fail-fast: false
@@ -330,6 +313,7 @@ jobs:
330313
vtk-cache-key: ${{ needs.update_vtk_Win32.outputs.cache-key }}
331314
itk-cache-key: ${{ needs.update_itk_Win32.outputs.cache-key }}
332315
plus-cache-key: plus-latest-Win32
316+
clear-plus-cache: ${{ github.event_name == 'schedule' || inputs.clear-plus-cache == true }}
333317
archive-name: PlusApp-Win32
334318
plus-config: >-
335319
-DVTK_DIR=${{ needs.update_vtk_Win32.outputs.install-path }}

0 commit comments

Comments
 (0)