diff --git a/ci/actions/delete-all-failed-devel-runs b/ci/actions/delete-all-failed-devel-runs new file mode 100755 index 00000000..795fe429 --- /dev/null +++ b/ci/actions/delete-all-failed-devel-runs @@ -0,0 +1,11 @@ +#!/bin/sh -xe + +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; } + +repo="kdave/btrfs-progs" + +for id in $(gh run -R "$repo" list -w 'Devel build and tests' -s failure --json databaseId | 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 new file mode 100755 index 00000000..09d59855 --- /dev/null +++ b/ci/actions/keep-last-ci-image-tests @@ -0,0 +1,13 @@ +#!/bin/sh -xe + +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; } + +repo="kdave/btrfs-progs" + +from=3 + +for id in $(gh run -R "$repo" list -w 'CI image 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-devel-runs b/ci/actions/keep-last-devel-runs new file mode 100755 index 00000000..5a65aaae --- /dev/null +++ b/ci/actions/keep-last-devel-runs @@ -0,0 +1,13 @@ +#!/bin/sh -xe + +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; } + +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 + 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 new file mode 100755 index 00000000..bc52a682 --- /dev/null +++ b/ci/actions/keep-last-static-binaries @@ -0,0 +1,13 @@ +#!/bin/sh -xe + +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; } + +repo="kdave/btrfs-progs" + +from=3 + +for id in $(gh run -R "$repo" list -w 'Static binaries' --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-week b/ci/actions/keep-last-week new file mode 100755 index 00000000..106bce4e --- /dev/null +++ b/ci/actions/keep-last-week @@ -0,0 +1,40 @@ +#!/bin/sh -e + +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; } + +repo="kdave/btrfs-progs" + +daysmax=8 + +clean_workflow() { + local wf="$1" + local json=$(gh run -R "$repo" list -w "$wf" --json databaseId,startedAt) + + echo "Cleaning workflow $wf" + i=0 + while :; do + id=$(echo "$json" | jq -r ".[$i].databaseId") + if [ "$id" == "null" -o -z "$id" ]; then + break + fi + echo "ID: $id" + now=$(date +%s) + date=$(echo "$json" | jq -r ".[$i].startedAt") + ts=$(date --date=${date} +%s) + delta=$(($now-$ts)) + days=$(($delta/3600/24)) + echo "Started at $id, delta $delta, days $days" + if [ "$days" -ge "$daysmax" ]; then + echo "Delete run $id" + gh run -R "$repo" delete "$id" + fi + + # loop + i=$(($i+1)) + done +} + +clean_workflow "Testing CI build" +clean_workflow "Devel build and tests" +clean_workflow "CI image tests" diff --git a/ci/actions/update-artifacts b/ci/actions/update-artifacts new file mode 100755 index 00000000..4c6c349e --- /dev/null +++ b/ci/actions/update-artifacts @@ -0,0 +1,31 @@ +#!/bin/sh -ex +# Usage: $0 tag +# +# Requires: gh extension 'release' installed (https://cli.github.com/manual/gh_release) + +if [ -z "$1" ]; then + echo "ERROR: needs tag where to upload the static binaries" + exit 1 +fi + +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; } + +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') + +for asset in btrfs.box.static btrfs.static; do + gh run -R "$repo" download "$id" -n "$asset" + chmod 755 "$asset" + gh release -R "$repo" upload "$tag" "$asset" +done + +for asset in btrfs.box.static.sha256 btrfs.static.sha256; do + gh run -R "$repo" download "$id" -n "$asset" + gh release -R "$repo" upload "$tag" "$asset" +done