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

[GHA] DRAFT: cleanup caches #19809

Closed
wants to merge 33 commits into from
Closed
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
62 changes: 62 additions & 0 deletions .github/workflows/cleanup_cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Cleanup cache
on:
pull_request:
types:
- closed

jobs:
cleanup:
runs-on: ubuntu-latest

permissions:
actions: write
contents: read

env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge

steps:
- name: Preconditions (Install gh-actions-cache)
run: |
gh extension install actions/gh-actions-cache

- name: Cleanup PR's caches
run: |
echo "Fetching list of cache keys for ${BRANCH}"
CACHE_KEYS_FOR_PR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 )

set +e
echo "Deleting caches..."
for CACHE_KEY in $CACHE_KEYS_FOR_PR
do
gh actions-cache delete $CACHE_KEY -R $REPO -B $BRANCH --confirm
done
echo "Done"

- name: Cleanup master's caches
env:
BRANCH: master
KEYS: "ccache-linux-ubuntu ccache-Build-linux-debian ccache-Build-linux-android ccache-Build-linux-arm64"
run: |
for KEY in ${KEYS[@]}
do
echo "Fetching list of cache with key ${KEY} for ${BRANCH}"
CACHE_KEYS=( $(gh actions-cache list -R $REPO -B $BRANCH -L 100 --key $KEY --sort created-at --order desc | cut -f 1) )
CACHE_KEYS_OLD=("${CACHE_KEYS[@]:1}")
echo "${CACHE_KEYS_OLD[@]}"
set +e
if [[ ${#CACHE_KEYS_OLD[@]} -gt 0 ]]
then
echo "Deleting caches..."
for CACHE_KEY in ${CACHE_KEYS_OLD[@]}
do
if [[ ! -z "$CACHE_KEY" ]]
then
gh actions-cache delete $CACHE_KEY -R $REPO -B $BRANCH --confirm
fi
done
fi
done
echo "Done"
7 changes: 4 additions & 3 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,10 @@ jobs:
max-size: "2000M"
# Should save cache only if run in the master branch of the base repo
# github.ref_name is 'ref/PR_#' in case of the PR, and 'branch_name' when executed on push
save: ${{ github.ref_name == 'master' && 'true' || 'false' }}
# save: ${{ github.ref_name == 'master' && 'true' || 'false' }}
verbose: 2
key: linux-ubuntu
append-timestamp: false
key: linux-ubuntu-${{ github.ref_name == 'master' && github.sha || github.ref_name }}
restore-keys: |
linux-ubuntu

Expand Down Expand Up @@ -780,7 +781,7 @@ jobs:
uses: actions/cache@v3
with:
path: ${{ env.PARALLEL_TEST_CACHE }}
key: ${{ runner.os }}-tests-functional-cpu-cache
key: ${{ runner.os }}-tests-functional-cpu-stamp-${{ github.ref_name == 'master' && github.sha || github.ref_name }}

- name: Intel CPU plugin func tests (parallel)
run: |
Expand Down