diff --git a/.dockerignore b/.dockerignore index 9aaa085..867223f 100644 --- a/.dockerignore +++ b/.dockerignore @@ -11,3 +11,4 @@ tests docs deploy/grafana deploy/prometheus +# (scripts/interop is used by the interop driver image) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 3615b1d..c2b47fa 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -77,10 +77,26 @@ jobs: - name: Dashboards are valid JSON run: for f in deploy/grafana/dashboards/*.json; do python3 -m json.tool "$f" > /dev/null; done + federation-interop: + # A real GoToSocial server follows a Scrobbler user (see scripts/interop/run.sh). + # Not for pull requests from forks: it runs containers on the runner's Docker. + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository + runs-on: ubuntu-latest + timeout-minutes: 20 + steps: + - uses: actions/checkout@v4 + - name: Scrobbler <-> GoToSocial + env: + INTEROP_PROJECT: interop-${{ github.run_id }} + run: | + # A subnet of its own, so concurrent runs can't collide + export INTEROP_SUBNET="172.30.$(( ${{ github.run_number }} % 200 + 20 )).0/24" + scripts/interop/run.sh + # ---- Publishing (main and v* tags only) ------------------------------------- images: - needs: [lint, test, validate-monitoring] + needs: [lint, test, validate-monitoring, federation-interop] if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) runs-on: ubuntu-latest outputs: @@ -123,7 +139,7 @@ jobs: run: docker logout "${{ vars.PKGS_HOST }}" || true assets: - needs: [lint, test, validate-monitoring] + needs: [lint, test, validate-monitoring, federation-interop] if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) runs-on: ubuntu-latest steps: @@ -147,7 +163,7 @@ jobs: done python-package: - needs: [lint, test, validate-monitoring] + needs: [lint, test, validate-monitoring, federation-interop] if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') runs-on: ubuntu-latest steps: @@ -164,7 +180,7 @@ jobs: --username api --password "${{ secrets.PKGS_API_KEY }}" notify: - needs: [lint, test, validate-monitoring, images, assets, python-package] + needs: [lint, test, validate-monitoring, federation-interop, images, assets, python-package] if: always() runs-on: ubuntu-latest steps: diff --git a/deploy/interop/docker-compose.interop.yml b/deploy/interop/docker-compose.interop.yml index 6e17017..c6bd88d 100644 --- a/deploy/interop/docker-compose.interop.yml +++ b/deploy/interop/docker-compose.interop.yml @@ -22,11 +22,12 @@ networks: fedi: ipam: config: - - subnet: 172.30.0.0/24 + - subnet: ${INTEROP_SUBNET:-172.30.0.0/24} services: db: ports: !reset [] + volumes: !reset [db-data:/var/lib/postgresql/data] # no bind mounts (CI) networks: [fedi] api: @@ -62,9 +63,9 @@ services: GTS_PORT: "80" GTS_DB_TYPE: sqlite GTS_DB_ADDRESS: /gotosocial/storage/sqlite.db - GTS_HTTP_CLIENT_ALLOW_IPS: 172.30.0.0/24 # let it reach Scrobbler on this network + GTS_HTTP_CLIENT_ALLOW_IPS: ${INTEROP_SUBNET:-172.30.0.0/24} # let it reach Scrobbler on this network GTS_HTTP_CLIENT_TLS_INSECURE_SKIP_VERIFY: "true" # Caddy's throwaway certificate - GTS_TRUSTED_PROXIES: 172.30.0.0/24 + GTS_TRUSTED_PROXIES: ${INTEROP_SUBNET:-172.30.0.0/24} GTS_ACCOUNTS_REGISTRATION_OPEN: "false" GTS_LOG_LEVEL: ${GTS_LOG_LEVEL:-info} sysctls: @@ -74,9 +75,10 @@ services: aliases: [gts.test] driver: - image: python:3.13-slim + build: + context: . + dockerfile: deploy/interop/driver.Dockerfile profiles: [driver] - volumes: - - ./scripts/interop:/interop:ro # relative to the project (first compose file) - command: ["python", "/interop/gotosocial_interop.py"] + environment: + GTS_REJECT_ENDS_FOLLOWS: ${GTS_REJECT_ENDS_FOLLOWS:-0} networks: [fedi] diff --git a/deploy/interop/driver.Dockerfile b/deploy/interop/driver.Dockerfile new file mode 100644 index 0000000..618750c --- /dev/null +++ b/deploy/interop/driver.Dockerfile @@ -0,0 +1,5 @@ +# The interop test driver: the script baked in (CI runners can't bind-mount the workspace +# into sibling containers). +FROM python:3.13-slim +COPY scripts/interop/gotosocial_interop.py /interop/gotosocial_interop.py +CMD ["python", "/interop/gotosocial_interop.py"] diff --git a/scripts/interop/compose.sh b/scripts/interop/compose.sh index 9674de8..7884744 100755 --- a/scripts/interop/compose.sh +++ b/scripts/interop/compose.sh @@ -2,4 +2,6 @@ # docker compose for the federation interop stack (Scrobbler + GoToSocial). set -euo pipefail root="$(cd "$(dirname "$0")/../.." && pwd)" -exec docker compose -f "$root/docker-compose.yml" -f "$root/deploy/interop/docker-compose.interop.yml" "$@" +# INTEROP_PROJECT and INTEROP_SUBNET let concurrent runs (e.g. in CI) stay apart. +exec docker compose -p "${INTEROP_PROJECT:-scrobbler-interop}" \ + -f "$root/docker-compose.yml" -f "$root/deploy/interop/docker-compose.interop.yml" "$@" diff --git a/scripts/interop/run.sh b/scripts/interop/run.sh index 3bfa33b..0600cbb 100755 --- a/scripts/interop/run.sh +++ b/scripts/interop/run.sh @@ -24,6 +24,7 @@ echo "==> Creating the GoToSocial test user" --username gtsuser --email gtsuser@gts.test --password 'Interop-Test-Password-1' >/dev/null "$compose" exec -T gotosocial /gotosocial/gotosocial admin account confirm --username gtsuser >/dev/null +"$compose" build driver >/dev/null "$compose" run --rm driver status=$? if [ $status -ne 0 ]; then