diff --git a/federation/federation.sh b/federation/federation.sh index 95682c8c..4d7c09a5 100755 --- a/federation/federation.sh +++ b/federation/federation.sh @@ -79,6 +79,7 @@ function test_federation() { scenarios=( "star 7.1" "mastodon 14.0" + "gotosocial 14.0" ) for scenario_version_str in "${scenarios[@]}"; do diff --git a/federation/scenario-gotosocial/.gitignore b/federation/scenario-gotosocial/.gitignore new file mode 100644 index 00000000..e69de29b diff --git a/federation/scenario-gotosocial/run.sh b/federation/scenario-gotosocial/run.sh new file mode 100644 index 00000000..9fd57a7b --- /dev/null +++ b/federation/scenario-gotosocial/run.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +source "$DIR/federation_scenario-$scenario-env" + +if [[ -z "$password" ]]; then + exit 1 +fi + +if [[ -z "$port" ]]; then + exit 1 +fi + +status_code="$(curl -o /dev/null -w '%{http_code}' "http://localhost:$port/")" +if [[ "$status_code" != "200" ]]; then + exit 1 +fi diff --git a/federation/scenario-gotosocial/setup.sh b/federation/scenario-gotosocial/setup.sh new file mode 100644 index 00000000..13d97057 --- /dev/null +++ b/federation/scenario-gotosocial/setup.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +source $SCENARIO_DIR/../../lib/lib.sh + +GTS_VERSION="0.20.2" # renovate: datasource=docker depName=data.forgejo.org/oci/gotosocial + +echo "setting up gotosocial" + +tmpdir="$(mktemp --tmpdir -d gts.XXXXXXXXXX)" +cat << EOF > "$tmpdir/config.yaml" +host: "localhost:8080" +protocol: http +db-type: sqlite +db-address: /mount/gts.db3 + +http-client: + allow-ips: ["0.0.0.0/0", "::/0"] + insecure-outgoing: true +EOF + +podman unshare \ + chown 1000:1000 -R $tmpdir + +container_id="$( + podman run \ + -d \ + --env "GTS_CONFIG_PATH=/mount/config.yaml" \ + -v "$tmpdir:/mount" \ + -p "8080:8080" \ + --network=host \ + "data.forgejo.org/oci/gotosocial:$GTS_VERSION" \ + server start +)" + +function wait_gts_ready() { + http_status=$(curl -s -w \ + "%{http_code}" -o /dev/null \ + "http://localhost:8080/" + ) + + [[ "$http_status" == 200 ]] && echo "ready" +} + +retry wait_gts_ready + +password="verysecurepassword" +podman exec -it "$container_id" /gotosocial/gotosocial admin \ + account create \ + --username "test" \ + --email "test@localhost" \ + --password "$password" + +cat << EOF > "$DIR/federation_scenario-gotosocial-env" +password="$password" +port="8080" +container_id="$container_id" +EOF + diff --git a/federation/scenario-gotosocial/teardown.sh b/federation/scenario-gotosocial/teardown.sh new file mode 100644 index 00000000..6e6d556a --- /dev/null +++ b/federation/scenario-gotosocial/teardown.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +source "$DIR/federation_scenario-gotosocial-env" + +if [[ -z "$container_id" ]]; then + echo "gotosocial container ID not found, container may not be stopped" + exit 1 +fi + +podman stop "$container_id" +rm "$DIR/federation_scenario-gotosocial-env" + diff --git a/run.sh b/run.sh new file mode 100755 index 00000000..92a91611 --- /dev/null +++ b/run.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +podman build -t forgejo-e2e . +patchelf ../forgejo/forgejo --set-interpreter /lib64/ld-linux-x86-64.so.2 +podman run \ + -it --privileged \ + -v ../forgejo/gitea:/srv/forgejo-binaries/forgejo-14.0 \ + -p 3001-3003:3001-3003 \ + -p 4000:4000 \ + -p 8080:8080 \ + forgejo-e2e