Skip to content

Commit

Permalink
btrfs-progs: ci: update cleanup scripts
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
kdave committed Aug 16, 2024
1 parent 269d106 commit 84c044d
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion ci/actions/delete-all-failed-devel-runs
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 6 additions & 4 deletions ci/actions/delete-all-runs-of-branch
Original file line number Diff line number Diff line change
Expand Up @@ -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]"
Expand All @@ -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
2 changes: 1 addition & 1 deletion ci/actions/keep-last-ci-image-tests
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ci/actions/keep-last-coverage
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ci/actions/keep-last-devel-runs
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion ci/actions/keep-last-static-binaries
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion ci/actions/keep-last-week
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
4 changes: 2 additions & 2 deletions ci/actions/update-artifacts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 84c044d

Please sign in to comment.