Merge pull request 'shfmt -w globally' (#237) from earl-warren/end-to-end:wip-shfmt into main

Reviewed-on: https://code.forgejo.org///forgejo/end-to-end/pulls/237
Reviewed-by: thefox <thefox@noreply.code.forgejo.org>
This commit is contained in:
earl-warren 2024-08-07 08:20:51 +00:00
commit 47a6f7ee78
27 changed files with 378 additions and 375 deletions

View file

@ -1,7 +1,7 @@
# Copyright 2024 The Forgejo Authors # Copyright 2024 The Forgejo Authors
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
ACTIONS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" ACTIONS_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
function actions_verify_example() { function actions_verify_example() {
local example=$1 local example=$1
@ -15,19 +15,19 @@ function actions_verify_example() {
export example export example
export EXAMPLE_DIR=$ACTIONS_DIR/example-$example export EXAMPLE_DIR=$ACTIONS_DIR/example-$example
if test -f $EXAMPLE_DIR/setup.sh ; then if test -f $EXAMPLE_DIR/setup.sh; then
echo "============================ SETUP example-$example ===================" echo "============================ SETUP example-$example ==================="
bash -ex $EXAMPLE_DIR/setup.sh || return 1 bash -ex $EXAMPLE_DIR/setup.sh || return 1
fi fi
if test -f $EXAMPLE_DIR/run.sh ; then if test -f $EXAMPLE_DIR/run.sh; then
echo "============================ RUN example-$example ===================" echo "============================ RUN example-$example ==================="
bash -ex $EXAMPLE_DIR/run.sh || return 1 bash -ex $EXAMPLE_DIR/run.sh || return 1
else else
forgejo-test-helper.sh run_workflow actions/example-$example $url root example-$example $example $token || return 1 forgejo-test-helper.sh run_workflow actions/example-$example $url root example-$example $example $token || return 1
fi fi
if test -f $EXAMPLE_DIR/teardown.sh ; then if test -f $EXAMPLE_DIR/teardown.sh; then
echo "============================ TEARDOWN example-$example ===================" echo "============================ TEARDOWN example-$example ==================="
bash -ex $EXAMPLE_DIR/teardown.sh || return 1 bash -ex $EXAMPLE_DIR/teardown.sh || return 1
fi fi
@ -45,11 +45,11 @@ function actions_save_contexts() {
} }
function actions_cleanup_example_volume() { function actions_cleanup_example_volume() {
if test $(id -u) != 0 ; then if test $(id -u) != 0; then
$SUDO chown $(id -u) /srv $SUDO chown $(id -u) /srv
fi fi
if ! test -d /srv/example ; then if ! test -d /srv/example; then
mkdir -p /srv/example mkdir -p /srv/example
return return
fi fi
@ -79,7 +79,7 @@ function actions_teardown() {
function actions_runner_version() { function actions_runner_version() {
local runner_version=$($DIR/forgejo-runner --version | sed -n -e 's/forgejo-runner version v//p') local runner_version=$($DIR/forgejo-runner --version | sed -n -e 's/forgejo-runner version v//p')
if test -z "$runner_version" ; then if test -z "$runner_version"; then
$DIR/forgejo-runner --version $DIR/forgejo-runner --version
echo failed to parse version echo failed to parse version
false false
@ -90,37 +90,37 @@ function actions_runner_version() {
function test_actions() { function test_actions() {
local versions="${1:-1.21 $RELEASE_NUMBERS_AND_DEV}" local versions="${1:-1.21 $RELEASE_NUMBERS_AND_DEV}"
for version in $versions ; do for version in $versions; do
actions_setup $version actions_setup $version
local runner_version=$(actions_runner_version) local runner_version=$(actions_runner_version)
log_info "Testing actions with Forgejo $version & Forgejo runner $runner_version" log_info "Testing actions with Forgejo $version & Forgejo runner $runner_version"
if dpkg --compare-versions $version ge 7.0 && dpkg --compare-versions $runner_version gt 3.3.0 ; then if dpkg --compare-versions $version ge 7.0 && dpkg --compare-versions $runner_version gt 3.3.0; then
for example in artifacts-v4 ; do for example in artifacts-v4; do
run actions_verify_example $example run actions_verify_example $example
done done
fi fi
for example in echo cache checkout service container expression local-action docker-action if if-fail push tag push-cancel artifacts pull-request context ; do for example in echo cache checkout service container expression local-action docker-action if if-fail push tag push-cancel artifacts pull-request context; do
run actions_verify_example $example run actions_verify_example $example
done done
if dpkg --compare-versions $version lt 7.1 ; then if dpkg --compare-versions $version lt 7.1; then
for example in cron ; do for example in cron; do
run actions_verify_example $example run actions_verify_example $example
done done
fi fi
if dpkg --compare-versions $version ge 7.1 ; then if dpkg --compare-versions $version ge 7.1; then
for example in automerge post-7-0-schedule ; do for example in automerge post-7-0-schedule; do
run actions_verify_example $example run actions_verify_example $example
done done
fi fi
if dpkg --compare-versions $version ge 8.0 ; then if dpkg --compare-versions $version ge 8.0; then
for example in workflow-dispatch ; do for example in workflow-dispatch; do
run actions_verify_example $example run actions_verify_example $example
done done
fi fi

View file

@ -16,12 +16,12 @@ forgejo-curl.sh api_json --data '{"new_branch_name":"zzzz"}' $api/repos/root/exa
verify_ref verify_ref
# cron runs once per minute, give it three minutes max before declaring failure # cron runs once per minute, give it three minutes max before declaring failure
if ! RETRY_DELAYS="30 30 30 30 30 30" forgejo.sh retry test -f /srv/example/cron-volume/DONE ; then if ! RETRY_DELAYS="30 30 30 30 30 30" forgejo.sh retry test -f /srv/example/cron-volume/DONE; then
cat $FORGEJO_RUNNER_LOGS cat $FORGEJO_RUNNER_LOGS
false false
fi fi
c=/srv/example/cron/contexts/schedule/github c=/srv/example/cron/contexts/schedule/github
cat $c cat $c
test "schedule" = "$(jq -r .event_name < $c)" test "schedule" = "$(jq -r .event_name <$c)"
test "schedule" = "$(jq -r .event.action < $c)" test "schedule" = "$(jq -r .event.action <$c)"

View file

@ -19,12 +19,12 @@ forgejo-curl.sh api_json --data '{"new_branch_name":"zzzz"}' $api/repos/root/exa
verify_ref verify_ref
# runs once per minute, give it three minutes max before declaring failure # runs once per minute, give it three minutes max before declaring failure
if ! RETRY_DELAYS="30 30 30 30 30 30" forgejo.sh retry test -f /srv/example/post-7-0-schedule-volume/DONE ; then if ! RETRY_DELAYS="30 30 30 30 30 30" forgejo.sh retry test -f /srv/example/post-7-0-schedule-volume/DONE; then
cat $FORGEJO_RUNNER_LOGS cat $FORGEJO_RUNNER_LOGS
false false
fi fi
c=/srv/example/post-7-0-schedule/contexts/schedule/github c=/srv/example/post-7-0-schedule/contexts/schedule/github
cat $c cat $c
test "schedule" = "$(jq -r .event_name < $c)" test "schedule" = "$(jq -r .event_name <$c)"
test "schedule" = "$(jq -r .event.action < $c)" test "schedule" = "$(jq -r .event.action <$c)"

View file

@ -4,8 +4,8 @@ set -ex
c=$d/contexts c=$d/contexts
test opened = "$(jq -r .event.action < $c/fork-org/pull_request/github)" test opened = "$(jq -r .event.action <$c/fork-org/pull_request/github)"
test opened = "$(jq -r .event.action < $c/fork-org/pull_request_target/github)" test opened = "$(jq -r .event.action <$c/fork-org/pull_request_target/github)"
test opened = "$(jq -r .event.action < $c/root/pull_request/github)" test opened = "$(jq -r .event.action <$c/root/pull_request/github)"
test opened = "$(jq -r .event.action < $c/root/pull_request_target/github)" test opened = "$(jq -r .event.action <$c/root/pull_request_target/github)"

View file

@ -12,14 +12,13 @@ function main() {
forgejo-curl.sh api_json --data-raw '{"organization":"fork-org"}' $api/repos/root/example-pull-request/forks forgejo-curl.sh api_json --data-raw '{"organization":"fork-org"}' $api/repos/root/example-pull-request/forks
forgejo-curl.sh api_json -X PUT --data-raw '{"data":"AAAA"}' $api/repos/root/example-pull-request/actions/secrets/SECRET forgejo-curl.sh api_json -X PUT --data-raw '{"data":"AAAA"}' $api/repos/root/example-pull-request/actions/secrets/SECRET
( (
cd $d cd $d
git clone $url/fork-org/example-pull-request fork git clone $url/fork-org/example-pull-request fork
cd fork cd fork
git config user.email root@example.com git config user.email root@example.com
git config user.name username git config user.name username
echo fork $PROOF >> README echo fork $PROOF >>README
touch file-unique-to-the-pr-branch touch file-unique-to-the-pr-branch
git add . git add .
git commit -m 'fork change' git commit -m 'fork change'
@ -36,7 +35,7 @@ function main() {
git config user.email root@example.com git config user.email root@example.com
git config user.name username git config user.name username
touch file-unique-to-the-pr-branch touch file-unique-to-the-pr-branch
echo other $PROOF >> README echo other $PROOF >>README
git add . git add .
git commit -m 'other change' git commit -m 'other change'
git push --force -u origin other git push --force -u origin other
@ -45,10 +44,10 @@ function main() {
forgejo.sh retry forgejo-curl.sh api_json --data-raw '{"title":"PR same repo","base":"main","head":"other"}' $api/repos/root/example-pull-request/pulls forgejo.sh retry forgejo-curl.sh api_json --data-raw '{"title":"PR same repo","base":"main","head":"other"}' $api/repos/root/example-pull-request/pulls
export RETRY_DELAYS="60 60 60 60 60 60 60" export RETRY_DELAYS="60 60 60 60 60 60 60"
for assert in $EXAMPLE_DIR/assert-*.sh ; do for assert in $EXAMPLE_DIR/assert-*.sh; do
if ! forgejo.sh retry $assert ; then if ! forgejo.sh retry $assert; then
find $d find $d
sed -e 's/^/[RUNNER LOGS]/' < $FORGEJO_RUNNER_LOGS sed -e 's/^/[RUNNER LOGS]/' <$FORGEJO_RUNNER_LOGS
false false
fi fi
done done

View file

@ -1,2 +1 @@
mkdir -p /srv/example/pull-request mkdir -p /srv/example/pull-request

View file

@ -1,3 +1,3 @@
> /srv/example-service-volume-valid >/srv/example-service-volume-valid
> /srv/example-service-volume-invalid >/srv/example-service-volume-invalid
FORGEJO_RUNNER_CONFIG=$EXAMPLE_DIR/runner-config.yaml forgejo-runner.sh reload FORGEJO_RUNNER_CONFIG=$EXAMPLE_DIR/runner-config.yaml forgejo-runner.sh reload

View file

@ -10,7 +10,7 @@ api=$url/api/v1
repo=root/example-$example repo=root/example-$example
function context_wait() { function context_wait() {
if ! forgejo.sh retry test -f $context ; then if ! forgejo.sh retry test -f $context; then
cat "$FORGEJO_RUNNER_LOGS" cat "$FORGEJO_RUNNER_LOGS"
false false
fi fi
@ -19,7 +19,7 @@ function context_wait() {
function verify_required() { function verify_required() {
local actual=$(forgejo-curl.sh api_json -w '%{http_code}' --data '{"ref":"main","inputs":{}}' $api/repos/$repo/actions/workflows/test.yml/dispatches) local actual=$(forgejo-curl.sh api_json -w '%{http_code}' --data '{"ref":"main","inputs":{}}' $api/repos/$repo/actions/workflows/test.yml/dispatches)
local expected=400 local expected=400
if test "$actual" != $expected ; then if test "$actual" != $expected; then
log_info "dispatch is expected to fail with status $expected because of string2 is a required value but got status $actual instead" log_info "dispatch is expected to fail with status $expected because of string2 is a required value but got status $actual instead"
return 1 return 1
fi fi
@ -28,7 +28,7 @@ function verify_required() {
function verify_inputs() { function verify_inputs() {
local inputs='{"string2":"value2"}' local inputs='{"string2":"value2"}'
forgejo-curl.sh api_json --data '{"ref":"main","inputs":'$inputs'}' $api/repos/$repo/actions/workflows/test.yml/dispatches forgejo-curl.sh api_json --data '{"ref":"main","inputs":'$inputs'}' $api/repos/$repo/actions/workflows/test.yml/dispatches
cat > $TMPDIR/expected <<'EOF' cat >$TMPDIR/expected <<'EOF'
{ {
"boolean_default_false": "false", "boolean_default_false": "false",
"boolean_default_true": "true", "boolean_default_true": "true",
@ -46,7 +46,7 @@ function run_tests() {
npm --silent install json-diff npm --silent install json-diff
verify_inputs verify_inputs
context_wait context_wait
node_modules/.bin/json-diff <(jq .event.inputs < $context) $TMPDIR/expected node_modules/.bin/json-diff <(jq .event.inputs <$context) $TMPDIR/expected
} }
function main() { function main() {
@ -56,7 +56,7 @@ function main() {
run_tests run_tests
test "workflow_dispatch" = "$(jq -r .event_name < $context)" test "workflow_dispatch" = "$(jq -r .event_name <$context)"
} }
main main

View file

@ -11,7 +11,7 @@
# Everything happens in /tmp/forgejo-end-to-end # Everything happens in /tmp/forgejo-end-to-end
# #
SELF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" SELF_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SELF="${BASH_SOURCE[0]}" SELF="${BASH_SOURCE[0]}"
source $SELF_DIR/lib/lib.sh source $SELF_DIR/lib/lib.sh

View file

@ -1,16 +1,16 @@
# Copyright 2024 The Forgejo Authors # Copyright 2024 The Forgejo Authors
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
FEDERATION_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" FEDERATION_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
export FEDERATION_INSTANCES="ONE TWO" export FEDERATION_INSTANCES="ONE TWO"
export FEDERATION_CONFIGS export FEDERATION_CONFIGS
function federation_setup_variables() { function federation_setup_variables() {
if test "$FEDERATION_CONFIGS" ; then if test "$FEDERATION_CONFIGS"; then
return return
fi fi
for instance in $FEDERATION_INSTANCES ; do for instance in $FEDERATION_INSTANCES; do
local config=$FEDERATION_DIR/$instance-app.ini local config=$FEDERATION_DIR/$instance-app.ini
FEDERATION_CONFIGS="$FEDERATION_CONFIGS $config" FEDERATION_CONFIGS="$FEDERATION_CONFIGS $config"
local base=$(work_path_base $config) local base=$(work_path_base $config)
@ -29,7 +29,7 @@ function federation_verify_scenario() {
export scenario export scenario
export SCENARIO_DIR=$FEDERATION_DIR/scenario-$scenario export SCENARIO_DIR=$FEDERATION_DIR/scenario-$scenario
if test -f $SCENARIO_DIR/setup.sh ; then if test -f $SCENARIO_DIR/setup.sh; then
echo "============================ SETUP scenario-$scenario ===================" echo "============================ SETUP scenario-$scenario ==================="
bash -ex $SCENARIO_DIR/setup.sh || return 1 bash -ex $SCENARIO_DIR/setup.sh || return 1
fi fi
@ -37,7 +37,7 @@ function federation_verify_scenario() {
echo "============================ RUN scenario-$scenario ===================" echo "============================ RUN scenario-$scenario ==================="
bash -ex $SCENARIO_DIR/run.sh || return 1 bash -ex $SCENARIO_DIR/run.sh || return 1
if test -f $SCENARIO_DIR/teardown.sh ; then if test -f $SCENARIO_DIR/teardown.sh; then
echo "============================ TEARDOWN scenario-$scenario ===================" echo "============================ TEARDOWN scenario-$scenario ==================="
bash -ex $SCENARIO_DIR/teardown.sh || return 1 bash -ex $SCENARIO_DIR/teardown.sh || return 1
fi fi
@ -50,7 +50,7 @@ function federation_setup() {
federation_teardown federation_teardown
local config local config
for config in $FEDERATION_CONFIGS ; do for config in $FEDERATION_CONFIGS; do
reset_forgejo $config reset_forgejo $config
start_forgejo $version $config start_forgejo $version $config
done done
@ -60,7 +60,7 @@ function federation_teardown() {
federation_setup_variables federation_setup_variables
local config local config
for config in $FEDERATION_CONFIGS ; do for config in $FEDERATION_CONFIGS; do
stop_forgejo $config stop_forgejo $config
done done
} }
@ -71,15 +71,15 @@ function test_federation() {
local versions="${1:-$RELEASE_NUMBERS_AND_DEV}" local versions="${1:-$RELEASE_NUMBERS_AND_DEV}"
for version in $versions ; do for version in $versions; do
if dpkg --compare-versions $version lt 7.1 ; then if dpkg --compare-versions $version lt 7.1; then
continue continue
fi fi
federation_setup $version federation_setup $version
for scenario in star ; do for scenario in star; do
run federation_verify_scenario $scenario run federation_verify_scenario $scenario
done done
done done

View file

@ -9,9 +9,9 @@ function star_count() {
local host_port=$2 local host_port=$2
local count=$3 local count=$3
$curl api_json http://$host_port/api/v1/repos/root/test > $TMPDIR/count.json $curl api_json http://$host_port/api/v1/repos/root/test >$TMPDIR/count.json
if test $count != $(jq -r .stars_count < $TMPDIR/count.json) ; then if test $count != $(jq -r .stars_count <$TMPDIR/count.json); then
jq . < $TMPDIR/count.json jq . <$TMPDIR/count.json
return 1 return 1
fi fi
} }
@ -19,10 +19,10 @@ function star_count() {
# #
# create a repo on each instance # create a repo on each instance
# #
$ONE_CURL api_json --data '{"name":"test","auto_init":true}' $ONE_HOST_PORT/api/v1/user/repos > $TMPDIR/one-repo.json $ONE_CURL api_json --data '{"name":"test","auto_init":true}' $ONE_HOST_PORT/api/v1/user/repos >$TMPDIR/one-repo.json
one_repo_id=$(jq -r .id < $TMPDIR/one-repo.json) one_repo_id=$(jq -r .id <$TMPDIR/one-repo.json)
$TWO_CURL api_json --data '{"name":"test","auto_init":true}' $TWO_HOST_PORT/api/v1/user/repos > $TMPDIR/two-repo.json $TWO_CURL api_json --data '{"name":"test","auto_init":true}' $TWO_HOST_PORT/api/v1/user/repos >$TMPDIR/two-repo.json
two_repo_id=$(jq -r .id < $TMPDIR/two-repo.json) two_repo_id=$(jq -r .id <$TMPDIR/two-repo.json)
# #
# the repo in instance two is federated with the repo in instance one # the repo in instance two is federated with the repo in instance one

View file

@ -0,0 +1 @@

View file

@ -0,0 +1 @@

View file

@ -1,6 +1,6 @@
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
FIXTURES_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" FIXTURES_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source $FIXTURES_DIR/fixtures/storage.sh source $FIXTURES_DIR/fixtures/storage.sh
source $FIXTURES_DIR/fixtures/doctor.sh source $FIXTURES_DIR/fixtures/doctor.sh

View file

@ -15,7 +15,7 @@ function fixture_get_paths_s3() {
( (
mc ls --quiet --recursive testS3/$path | sed -e "s|.* |$path/|" mc ls --quiet --recursive testS3/$path | sed -e "s|.* |$path/|"
) > $DIR/path ) >$DIR/path
} }
function fixture_content_search_s3() { function fixture_content_search_s3() {
@ -23,13 +23,13 @@ function fixture_content_search_s3() {
local expected="$2" local expected="$2"
fixture_get_paths_s3 $path fixture_get_paths_s3 $path
if test $(wc -l < $DIR/path) -lt 1 ; then if test $(wc -l <$DIR/path) -lt 1; then
echo expected at least one but got "'$(cat $DIR/path)'" echo expected at least one but got "'$(cat $DIR/path)'"
return 1 return 1
fi fi
for filename in $(cat $DIR/path) ; do for filename in $(cat $DIR/path); do
local content=$(mc cat testS3/$filename | base64 -w0) local content=$(mc cat testS3/$filename | base64 -w0)
if test "$content" = "$expected" ; then if test "$content" = "$expected"; then
return 0 return 0
fi fi
done done
@ -41,7 +41,10 @@ function fixture_get_paths_local() {
local path=$1 local path=$1
local work_path=$DIR/forgejo-work-path local work_path=$DIR/forgejo-work-path
( cd $work_path ; find $path -type f) > $DIR/path (
cd $work_path
find $path -type f
) >$DIR/path
} }
function fixture_get_one_path() { function fixture_get_one_path() {
@ -50,7 +53,7 @@ function fixture_get_one_path() {
fixture_get_paths_$storage $path fixture_get_paths_$storage $path
if test $(wc -l < $DIR/path) != 1 ; then if test $(wc -l <$DIR/path) != 1; then
echo expected one path but got echo expected one path but got
cat $DIR/path cat $DIR/path
return 1 return 1
@ -77,7 +80,7 @@ function fixture_lfs_create() {
( (
cd $DIR/fixture cd $DIR/fixture
git lfs track "*.txt" git lfs track "*.txt"
echo CONTENT > file.txt echo CONTENT >file.txt
git add . git add .
git commit -m 'lfs files' git commit -m 'lfs files'
git push git push
@ -110,7 +113,7 @@ function fixture_lfs_assert_local() {
} }
function fixture_packages_create() { function fixture_packages_create() {
echo PACKAGE_CONTENT > $DIR/fixture/package echo PACKAGE_CONTENT >$DIR/fixture/package
forgejo-curl.sh api_json -X DELETE http://${HOST_PORT}/api/packages/${FORGEJO_USER}/generic/test_package/1.0.0/file.txt || true forgejo-curl.sh api_json -X DELETE http://${HOST_PORT}/api/packages/${FORGEJO_USER}/generic/test_package/1.0.0/file.txt || true
forgejo-curl.sh api_json --upload-file $DIR/fixture/package http://${HOST_PORT}/api/packages/${FORGEJO_USER}/generic/test_package/1.0.0/file.txt forgejo-curl.sh api_json --upload-file $DIR/fixture/package http://${HOST_PORT}/api/packages/${FORGEJO_USER}/generic/test_package/1.0.0/file.txt
} }
@ -128,7 +131,7 @@ function fixture_packages_assert_local() {
} }
function fixture_avatars_create() { function fixture_avatars_create() {
echo -n $ONEPIXEL | base64 --decode > $DIR/avatar.png echo -n $ONEPIXEL | base64 --decode >$DIR/avatar.png
forgejo-curl.sh web --form avatar=@$DIR/avatar.png http://${HOST_PORT}/user/settings/avatar forgejo-curl.sh web --form avatar=@$DIR/avatar.png http://${HOST_PORT}/user/settings/avatar
} }
@ -145,7 +148,7 @@ function fixture_avatars_assert_local() {
} }
function fixture_repo_avatars_create() { function fixture_repo_avatars_create() {
echo -n $ONEPIXEL | base64 --decode > $DIR/repo-avatar.png echo -n $ONEPIXEL | base64 --decode >$DIR/repo-avatar.png
forgejo-curl.sh web --form avatar=@$DIR/repo-avatar.png http://${HOST_PORT}/${FORGEJO_USER}/${FORGEJO_REPO}/settings/avatar forgejo-curl.sh web --form avatar=@$DIR/repo-avatar.png http://${HOST_PORT}/${FORGEJO_USER}/${FORGEJO_REPO}/settings/avatar
# v1.21 only # v1.21 only
#forgejo-curl.sh api_json -X POST --data-raw '{"body":"'$avatar'"}' http://${HOST_PORT}/api/v1/repos/${FORGEJO_USER}/${FORGEJO_REPO}/avatar #forgejo-curl.sh api_json -X POST --data-raw '{"body":"'$avatar'"}' http://${HOST_PORT}/api/v1/repos/${FORGEJO_USER}/${FORGEJO_REPO}/avatar
@ -166,17 +169,17 @@ function fixture_repo_avatars_assert_local() {
} }
function fixture_attachments_create_1_18() { function fixture_attachments_create_1_18() {
echo -n $ONEPIXEL | base64 --decode > $DIR/attachment.png echo -n $ONEPIXEL | base64 --decode >$DIR/attachment.png
forgejo-curl.sh web --trace-ascii - --form file=@$DIR/attachment.png http://${HOST_PORT}/${FORGEJO_USER}/${FORGEJO_REPO}/issues/attachments forgejo-curl.sh web --trace-ascii - --form file=@$DIR/attachment.png http://${HOST_PORT}/${FORGEJO_USER}/${FORGEJO_REPO}/issues/attachments
} }
function fixture_attachments_create() { function fixture_attachments_create() {
if forgejo-curl.sh api_json http://${HOST_PORT}/api/v1/version | grep --quiet --fixed-strings 1.18. ; then if forgejo-curl.sh api_json http://${HOST_PORT}/api/v1/version | grep --quiet --fixed-strings 1.18.; then
fixture_attachments_create_1_18 fixture_attachments_create_1_18
return return
fi fi
id=$(forgejo-curl.sh api_json --data-raw '{"title":"TITLE"}' http://${HOST_PORT}/api/v1/repos/${FORGEJO_USER}/${FORGEJO_REPO}/issues | jq .id) id=$(forgejo-curl.sh api_json --data-raw '{"title":"TITLE"}' http://${HOST_PORT}/api/v1/repos/${FORGEJO_USER}/${FORGEJO_REPO}/issues | jq .id)
echo -n $ONEPIXEL | base64 --decode > $DIR/attachment.png echo -n $ONEPIXEL | base64 --decode >$DIR/attachment.png
forgejo-curl.sh api --form name=attachment.png --form attachment=@$DIR/attachment.png http://${HOST_PORT}/api/v1/repos/${FORGEJO_USER}/${FORGEJO_REPO}/issues/$id/assets forgejo-curl.sh api --form name=attachment.png --form attachment=@$DIR/attachment.png http://${HOST_PORT}/api/v1/repos/${FORGEJO_USER}/${FORGEJO_REPO}/issues/$id/assets
} }
@ -206,18 +209,18 @@ function fixture_create() {
git remote add origin http://${FORGEJO_USER}:${FORGEJO_PASSWORD}@${HOST_PORT}/${FORGEJO_USER}/${FORGEJO_REPO} git remote add origin http://${FORGEJO_USER}:${FORGEJO_PASSWORD}@${HOST_PORT}/${FORGEJO_USER}/${FORGEJO_REPO}
git config user.email root@example.com git config user.email root@example.com
git config user.name username git config user.name username
echo SOMETHING > README echo SOMETHING >README
git add README git add README
git commit -m 'initial commit' git commit -m 'initial commit'
git push --set-upstream --force origin main git push --set-upstream --force origin main
) )
for fun in ${STORAGE_FUN} ; do for fun in ${STORAGE_FUN}; do
fixture_${fun}_create fixture_${fun}_create
done done
} }
function fixture_assert() { function fixture_assert() {
for fun in lfs ; do for fun in lfs; do
fixture_${fun}_assert fixture_${fun}_assert
done done
} }

View file

@ -14,7 +14,7 @@ function api_user_make_admin() {
function api_user_create() { function api_user_create() {
local api="$1" username="$2" email="$3" local api="$1" username="$2" email="$3"
log_info "(re)create user $username" log_info "(re)create user $username"
forgejo-curl.sh api_json -X DELETE $api/admin/users/$username?purge=true >& /dev/null || true forgejo-curl.sh api_json -X DELETE $api/admin/users/$username?purge=true >&/dev/null || true
forgejo-curl.sh api_json --data '{"username":"'$username'","email":"'$email'","password":"admin1234","must_change_password":false}' $api/admin/users forgejo-curl.sh api_json --data '{"username":"'$username'","email":"'$email'","password":"admin1234","must_change_password":false}' $api/admin/users
} }

View file

@ -4,16 +4,16 @@
set -ex set -ex
SELF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" SELF_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
version=$1 version=$1
dir_binaries=$2 dir_binaries=$2
v=$(echo $version | sed -E -e 's/^([0-9]+\.[0-9]+).*/\1/') v=$(echo $version | sed -E -e 's/^([0-9]+\.[0-9]+).*/\1/')
src=$dir_binaries/src-$v src=$dir_binaries/src-$v
read url ref semver < $SELF_DIR/../forgejo/sources/$v read url ref semver <$SELF_DIR/../forgejo/sources/$v
if ! test -d $src ; then if ! test -d $src; then
mkdir -p $src mkdir -p $src
cd $src cd $src
git init git init
@ -22,11 +22,11 @@ else
cd $src cd $src
fi fi
if ! [[ "$ref" =~ ^refs/ ]] ; then if ! [[ "$ref" =~ ^refs/ ]]; then
ref=refs/heads/$ref ref=refs/heads/$ref
fi fi
for retry in 1 2 3 ; do for retry in 1 2 3; do
if timeout 15m git fetch --update-head-ok origin +$ref:$ref ; then if timeout 15m git fetch --update-head-ok origin +$ref:$ref; then
break break
else else
echo "Retry git fetch in 60 seconds" echo "Retry git fetch in 60 seconds"

View file

@ -2,11 +2,11 @@
# Copyright 2024 The Forgejo Authors # Copyright 2024 The Forgejo Authors
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
LIB_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" LIB_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source $LIB_DIR/api.sh source $LIB_DIR/api.sh
if ${VERBOSE:-false} ; then if ${VERBOSE:-false}; then
set -ex set -ex
PS4='${BASH_SOURCE[0]}:$LINENO: ${FUNCNAME[0]}: ' PS4='${BASH_SOURCE[0]}:$LINENO: ${FUNCNAME[0]}: '
else else
@ -17,7 +17,7 @@ set -o pipefail
export DEBIAN_FRONTEND=noninteractive export DEBIAN_FRONTEND=noninteractive
if test $(id -u) != 0 ; then if test $(id -u) != 0; then
SUDO=sudo SUDO=sudo
fi fi
@ -35,7 +35,7 @@ export DOT_FORGEJO_CURL=$DIR/forgejo-curl
export DOT=$DOT_FORGEJO_CURL # for backward compatibility with forgejo-curl.sh 1.0.0 export DOT=$DOT_FORGEJO_CURL # for backward compatibility with forgejo-curl.sh 1.0.0
: ${FORGEJO_USER:=root} : ${FORGEJO_USER:=root}
: ${FORGEJO_PASSWORD:=admin1234} : ${FORGEJO_PASSWORD:=admin1234}
: ${RELEASE_NUMBERS_AND_DEV:="$(for r in $RELEASE_NUMBERS ; do echo -n "$r $r-dev " ; done)"} : ${RELEASE_NUMBERS_AND_DEV:="$(for r in $RELEASE_NUMBERS; do echo -n "$r $r-dev "; done)"}
ORGANIZATIONS=$(cat $LIB_DIR/ORGANIZATIONS) ORGANIZATIONS=$(cat $LIB_DIR/ORGANIZATIONS)
function log_info() { function log_info() {
@ -44,37 +44,37 @@ function log_info() {
function dependencies() { function dependencies() {
if ! test -f /usr/local/bin/forgejo-curl.sh ; then if ! test -f /usr/local/bin/forgejo-curl.sh; then
$SUDO curl --fail -sS https://code.forgejo.org/forgejo/forgejo-curl/raw/branch/main/forgejo-curl.sh -o /usr/local/bin/forgejo-curl.sh $SUDO curl --fail -sS https://code.forgejo.org/forgejo/forgejo-curl/raw/branch/main/forgejo-curl.sh -o /usr/local/bin/forgejo-curl.sh
$SUDO chmod +x /usr/local/bin/forgejo-curl.sh $SUDO chmod +x /usr/local/bin/forgejo-curl.sh
fi fi
if ! which make curl daemon git-lfs jq sqlite3 skopeo > /dev/null ; then if ! which make curl daemon git-lfs jq sqlite3 skopeo >/dev/null; then
$SUDO apt-get update -qq $SUDO apt-get update -qq
$SUDO apt-get install -y -qq make curl daemon git-lfs jq sqlite3 skopeo $SUDO apt-get install -y -qq make curl daemon git-lfs jq sqlite3 skopeo
fi fi
if ! test -f /usr/local/bin/mc || ! test -f /usr/local/bin/minio ; then if ! test -f /usr/local/bin/mc || ! test -f /usr/local/bin/minio; then
$SUDO curl --fail -sS https://dl.min.io/client/mc/release/linux-amd64/mc -o /usr/local/bin/mc $SUDO curl --fail -sS https://dl.min.io/client/mc/release/linux-amd64/mc -o /usr/local/bin/mc
$SUDO curl --fail -sS https://dl.min.io/server/minio/release/linux-amd64/minio -o /usr/local/bin/minio $SUDO curl --fail -sS https://dl.min.io/server/minio/release/linux-amd64/minio -o /usr/local/bin/minio
fi fi
if ! test -x /usr/local/bin/mc || ! test -x /usr/local/bin/minio ; then if ! test -x /usr/local/bin/mc || ! test -x /usr/local/bin/minio; then
$SUDO chmod +x /usr/local/bin/mc $SUDO chmod +x /usr/local/bin/mc
$SUDO chmod +x /usr/local/bin/minio $SUDO chmod +x /usr/local/bin/minio
fi fi
if ! test -f /usr/local/bin/garage > /dev/null ; then if ! test -f /usr/local/bin/garage >/dev/null; then
$SUDO curl --fail -sS https://garagehq.deuxfleurs.fr/_releases/v0.8.2/x86_64-unknown-linux-musl/garage -o /usr/local/bin/garage $SUDO curl --fail -sS https://garagehq.deuxfleurs.fr/_releases/v0.8.2/x86_64-unknown-linux-musl/garage -o /usr/local/bin/garage
fi fi
if ! test -x /usr/local/bin/garage > /dev/null ; then if ! test -x /usr/local/bin/garage >/dev/null; then
$SUDO chmod +x /usr/local/bin/garage $SUDO chmod +x /usr/local/bin/garage
fi fi
} }
function build_all() { function build_all() {
for dev in $RELEASE_NUMBERS ; do for dev in $RELEASE_NUMBERS; do
local forgejo=$DIR_BINARIES/forgejo-$dev-dev local forgejo=$DIR_BINARIES/forgejo-$dev-dev
if test -f $forgejo ; then if test -f $forgejo; then
log_info $dev already exists log_info $dev already exists
else else
$LIB_DIR/build.sh $dev $DIR_BINARIES $LIB_DIR/build.sh $dev $DIR_BINARIES
@ -86,8 +86,8 @@ function build_all() {
function retry() { function retry() {
rm -f $DIR/wait-for.out rm -f $DIR/wait-for.out
success=false success=false
for delay in 1 1 5 5 15 ; do for delay in 1 1 5 5 15; do
if "$@" >> $DIR/wait-for.out 2>&1 ; then if "$@" >>$DIR/wait-for.out 2>&1; then
success=true success=true
break break
fi fi
@ -95,7 +95,7 @@ function retry() {
echo waiting $delay echo waiting $delay
sleep $delay sleep $delay
done done
if test $success = false ; then if test $success = false; then
cat $DIR/wait-for.out cat $DIR/wait-for.out
return 1 return 1
fi fi
@ -105,7 +105,7 @@ function full_version() {
local version=$1 local version=$1
local owner=$2 local owner=$2
if [[ $version =~ ^[0-9]+\.[0-9]+$ ]] ; then if [[ $version =~ ^[0-9]+\.[0-9]+$ ]]; then
full_version=$(curl -sS "https://codeberg.org/api/v1/repos/$owner/forgejo/releases?limit=50" | jq -r '.[] | .tag_name | select(startswith("v'$version'"))' | sort --reverse --version-sort | head -1) full_version=$(curl -sS "https://codeberg.org/api/v1/repos/$owner/forgejo/releases?limit=50" | jq -r '.[] | .tag_name | select(startswith("v'$version'"))' | sort --reverse --version-sort | head -1)
echo ${full_version#v} echo ${full_version#v}
else else
@ -116,19 +116,19 @@ function full_version() {
function download_forgejo() { function download_forgejo() {
local version=$1 local version=$1
if ! test -f $DIR_BINARIES/forgejo-$version ; then if ! test -f $DIR_BINARIES/forgejo-$version; then
mkdir -p $DIR_BINARIES mkdir -p $DIR_BINARIES
for owner in $ORGANIZATIONS ; do for owner in $ORGANIZATIONS; do
full_version=$(full_version $version $owner) full_version=$(full_version $version $owner)
if test "$full_version" = "" ; then if test "$full_version" = ""; then
continue continue
fi fi
if wget -O $DIR_BINARIES/forgejo-$version --quiet https://codeberg.org/$owner/forgejo/releases/download/v$full_version/forgejo-$full_version-linux-amd64 ; then if wget -O $DIR_BINARIES/forgejo-$version --quiet https://codeberg.org/$owner/forgejo/releases/download/v$full_version/forgejo-$full_version-linux-amd64; then
break break
fi fi
done done
if test -s $DIR_BINARIES/forgejo-$version ; then if test -s $DIR_BINARIES/forgejo-$version; then
if test "$version" != "$full_version" ; then if test "$version" != "$full_version"; then
log_info "downloaded Forgejo $full_version for $version" log_info "downloaded Forgejo $full_version for $version"
fi fi
else else
@ -142,9 +142,9 @@ function download_forgejo() {
function download_gitea() { function download_gitea() {
local version=$1 local version=$1
if ! test -f $DIR_BINARIES/gitea-$version ; then if ! test -f $DIR_BINARIES/gitea-$version; then
mkdir -p $DIR_BINARIES mkdir -p $DIR_BINARIES
if [[ $version =~ ^[0-9]+\.[0-9]+$ ]] ; then if [[ $version =~ ^[0-9]+\.[0-9]+$ ]]; then
full_version=$(curl -sS "https://api.github.com/repos/go-gitea/gitea/releases?per_page=100" | jq -r '.[] | .tag_name | select(startswith("v'$version'"))' | grep -v -e '-rc' | sort --reverse --version-sort | head -1) full_version=$(curl -sS "https://api.github.com/repos/go-gitea/gitea/releases?per_page=100" | jq -r '.[] | .tag_name | select(startswith("v'$version'"))' | grep -v -e '-rc' | sort --reverse --version-sort | head -1)
full_version=${full_version#v} full_version=${full_version#v}
else else
@ -152,8 +152,8 @@ function download_gitea() {
fi fi
wget -O $DIR_BINARIES/gitea-$version --quiet https://dl.gitea.com/gitea/$full_version/gitea-$full_version-linux-amd64 wget -O $DIR_BINARIES/gitea-$version --quiet https://dl.gitea.com/gitea/$full_version/gitea-$full_version-linux-amd64
if test -s $DIR_BINARIES/gitea-$version ; then if test -s $DIR_BINARIES/gitea-$version; then
if test "$version" != "$full_version" ; then if test "$version" != "$full_version"; then
log_info "downloaded Gitea $full_version for $version" log_info "downloaded Gitea $full_version for $version"
fi fi
else else
@ -185,7 +185,7 @@ function clobber() {
function start_gitlab_cache_load() { function start_gitlab_cache_load() {
local image=$1 local image=$1
local d=$DIR_BINARIES/gitlab local d=$DIR_BINARIES/gitlab
if test -d $d ; then if test -d $d; then
log_info "loading $image from $d" log_info "loading $image from $d"
skopeo copy dir:$d docker-daemon:$image skopeo copy dir:$d docker-daemon:$image
fi fi
@ -194,7 +194,7 @@ function start_gitlab_cache_load() {
function start_gitlab_cache_save() { function start_gitlab_cache_save() {
local image=$1 local image=$1
local d=$DIR_BINARIES/gitlab local d=$DIR_BINARIES/gitlab
if ! test -d $d ; then if ! test -d $d; then
log_info "saving $image to $d" log_info "saving $image to $d"
skopeo copy docker-daemon:$image dir:$d skopeo copy docker-daemon:$image dir:$d
fi fi
@ -210,12 +210,12 @@ function start_gitlab() {
docker run --name="test-gitlab" --shm-size=128M -d \ docker run --name="test-gitlab" --shm-size=128M -d \
-e GITLAB_OMNIBUS_CONFIG="$GITLAB_OMNIBUS_CONFIG" \ -e GITLAB_OMNIBUS_CONFIG="$GITLAB_OMNIBUS_CONFIG" \
-p 2221:22 -p $GITLAB_PORT:8181 \ -p 2221:22 -p $GITLAB_PORT:8181 \
$image >& /dev/null < /dev/null $image >&/dev/null </dev/null
start_gitlab_cache_save $image start_gitlab_cache_save $image
for i in $(seq 10) ; do for i in $(seq 10); do
if test $(curl --silent http://$IP:$GITLAB_PORT -o /dev/null -w "%{http_code}") = 302 ; then if test $(curl --silent http://$IP:$GITLAB_PORT -o /dev/null -w "%{http_code}") = 302; then
docker exec test-gitlab gitlab-rails runner "user = User.find_by_username 'root'; user.password = '$GITLAB_PASSWORD'; user.password_confirmation = '$GITLAB_PASSWORD'; user.password_automatically_set = false ; user.save!" docker exec test-gitlab gitlab-rails runner "user = User.find_by_username 'root'; user.password = '$GITLAB_PASSWORD'; user.password_confirmation = '$GITLAB_PASSWORD'; user.password_automatically_set = false ; user.save!"
docker exec test-gitlab$serial gitlab-rails runner "Gitlab::CurrentSettings.current_application_settings.update(default_vcs_type: 'git')" docker exec test-gitlab$serial gitlab-rails runner "Gitlab::CurrentSettings.current_application_settings.update(default_vcs_type: 'git')"
log_info "GitLab is ready" log_info "GitLab is ready"
@ -263,12 +263,12 @@ function start_forgejo_daemon() {
local base=$(work_path_base $config) local base=$(work_path_base $config)
local work_path=$DIR/$base local work_path=$DIR/$base
daemon --chdir=$DIR --unsafe --env="TERM=$TERM" --env="HOME=$HOME" --env="PATH=$PATH" --pidfile=$DIR/$base-pid --errlog=$DIR/$base-err.log --output=$DIR/$base-out.log -- $binary --config $work_path/app.ini --work-path $work_path daemon --chdir=$DIR --unsafe --env="TERM=$TERM" --env="HOME=$HOME" --env="PATH=$PATH" --pidfile=$DIR/$base-pid --errlog=$DIR/$base-err.log --output=$DIR/$base-out.log -- $binary --config $work_path/app.ini --work-path $work_path
if ! retry grep --no-messages --quiet 'Starting server on' $work_path/log/forgejo.log ; then if ! retry grep --no-messages --quiet 'Starting server on' $work_path/log/forgejo.log; then
grep '' $DIR/$base*.log grep '' $DIR/$base*.log
grep '' $work_path/log/*.log 2> /dev/null grep '' $work_path/log/*.log 2>/dev/null
return 1 return 1
fi fi
echo "$binary --config $work_path/app.ini --work-path $work_path" '"$@"' > $work_path/forgejocli echo "$binary --config $work_path/app.ini --work-path $work_path" '"$@"' >$work_path/forgejocli
chmod +x $work_path/forgejocli chmod +x $work_path/forgejocli
cp -a $work_path/forgejocli $DIR/forgejocli # because setup-forgejo/forgejo-runner.sh expects it here cp -a $work_path/forgejocli $DIR/forgejocli # because setup-forgejo/forgejo-runner.sh expects it here
create_user_and_login $version $config create_user_and_login $version $config
@ -282,13 +282,13 @@ function start_minio() {
--env=MINIO_ROOT_PASSWORD=12345678 \ --env=MINIO_ROOT_PASSWORD=12345678 \
--env=MINIO_VOLUMES=$DIR/minio \ --env=MINIO_VOLUMES=$DIR/minio \
--pidfile=$DIR/minio-pid --errlog=$DIR/minio-err.log --output=$DIR/minio-out.log -- /usr/local/bin/minio server --pidfile=$DIR/minio-pid --errlog=$DIR/minio-err.log --output=$DIR/minio-out.log -- /usr/local/bin/minio server
retry mc alias set testS3 http://127.0.0.1:9000 123456 12345678 >& /dev/null retry mc alias set testS3 http://127.0.0.1:9000 123456 12345678 >&/dev/null
mc alias set testS3 http://127.0.0.1:9000 123456 12345678 mc alias set testS3 http://127.0.0.1:9000 123456 12345678
} }
function start_garage() { function start_garage() {
mkdir -p $DIR/garage/{data,meta} mkdir -p $DIR/garage/{data,meta}
cat > $DIR/garage/garage.toml <<EOF cat >$DIR/garage/garage.toml <<EOF
metadata_dir = "$DIR/garage/meta" metadata_dir = "$DIR/garage/meta"
data_dir = "$DIR/garage/data" data_dir = "$DIR/garage/data"
db_engine = "lmdb" db_engine = "lmdb"
@ -325,7 +325,7 @@ EOF
retry garage -c $DIR/garage/garage.toml status retry garage -c $DIR/garage/garage.toml status
garage -c $DIR/garage/garage.toml layout assign -z dc1 -c 1 $(garage -c $DIR/garage/garage.toml status | tail -1 | grep -o '[0-9a-z]*' | head -1) garage -c $DIR/garage/garage.toml layout assign -z dc1 -c 1 $(garage -c $DIR/garage/garage.toml status | tail -1 | grep -o '[0-9a-z]*' | head -1)
ver=$(garage -c $DIR/garage/garage.toml layout show | grep -oP '(?<=Current cluster layout version: )\d+') ver=$(garage -c $DIR/garage/garage.toml layout show | grep -oP '(?<=Current cluster layout version: )\d+')
garage -c $DIR/garage/garage.toml layout apply --version $((ver+1)) garage -c $DIR/garage/garage.toml layout apply --version $((ver + 1))
garage -c $DIR/garage/garage.toml key info test || garage -c $DIR/garage/garage.toml key import -n test 123456 12345678 garage -c $DIR/garage/garage.toml key info test || garage -c $DIR/garage/garage.toml key import -n test 123456 12345678
garage -c $DIR/garage/garage.toml key allow --create-bucket test garage -c $DIR/garage/garage.toml key allow --create-bucket test
retry mc alias set testS3 http://127.0.0.1:9000 123456 12345678 retry mc alias set testS3 http://127.0.0.1:9000 123456 12345678
@ -347,10 +347,10 @@ function start() {
function get_host_port() { function get_host_port() {
local config="$1" local config="$1"
if test -z "$config" ; then if test -z "$config"; then
echo "$IP:3000" echo "$IP:3000"
else else
echo "$IP:$(sed -n -e 's/^HTTP_PORT *= *\(.*\)/\1/p' < $config)" echo "$IP:$(sed -n -e 's/^HTTP_PORT *= *\(.*\)/\1/p' <$config)"
fi fi
} }
@ -358,10 +358,10 @@ HOST_PORT=$(get_host_port)
function work_path_base() { function work_path_base() {
local config="$1" local config="$1"
if test -z "$config" ; then if test -z "$config"; then
echo forgejo-work-path echo forgejo-work-path
else else
sed -n -e 's/^WORK_PATH *= *\(.*\)/\1/p' < $config sed -n -e 's/^WORK_PATH *= *\(.*\)/\1/p' <$config
fi fi
} }
@ -373,7 +373,7 @@ function reset_forgejo() {
sed -e "s/\${IP}/$IP/g" \ sed -e "s/\${IP}/$IP/g" \
-e "s|\${WORK_PATH}|$work_path|g" \ -e "s|\${WORK_PATH}|$work_path|g" \
-e "s|^WORK_PATH = .*|WORK_PATH = $work_path|" \ -e "s|^WORK_PATH = .*|WORK_PATH = $work_path|" \
< $config > $work_path/app.ini <$config >$work_path/app.ini
} }
function reset_minio() { function reset_minio() {
@ -391,19 +391,19 @@ function create_user_and_login() {
local work_path=$DIR/$(work_path_base $config) local work_path=$DIR/$(work_path_base $config)
local email="$FORGEJO_USER@example.com" local email="$FORGEJO_USER@example.com"
if ! $work_path/forgejocli admin user list | grep --quiet "$email" ; then if ! $work_path/forgejocli admin user list | grep --quiet "$email"; then
$work_path/forgejocli admin user create --admin --username "$FORGEJO_USER" --password "$FORGEJO_PASSWORD" --email $email $work_path/forgejocli admin user create --admin --username "$FORGEJO_USER" --password "$FORGEJO_PASSWORD" --email $email
fi fi
forgejo-curl.sh logout forgejo-curl.sh logout
local scopes='--scopes ["all"]' local scopes='--scopes ["all"]'
if echo $version | grep --quiet 1.18 ; then if echo $version | grep --quiet 1.18; then
scopes="" scopes=""
fi fi
forgejo-curl.sh --user "$FORGEJO_USER" --password "$FORGEJO_PASSWORD" $scopes login http://$(get_host_port $config) forgejo-curl.sh --user "$FORGEJO_USER" --password "$FORGEJO_PASSWORD" $scopes login http://$(get_host_port $config)
local forgejo_curl=$work_path/forgejo-curl.sh local forgejo_curl=$work_path/forgejo-curl.sh
cat > $forgejo_curl <<EOF cat >$forgejo_curl <<EOF
#!/bin/bash #!/bin/bash
export DOT_FORGEJO_CURL=$work_path/forgejo-curl export DOT_FORGEJO_CURL=$work_path/forgejo-curl
export DOT=$work_path/forgejo-curl # for backward compatibility with forgejo-curl.sh 1.0.0 export DOT=$work_path/forgejo-curl # for backward compatibility with forgejo-curl.sh 1.0.0
@ -416,12 +416,12 @@ EOF
function stop_daemon() { function stop_daemon() {
local daemon=$1 local daemon=$1
if test -f $DIR/$daemon-pid ; then if test -f $DIR/$daemon-pid; then
local pid=$(cat $DIR/$daemon-pid) local pid=$(cat $DIR/$daemon-pid)
kill -TERM $pid kill -TERM $pid
pidwait $pid || true pidwait $pid || true
for delay in 1 1 2 2 5 5 ; do for delay in 1 1 2 2 5 5; do
if ! test -f $DIR/$daemon-pid ; then if ! test -f $DIR/$daemon-pid; then
break break
fi fi
sleep $delay sleep $delay
@ -441,7 +441,7 @@ function stop() {
} }
function show_logs() { function show_logs() {
if ! test -d $DIR ; then if ! test -d $DIR; then
log_info "$DIR does not exist, no logs to display" log_info "$DIR does not exist, no logs to display"
return return
fi fi
@ -460,10 +460,10 @@ function run() {
echo Start running $fun "$@" echo Start running $fun "$@"
mkdir -p $DIR mkdir -p $DIR
> $DIR/$fun.out >$DIR/$fun.out
tail --follow $DIR/$fun.out |& sed --unbuffered -n -e "/^$PREFIX/s/^$PREFIX //p" & tail --follow $DIR/$fun.out |& sed --unbuffered -n -e "/^$PREFIX/s/^$PREFIX //p" &
local pid=$! local pid=$!
if ! VERBOSE=true $SELF $fun "$@" >& $DIR/$fun.out ; then if ! VERBOSE=true $SELF $fun "$@" >&$DIR/$fun.out; then
kill $pid kill $pid
cat $DIR/$fun.out cat $DIR/$fun.out
echo Failure running $fun echo Failure running $fun

View file

@ -38,8 +38,8 @@ for file in $(find . -name '*.apk' -type f | sed -e 's,./,,'); do
--fail \ --fail \
-H "Authorization: token $forgejo_token" \ -H "Authorization: token $forgejo_token" \
-X DELETE \ -X DELETE \
"$forgejo_url/api/packages/root/alpine/3.19/forgejo-2174/$file" \ "$forgejo_url/api/packages/root/alpine/3.19/forgejo-2174/$file" ||
|| true true
# upload new package # upload new package
curl \ curl \

View file

@ -41,8 +41,8 @@ for file in $(find . -name '*.apk' -type f | sed -e 's,./,,'); do
--fail \ --fail \
-H "Authorization: token $forgejo_token" \ -H "Authorization: token $forgejo_token" \
-X DELETE \ -X DELETE \
"$forgejo_url/api/packages/root/alpine/3.19/e2e-tests/$file" \ "$forgejo_url/api/packages/root/alpine/3.19/e2e-tests/$file" ||
|| true true
# upload new package # upload new package
curl \ curl \

View file

@ -16,8 +16,8 @@ function test_packages_alpine_version() {
} }
function test_packages_alpine() { function test_packages_alpine() {
for alpine_version in 3.18 3.19 ; do for alpine_version in 3.18 3.19; do
for forgejo_version in 1.21 7.0-test 7.0-dev ; do for forgejo_version in 1.21 7.0-test 7.0-dev; do
test_packages_alpine_version $alpine_version $forgejo_version test_packages_alpine_version $alpine_version $forgejo_version
done done
done done

View file

@ -1,6 +1,6 @@
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
STORAGE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" STORAGE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
STORAGE_PATHS="attachments avatars lfs packages repo-archive repo-avatars" STORAGE_PATHS="attachments avatars lfs packages repo-archive repo-avatars"
@ -14,7 +14,7 @@ function storage_reset() {
function verify_storage() { function verify_storage() {
local work_path=$DIR/forgejo-work-path local work_path=$DIR/forgejo-work-path
for path in ${STORAGE_PATHS} ; do for path in ${STORAGE_PATHS}; do
test -d $work_path/data/$path test -d $work_path/data/$path
done done
} }
@ -22,7 +22,7 @@ function verify_storage() {
function cleanup_storage() { function cleanup_storage() {
local work_path=$DIR/forgejo-work-path local work_path=$DIR/forgejo-work-path
for path in ${STORAGE_PATHS} ; do for path in ${STORAGE_PATHS}; do
rm -fr $work_path/data/$path rm -fr $work_path/data/$path
done done
} }
@ -33,13 +33,13 @@ function test_storage_stable_s3() {
log_info "See also https://codeberg.org/forgejo/forgejo/issues/1338" log_info "See also https://codeberg.org/forgejo/forgejo/issues/1338"
for version in 1.21 $RELEASE_NUMBERS_AND_DEV ; do for version in 1.21 $RELEASE_NUMBERS_AND_DEV; do
log_info "Forgejo $version & $s3_backend" log_info "Forgejo $version & $s3_backend"
stop stop
storage_reset stable-s3 storage_reset stable-s3
start $version $s3_backend start $version $s3_backend
fixture_create fixture_create
for fun in ${STORAGE_FUN} ; do for fun in ${STORAGE_FUN}; do
fixture_${fun}_assert_s3 fixture_${fun}_assert_s3
done done
done done

View file

@ -1,6 +1,6 @@
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
UPGRADE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" UPGRADE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
function upgrade_reset() { function upgrade_reset() {
local config=$1 local config=$1
@ -11,7 +11,7 @@ function upgrade_reset() {
function verify_storage() { function verify_storage() {
local work_path=$DIR/forgejo-work-path local work_path=$DIR/forgejo-work-path
for path in ${STORAGE_PATHS} ; do for path in ${STORAGE_PATHS}; do
test -d $work_path/data/$path test -d $work_path/data/$path
done done
} }
@ -19,14 +19,14 @@ function verify_storage() {
function cleanup_storage() { function cleanup_storage() {
local work_path=$DIR/forgejo-work-path local work_path=$DIR/forgejo-work-path
for path in ${STORAGE_PATHS} ; do for path in ${STORAGE_PATHS}; do
rm -fr $work_path/data/$path rm -fr $work_path/data/$path
done done
} }
function test_successful_upgrades() { function test_successful_upgrades() {
stop stop
for config in $UPGRADE_DIR/default-app.ini ; do for config in $UPGRADE_DIR/default-app.ini; do
log_info "using $config" log_info "using $config"
upgrade_reset $config upgrade_reset $config
@ -38,7 +38,7 @@ function test_successful_upgrades() {
fixture_assert fixture_assert
doctor_run $config doctor_run $config
for version in $RELEASE_NUMBERS_AND_DEV ; do for version in $RELEASE_NUMBERS_AND_DEV; do
stop stop
log_info "run $version" log_info "run $version"
start $version start $version
@ -55,7 +55,7 @@ function test_gitea_upgrades() {
echo gitea 1.21 forgejo 7.0-test echo gitea 1.21 forgejo 7.0-test
echo gitea 1.21 forgejo 8.0-test echo gitea 1.21 forgejo 8.0-test
echo gitea 1.22 forgejo 8.0-test echo gitea 1.22 forgejo 8.0-test
) | while read gitea gitea_version forgejo forgejo_version ; do ) | while read gitea gitea_version forgejo forgejo_version; do
log_info "upgrading from Gitea $gitea_version to Forgejo $forgejo_version" log_info "upgrading from Gitea $gitea_version to Forgejo $forgejo_version"
stop stop
upgrade_reset $config upgrade_reset $config