From 7c3b8978036983e5b3e6f736d8168fcc1029f4fb Mon Sep 17 00:00:00 2001 From: David Sterba Date: Fri, 16 Aug 2024 21:34:28 +0200 Subject: [PATCH] btrfs-progs: ci: update cleanup scripts Add limit parameter so workflows are not skipped if they don't fit the default limit 10. Add more workflows to clean up after recent updates. Signed-off-by: David Sterba --- ci/actions/delete-all-failed-devel-runs | 2 +- ci/actions/delete-all-runs-of-branch | 10 ++++++---- ci/actions/keep-last-ci-image-tests | 2 +- ci/actions/keep-last-coverage | 2 +- ci/actions/keep-last-devel-runs | 2 +- ci/actions/keep-last-static-binaries | 2 +- ci/actions/keep-last-week | 5 ++++- ci/actions/update-artifacts | 4 ++-- 8 files changed, 17 insertions(+), 12 deletions(-) diff --git a/ci/actions/delete-all-failed-devel-runs b/ci/actions/delete-all-failed-devel-runs index 79d33b39..983cb178 100755 --- a/ci/actions/delete-all-failed-devel-runs +++ b/ci/actions/delete-all-failed-devel-runs @@ -8,7 +8,7 @@ repo="kdave/btrfs-progs" type -p gh > /dev/null || { echo "ERROR: gh tool not found"; exit 1; } type -p jq > /dev/null || { echo "ERROR: jq tool not found"; exit 1; } -for id in $(gh run -R "$repo" list --workflow "$workflow" --status failure --json databaseId | jq '.[].databaseId'); do +for id in $(gh run -R "$repo" list --limit 100 --workflow "$workflow" --status failure --json databaseId | jq '.[].databaseId'); do echo "Delete run $id" gh run -R "$repo" delete "$id" done diff --git a/ci/actions/delete-all-runs-of-branch b/ci/actions/delete-all-runs-of-branch index 9e1e1948..e7596f79 100755 --- a/ci/actions/delete-all-runs-of-branch +++ b/ci/actions/delete-all-runs-of-branch @@ -16,11 +16,13 @@ notthatone() { exit 1 } +areyousure() { + echo "WARNING: protected branch, make sure you want to remove it: $1" +} + case "$branch" in master) notthatone "$branch";; - devel) notthatone "$branch";; - coverage-test) notthatone "$branch";; - release-test) notthatone "$branch";; + devel) areyousure "$branch";; esac echo "Delete all runs of branch $branch, are you sure? [y/N]" @@ -31,7 +33,7 @@ if ! [ "$answer" = 'y' ]; then fi echo -for id in $(gh run -R "$repo" list --json databaseId --branch "$branch" | jq '.[].databaseId'); do +for id in $(gh run -R "$repo" list --limit 100 --json databaseId --branch "$branch" | jq '.[].databaseId'); do echo "Delete run $id" gh run -R "$repo" delete "$id" done diff --git a/ci/actions/keep-last-ci-image-tests b/ci/actions/keep-last-ci-image-tests index ceff31a6..40186edc 100755 --- a/ci/actions/keep-last-ci-image-tests +++ b/ci/actions/keep-last-ci-image-tests @@ -9,7 +9,7 @@ type -p gh > /dev/null || { echo "ERROR: gh tool not found"; exit 1; } type -p jq > /dev/null || { echo "ERROR: jq tool not found"; exit 1; } for branch in master release-test; do - for id in $(gh run -R "$repo" list --workflow "$workflow" --branch "$branch" --json databaseId | jq '.[1:] | .[].databaseId'); do + for id in $(gh run -R "$repo" list --limit 100 --workflow "$workflow" --branch "$branch" --json databaseId | jq '.[1:] | .[].databaseId'); do echo "Delete run $id" gh run -R "$repo" delete "$id" done diff --git a/ci/actions/keep-last-coverage b/ci/actions/keep-last-coverage index 76eb7033..f2543f72 100755 --- a/ci/actions/keep-last-coverage +++ b/ci/actions/keep-last-coverage @@ -9,7 +9,7 @@ type -p gh > /dev/null || { echo "ERROR: gh tool not found"; exit 1; } type -p jq > /dev/null || { echo "ERROR: jq tool not found"; exit 1; } for branch in master coverage-test; do - for id in $(gh run -R "$repo" list --workflow "$workflow" --branch "$branch" --json databaseId | jq '.[1:] | .[].databaseId'); do + for id in $(gh run -R "$repo" list --limit 100 --workflow "$workflow" --branch "$branch" --json databaseId | jq '.[1:] | .[].databaseId'); do echo "Delete run $id" gh run -R "$repo" delete "$id" done diff --git a/ci/actions/keep-last-devel-runs b/ci/actions/keep-last-devel-runs index 5a65aaae..96f5f08f 100755 --- a/ci/actions/keep-last-devel-runs +++ b/ci/actions/keep-last-devel-runs @@ -7,7 +7,7 @@ repo="kdave/btrfs-progs" from=11 -for id in $(gh run -R "$repo" list -w 'Devel build and tests' --json databaseId | jq '.[].databaseId' | tail -n +${from}); do +for id in $(gh run -R "$repo" list --limit 100 --workflow 'Devel build and tests' --json databaseId | jq '.[].databaseId' | tail -n +${from}); do echo "Delete run $id" gh run -R "$repo" delete "$id" done diff --git a/ci/actions/keep-last-static-binaries b/ci/actions/keep-last-static-binaries index 421a6867..ebd769dd 100755 --- a/ci/actions/keep-last-static-binaries +++ b/ci/actions/keep-last-static-binaries @@ -9,7 +9,7 @@ type -p gh > /dev/null || { echo "ERROR: gh tool not found"; exit 1; } type -p jq > /dev/null || { echo "ERROR: jq tool not found"; exit 1; } for branch in master release-test; do - for id in $(gh run -R "$repo" list --workflow "$workflow" --branch "$branch" --json databaseId | jq '.[1:] | .[].databaseId'); do + for id in $(gh run -R "$repo" list --limit 100 --workflow "$workflow" --branch "$branch" --json databaseId | jq '.[1:] | .[].databaseId'); do echo "Delete run $id" gh run -R "$repo" delete "$id" done diff --git a/ci/actions/keep-last-week b/ci/actions/keep-last-week index e985380d..08834027 100755 --- a/ci/actions/keep-last-week +++ b/ci/actions/keep-last-week @@ -11,7 +11,7 @@ daysmax=8 clean_workflow() { local wf="$1" - local json=$(gh run -R "$repo" list --workflow "$wf" --json databaseId,startedAt) + local json=$(gh run -R "$repo" list --limit 100 --workflow "$wf" --json databaseId,startedAt) echo "Cleaning workflow $wf" i=0 @@ -40,3 +40,6 @@ clean_workflow() { clean_workflow "Testing CI build" clean_workflow "Devel build and tests" clean_workflow "Pull request build and tests" +clean_workflow "Codespell" +clean_workflow "CI image tests" +clean_workflow "Sanitizer checks" diff --git a/ci/actions/update-artifacts b/ci/actions/update-artifacts index 4c6c349e..6bf4e8e5 100755 --- a/ci/actions/update-artifacts +++ b/ci/actions/update-artifacts @@ -16,8 +16,8 @@ repo="kdave/btrfs-progs" tag="$1" # TODO: verify that tag exists -# Read last workflow id -id=$(gh run -R "$repo" list -w 'Static binaries' -L 1 --json databaseId | jq '.[].databaseId') +# Read last workflow id for master branch +id=$(gh run -R "$repo" list --limit 1 --workflow 'Static binaries' --branch 'master' --json databaseId | jq '.[].databaseId') for asset in btrfs.box.static btrfs.static; do gh run -R "$repo" download "$id" -n "$asset"