2023-03-26 18:41:37 +03:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -ex
|
|
|
|
|
2023-03-27 00:03:56 +03:00
|
|
|
DIR=$(mktemp -d)
|
|
|
|
|
2023-03-30 02:08:18 +03:00
|
|
|
trap "rm -fr $DIR" EXIT
|
2023-03-27 00:03:56 +03:00
|
|
|
|
2023-03-26 18:41:37 +03:00
|
|
|
test_teardown() {
|
|
|
|
setup_api
|
2023-03-30 02:08:18 +03:00
|
|
|
api DELETE repos/$REPO/releases/tags/$TAG || true
|
|
|
|
api DELETE repos/$REPO/tags/$TAG || true
|
2023-03-26 18:41:37 +03:00
|
|
|
rm -fr dist/release
|
|
|
|
setup_tea
|
2023-03-30 02:08:18 +03:00
|
|
|
$BIN_DIR/tea login delete $DOER || true
|
2023-03-26 18:41:37 +03:00
|
|
|
}
|
|
|
|
|
2023-03-27 00:03:56 +03:00
|
|
|
test_reset_repo() {
|
2023-03-30 02:08:18 +03:00
|
|
|
local project="$1"
|
|
|
|
api DELETE repos/$REPO || true
|
|
|
|
api POST user/repos --data-raw '{"name":"'$project'", "auto_init":true}'
|
|
|
|
git clone $FORGEJO/$REPO $DIR/repo
|
|
|
|
SHA=$(git -C $DIR/repo rev-parse HEAD)
|
2023-03-27 00:03:56 +03:00
|
|
|
}
|
|
|
|
|
2023-03-26 18:41:37 +03:00
|
|
|
test_setup() {
|
2023-03-30 02:08:18 +03:00
|
|
|
local project="$1"
|
|
|
|
test_reset_repo $project
|
2023-03-26 18:41:37 +03:00
|
|
|
mkdir -p $RELEASE_DIR
|
|
|
|
touch $RELEASE_DIR/file-one.txt
|
|
|
|
touch $RELEASE_DIR/file-two.txt
|
|
|
|
}
|
|
|
|
|
|
|
|
test_ensure_tag() {
|
2023-03-30 02:08:18 +03:00
|
|
|
api DELETE repos/$REPO/tags/$TAG || true
|
2023-03-26 18:41:37 +03:00
|
|
|
#
|
|
|
|
# idempotent
|
|
|
|
#
|
|
|
|
ensure_tag
|
2023-03-30 02:08:18 +03:00
|
|
|
api GET repos/$REPO/tags/$TAG > $DIR/tag1.json
|
2023-03-26 18:41:37 +03:00
|
|
|
ensure_tag
|
2023-03-30 02:08:18 +03:00
|
|
|
api GET repos/$REPO/tags/$TAG > $DIR/tag2.json
|
2023-03-27 00:03:56 +03:00
|
|
|
diff -u $DIR/tag[12].json
|
2023-03-26 18:41:37 +03:00
|
|
|
#
|
|
|
|
# sanity check on the SHA of an existing tag
|
|
|
|
#
|
|
|
|
(
|
2023-03-30 02:08:18 +03:00
|
|
|
SHA=12345
|
2023-03-26 18:41:37 +03:00
|
|
|
! ensure_tag
|
|
|
|
)
|
2023-03-30 02:08:18 +03:00
|
|
|
api DELETE repos/$REPO/tags/$TAG
|
2023-03-26 18:41:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
test_run() {
|
2023-03-30 02:08:18 +03:00
|
|
|
local user="$1"
|
|
|
|
local project="$2"
|
2023-03-26 18:41:37 +03:00
|
|
|
test_teardown
|
2023-03-27 00:03:56 +03:00
|
|
|
to_push=$DIR/binaries-releases-to-push
|
|
|
|
pulled=$DIR/binaries-releases-pulled
|
2023-03-26 18:41:37 +03:00
|
|
|
RELEASE_DIR=$to_push
|
2023-03-30 02:08:18 +03:00
|
|
|
REPO=$user/$project
|
|
|
|
test_setup $project
|
2023-03-26 18:41:37 +03:00
|
|
|
test_ensure_tag
|
|
|
|
echo "================================ TEST BEGIN"
|
2023-03-30 02:08:18 +03:00
|
|
|
upload
|
2023-03-26 18:41:37 +03:00
|
|
|
RELEASE_DIR=$pulled
|
2023-03-30 02:08:18 +03:00
|
|
|
download
|
2023-03-26 18:41:37 +03:00
|
|
|
diff -r $to_push $pulled
|
|
|
|
echo "================================ TEST END"
|
|
|
|
}
|
|
|
|
|
2023-03-30 02:08:18 +03:00
|
|
|
: ${TAG:=v17.8.20-1}
|
2023-03-26 18:41:37 +03:00
|
|
|
|
|
|
|
. $(dirname $0)/../forgejo-release.sh
|