Skip to content

Commit 87ffd8c

Browse files
authored
ci: fix cleaning caches (#20167)
1 parent b3ee85d commit 87ffd8c

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed
Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,40 @@
11
name: Clear cache weekly
22

33
on:
4+
pull_request:
5+
paths:
6+
- ".github/workflows/call-clear-cache.yml"
47
workflow_dispatch:
58
inputs:
69
pattern:
710
description: "pattern for cleaning cache"
811
default: "pip-|conda"
912
required: false
1013
type: string
14+
age-days:
15+
description: "setting the age of caches in days to be dropped"
16+
required: true
17+
type: number
18+
default: 5
19+
schedule:
20+
# on Sundays
21+
- cron: "0 0 * * 0"
1122

1223
jobs:
1324
cron-clear:
14-
if: github.event_name == 'schedule'
15-
uses: Lightning-AI/utilities/.github/workflows/clear-cache.yml@v0.11.6
25+
if: github.event_name == 'schedule' || github.event_name == 'pull_request'
26+
uses: Lightning-AI/utilities/.github/workflows/cleanup-caches.yml@v0.11.6
1627
with:
28+
scripts-ref: v0.11.6
29+
dry-run: ${{ github.event_name == 'pull_request' }}
1730
pattern: "latest|docs"
31+
age-days: 7
1832

1933
direct-clear:
20-
if: github.event_name == 'workflow_dispatch'
21-
uses: Lightning-AI/utilities/.github/workflows/clear-cache.yml@v0.11.6
34+
if: github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request'
35+
uses: Lightning-AI/utilities/.github/workflows/cleanup-caches.yml@v0.11.6
2236
with:
23-
pattern: ${{ inputs.pattern }}
37+
scripts-ref: v0.11.6
38+
dry-run: ${{ github.event_name == 'pull_request' }}
39+
pattern: ${{ inputs.pattern || 'pypi_wheels' }} # setting str in case of PR / debugging
40+
age-days: ${{ inputs.age-days || 0 }} # setting 0 in case of PR / debugging

.github/workflows/cleanup-caches.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#force-deleting-cache-entries
2-
name: cleanup caches by a branch
1+
name: cleanup caches on a branch
32
on:
43
pull_request:
54
types: [closed]
65

76
jobs:
87
pr-cleanup:
8+
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#force-deleting-cache-entries
99
runs-on: ubuntu-latest
1010
steps:
1111
- name: Check out code

0 commit comments

Comments
 (0)