mirror of
https://code.forgejo.org/actions/forgejo-release.git
synced 2024-11-22 10:13:25 +01:00
adapt shell tests
This commit is contained in:
parent
d12e05c347
commit
ca02749d65
3 changed files with 29 additions and 27 deletions
|
@ -20,6 +20,7 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
set -ex
|
set -ex
|
||||||
export FORGEJO="${{ steps.forgejo.outputs.url }}"
|
export FORGEJO="${{ steps.forgejo.outputs.url }}"
|
||||||
export RELEASETEAMTOKEN="${{ steps.forgejo.outputs.token }}"
|
export TOKEN="${{ steps.forgejo.outputs.token }}"
|
||||||
export CI_REPO_OWNER=testuser
|
export DOER=testuser
|
||||||
testdata/forgejo-release-test.sh test_run
|
export VERBOSE=true
|
||||||
|
testdata/forgejo-release-test.sh test_run testuser otherrepo
|
||||||
|
|
|
@ -54,7 +54,7 @@ upload() {
|
||||||
|
|
||||||
setup_api() {
|
setup_api() {
|
||||||
if ! which jq curl ; then
|
if ! which jq curl ; then
|
||||||
apt-get install -y -qq jq curl
|
apt-get install -y -qq jq curl wget
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
47
testdata/forgejo-release-test.sh
vendored
47
testdata/forgejo-release-test.sh
vendored
|
@ -4,71 +4,72 @@ set -ex
|
||||||
|
|
||||||
DIR=$(mktemp -d)
|
DIR=$(mktemp -d)
|
||||||
|
|
||||||
#trap "rm -fr $DIR" EXIT
|
trap "rm -fr $DIR" EXIT
|
||||||
|
|
||||||
test_teardown() {
|
test_teardown() {
|
||||||
setup_api
|
setup_api
|
||||||
api DELETE repos/$PUSH_USER/$REPO/releases/tags/$TAG || true
|
api DELETE repos/$REPO/releases/tags/$TAG || true
|
||||||
api DELETE repos/$PUSH_USER/$REPO/tags/$TAG || true
|
api DELETE repos/$REPO/tags/$TAG || true
|
||||||
rm -fr dist/release
|
rm -fr dist/release
|
||||||
setup_tea
|
setup_tea
|
||||||
$BIN_DIR/tea login delete $RELEASETEAMUSER || true
|
$BIN_DIR/tea login delete $DOER || true
|
||||||
}
|
}
|
||||||
|
|
||||||
test_reset_repo() {
|
test_reset_repo() {
|
||||||
api DELETE repos/$PUSH_USER/$REPO || true
|
local project="$1"
|
||||||
api POST user/repos --data-raw '{"name":"'$REPO'", "auto_init":true}'
|
api DELETE repos/$REPO || true
|
||||||
git clone $FORGEJO/$PUSH_USER/$REPO $DIR/repo
|
api POST user/repos --data-raw '{"name":"'$project'", "auto_init":true}'
|
||||||
CI_COMMIT_SHA=$(git -C $DIR/repo rev-parse HEAD)
|
git clone $FORGEJO/$REPO $DIR/repo
|
||||||
|
SHA=$(git -C $DIR/repo rev-parse HEAD)
|
||||||
}
|
}
|
||||||
|
|
||||||
test_setup() {
|
test_setup() {
|
||||||
test_reset_repo
|
local project="$1"
|
||||||
|
test_reset_repo $project
|
||||||
mkdir -p $RELEASE_DIR
|
mkdir -p $RELEASE_DIR
|
||||||
touch $RELEASE_DIR/file-one.txt
|
touch $RELEASE_DIR/file-one.txt
|
||||||
touch $RELEASE_DIR/file-two.txt
|
touch $RELEASE_DIR/file-two.txt
|
||||||
}
|
}
|
||||||
|
|
||||||
test_ensure_tag() {
|
test_ensure_tag() {
|
||||||
api DELETE repos/$PUSH_USER/$REPO/tags/$TAG || true
|
api DELETE repos/$REPO/tags/$TAG || true
|
||||||
#
|
#
|
||||||
# idempotent
|
# idempotent
|
||||||
#
|
#
|
||||||
ensure_tag
|
ensure_tag
|
||||||
api GET repos/$PUSH_USER/$REPO/tags/$TAG > $DIR/tag1.json
|
api GET repos/$REPO/tags/$TAG > $DIR/tag1.json
|
||||||
ensure_tag
|
ensure_tag
|
||||||
api GET repos/$PUSH_USER/$REPO/tags/$TAG > $DIR/tag2.json
|
api GET repos/$REPO/tags/$TAG > $DIR/tag2.json
|
||||||
diff -u $DIR/tag[12].json
|
diff -u $DIR/tag[12].json
|
||||||
#
|
#
|
||||||
# sanity check on the SHA of an existing tag
|
# sanity check on the SHA of an existing tag
|
||||||
#
|
#
|
||||||
(
|
(
|
||||||
CI_COMMIT_SHA=12345
|
SHA=12345
|
||||||
! ensure_tag
|
! ensure_tag
|
||||||
)
|
)
|
||||||
api DELETE repos/$PUSH_USER/$REPO/tags/$TAG
|
api DELETE repos/$REPO/tags/$TAG
|
||||||
}
|
}
|
||||||
|
|
||||||
test_run() {
|
test_run() {
|
||||||
|
local user="$1"
|
||||||
|
local project="$2"
|
||||||
test_teardown
|
test_teardown
|
||||||
to_push=$DIR/binaries-releases-to-push
|
to_push=$DIR/binaries-releases-to-push
|
||||||
pulled=$DIR/binaries-releases-pulled
|
pulled=$DIR/binaries-releases-pulled
|
||||||
RELEASE_DIR=$to_push
|
RELEASE_DIR=$to_push
|
||||||
test_setup
|
REPO=$user/$project
|
||||||
|
test_setup $project
|
||||||
test_ensure_tag
|
test_ensure_tag
|
||||||
echo "================================ TEST BEGIN"
|
echo "================================ TEST BEGIN"
|
||||||
push
|
upload
|
||||||
RELEASE_DIR=$pulled
|
RELEASE_DIR=$pulled
|
||||||
pull
|
download
|
||||||
diff -r $to_push $pulled
|
diff -r $to_push $pulled
|
||||||
echo "================================ TEST END"
|
echo "================================ TEST END"
|
||||||
}
|
}
|
||||||
|
|
||||||
: ${RELEASETEAMUSER:=root}
|
: ${DOER:=root}
|
||||||
: ${REPO:=testrepo}
|
: ${TAG:=v17.8.20-1}
|
||||||
: ${CI_REPO_OWNER:=root}
|
|
||||||
: ${PULL_USER=$CI_REPO_OWNER}
|
|
||||||
: ${PUSH_USER=$CI_REPO_OWNER}
|
|
||||||
: ${CI_COMMIT_TAG:=v17.8.20-1}
|
|
||||||
|
|
||||||
. $(dirname $0)/../forgejo-release.sh
|
. $(dirname $0)/../forgejo-release.sh
|
||||||
|
|
Loading…
Reference in a new issue