mirror of
https://code.forgejo.org/actions/forgejo-release.git
synced 2024-12-22 07:35:48 +02: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: |
|
||||
set -ex
|
||||
export FORGEJO="${{ steps.forgejo.outputs.url }}"
|
||||
export RELEASETEAMTOKEN="${{ steps.forgejo.outputs.token }}"
|
||||
export CI_REPO_OWNER=testuser
|
||||
testdata/forgejo-release-test.sh test_run
|
||||
export TOKEN="${{ steps.forgejo.outputs.token }}"
|
||||
export DOER=testuser
|
||||
export VERBOSE=true
|
||||
testdata/forgejo-release-test.sh test_run testuser otherrepo
|
||||
|
|
|
@ -54,7 +54,7 @@ upload() {
|
|||
|
||||
setup_api() {
|
||||
if ! which jq curl ; then
|
||||
apt-get install -y -qq jq curl
|
||||
apt-get install -y -qq jq curl wget
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
47
testdata/forgejo-release-test.sh
vendored
47
testdata/forgejo-release-test.sh
vendored
|
@ -4,71 +4,72 @@ set -ex
|
|||
|
||||
DIR=$(mktemp -d)
|
||||
|
||||
#trap "rm -fr $DIR" EXIT
|
||||
trap "rm -fr $DIR" EXIT
|
||||
|
||||
test_teardown() {
|
||||
setup_api
|
||||
api DELETE repos/$PUSH_USER/$REPO/releases/tags/$TAG || true
|
||||
api DELETE repos/$PUSH_USER/$REPO/tags/$TAG || true
|
||||
api DELETE repos/$REPO/releases/tags/$TAG || true
|
||||
api DELETE repos/$REPO/tags/$TAG || true
|
||||
rm -fr dist/release
|
||||
setup_tea
|
||||
$BIN_DIR/tea login delete $RELEASETEAMUSER || true
|
||||
$BIN_DIR/tea login delete $DOER || true
|
||||
}
|
||||
|
||||
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)
|
||||
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)
|
||||
}
|
||||
|
||||
test_setup() {
|
||||
test_reset_repo
|
||||
local project="$1"
|
||||
test_reset_repo $project
|
||||
mkdir -p $RELEASE_DIR
|
||||
touch $RELEASE_DIR/file-one.txt
|
||||
touch $RELEASE_DIR/file-two.txt
|
||||
}
|
||||
|
||||
test_ensure_tag() {
|
||||
api DELETE repos/$PUSH_USER/$REPO/tags/$TAG || true
|
||||
api DELETE repos/$REPO/tags/$TAG || true
|
||||
#
|
||||
# idempotent
|
||||
#
|
||||
ensure_tag
|
||||
api GET repos/$PUSH_USER/$REPO/tags/$TAG > $DIR/tag1.json
|
||||
api GET repos/$REPO/tags/$TAG > $DIR/tag1.json
|
||||
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
|
||||
#
|
||||
# sanity check on the SHA of an existing tag
|
||||
#
|
||||
(
|
||||
CI_COMMIT_SHA=12345
|
||||
SHA=12345
|
||||
! ensure_tag
|
||||
)
|
||||
api DELETE repos/$PUSH_USER/$REPO/tags/$TAG
|
||||
api DELETE repos/$REPO/tags/$TAG
|
||||
}
|
||||
|
||||
test_run() {
|
||||
local user="$1"
|
||||
local project="$2"
|
||||
test_teardown
|
||||
to_push=$DIR/binaries-releases-to-push
|
||||
pulled=$DIR/binaries-releases-pulled
|
||||
RELEASE_DIR=$to_push
|
||||
test_setup
|
||||
REPO=$user/$project
|
||||
test_setup $project
|
||||
test_ensure_tag
|
||||
echo "================================ TEST BEGIN"
|
||||
push
|
||||
upload
|
||||
RELEASE_DIR=$pulled
|
||||
pull
|
||||
download
|
||||
diff -r $to_push $pulled
|
||||
echo "================================ TEST END"
|
||||
}
|
||||
|
||||
: ${RELEASETEAMUSER:=root}
|
||||
: ${REPO:=testrepo}
|
||||
: ${CI_REPO_OWNER:=root}
|
||||
: ${PULL_USER=$CI_REPO_OWNER}
|
||||
: ${PUSH_USER=$CI_REPO_OWNER}
|
||||
: ${CI_COMMIT_TAG:=v17.8.20-1}
|
||||
: ${DOER:=root}
|
||||
: ${TAG:=v17.8.20-1}
|
||||
|
||||
. $(dirname $0)/../forgejo-release.sh
|
||||
|
|
Loading…
Reference in a new issue