From 87ffd8ce7c70f69e1744f882cc06a38ebf7e8ddf Mon Sep 17 00:00:00 2001 From: Jirka Borovec <6035284+Borda@users.noreply.github.com> Date: Tue, 6 Aug 2024 12:59:55 +0200 Subject: [PATCH] ci: fix cleaning caches (#20167) --- .github/workflows/call-clear-cache.yml | 27 +++++++++++++++++++++----- .github/workflows/cleanup-caches.yml | 4 ++-- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/.github/workflows/call-clear-cache.yml b/.github/workflows/call-clear-cache.yml index 5aecc5d40e..09b5dc77f9 100644 --- a/.github/workflows/call-clear-cache.yml +++ b/.github/workflows/call-clear-cache.yml @@ -1,6 +1,9 @@ name: Clear cache weekly on: + pull_request: + paths: + - ".github/workflows/call-clear-cache.yml" workflow_dispatch: inputs: pattern: @@ -8,16 +11,30 @@ on: default: "pip-|conda" required: false type: string + age-days: + description: "setting the age of caches in days to be dropped" + required: true + type: number + default: 5 + schedule: + # on Sundays + - cron: "0 0 * * 0" jobs: cron-clear: - if: github.event_name == 'schedule' - uses: Lightning-AI/utilities/.github/workflows/clear-cache.yml@v0.11.6 + if: github.event_name == 'schedule' || github.event_name == 'pull_request' + uses: Lightning-AI/utilities/.github/workflows/cleanup-caches.yml@v0.11.6 with: + scripts-ref: v0.11.6 + dry-run: ${{ github.event_name == 'pull_request' }} pattern: "latest|docs" + age-days: 7 direct-clear: - if: github.event_name == 'workflow_dispatch' - uses: Lightning-AI/utilities/.github/workflows/clear-cache.yml@v0.11.6 + if: github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request' + uses: Lightning-AI/utilities/.github/workflows/cleanup-caches.yml@v0.11.6 with: - pattern: ${{ inputs.pattern }} + scripts-ref: v0.11.6 + dry-run: ${{ github.event_name == 'pull_request' }} + pattern: ${{ inputs.pattern || 'pypi_wheels' }} # setting str in case of PR / debugging + age-days: ${{ inputs.age-days || 0 }} # setting 0 in case of PR / debugging diff --git a/.github/workflows/cleanup-caches.yml b/.github/workflows/cleanup-caches.yml index 0c60c5aa80..93bce48fcc 100644 --- a/.github/workflows/cleanup-caches.yml +++ b/.github/workflows/cleanup-caches.yml @@ -1,11 +1,11 @@ -# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#force-deleting-cache-entries -name: cleanup caches by a branch +name: cleanup caches on a branch on: pull_request: types: [closed] jobs: pr-cleanup: + # https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#force-deleting-cache-entries runs-on: ubuntu-latest steps: - name: Check out code