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