diff --git a/.github/workflows/build-and-test.yaml b/.github/workflows/build-and-test.yaml index a8b7c0f8e8..e367a64450 100644 --- a/.github/workflows/build-and-test.yaml +++ b/.github/workflows/build-and-test.yaml @@ -208,9 +208,6 @@ jobs: - name: Install dependencies run: pnpm install --frozen-lockfile - - name: Build modules - run: pnpm -r --workspace-concurrency=1 --filter "./modules/**" run build - - name: Setup playwright uses: ./.github/actions/setup-playwright with: diff --git a/modules/project.json b/modules/project.json index 7f65e1cf91..0d7a172ea8 100644 --- a/modules/project.json +++ b/modules/project.json @@ -1,16 +1,17 @@ { "$schema": "../node_modules/nx/schemas/project-schema.json", "projectType": "library", + "implicitDependencies": ["modules/*"], "targets": { "test:playwright": { "command": "playwright test", "options": { "cwd": "modules" }, - "dependsOn": ["^build:playwright"] + "dependsOn": ["^build:playwright", "^build"] }, "test:playwright:screenshots": { "command": "playwright-screenshots playwright test --update-snapshots --grep @screenshot", "options": { "cwd": "modules" }, - "dependsOn": ["^build:playwright"] + "dependsOn": ["^build:playwright", "^build"] } } } diff --git a/modules/restricted-guests/e2e/services.ts b/modules/restricted-guests/e2e/services.ts index 8122e671b3..f99b15f950 100644 --- a/modules/restricted-guests/e2e/services.ts +++ b/modules/restricted-guests/e2e/services.ts @@ -9,10 +9,8 @@ import { StartedSynapseContainer, SynapseContainer, } from "@element-hq/element-web-playwright-common/lib/testcontainers/index.js"; -import path, { dirname } from "node:path"; -import { fileURLToPath } from "node:url"; - -const __dirname = dirname(fileURLToPath(import.meta.url)); +import { Readable } from "node:stream"; +import { GenericContainer, Wait } from "testcontainers"; // We use the SynapseContainer as a base to have all of its utilities for config setting export class RestrictedGuestsSynapseContainer extends SynapseContainer { @@ -21,14 +19,22 @@ export class RestrictedGuestsSynapseContainer extends SynapseContainer { } public override async start(): Promise { - this.withCopyDirectoriesToContainer([ + // Download the synapse module + const initContainer = await new GenericContainer("ghcr.io/element-hq/synapse-guest-module:861f7ee") + .withWaitStrategy(Wait.forOneShotStartup()) + .start(); + const tarStream = await initContainer.copyArchiveFromContainer(`/src/synapse_guest_module`); + await initContainer.stop(); + + this.withCopyArchivesToContainer([ { - source: path.resolve(__dirname, "..", "..", "synapse", "synapse_guest_module"), - target: "/modules/synapse_guest_module/", + tar: Readable.from(tarStream), + target: "/", }, ]).withEnvironment({ PYTHONPATH: "/modules", }); + this.config.modules.push({ module: "synapse_guest_module.GuestModule", config: this.getModuleConfig(), diff --git a/modules/restricted-guests/package.json b/modules/restricted-guests/package.json index 842dbf10cc..1b84b13fe8 100644 --- a/modules/restricted-guests/package.json +++ b/modules/restricted-guests/package.json @@ -16,6 +16,7 @@ "@types/react": "catalog:", "@vitejs/plugin-react": "catalog:", "react": "catalog:", + "testcontainers": "^12.0.1", "typescript": "catalog:", "vite": "catalog:", "vite-plugin-node-polyfills": "catalog:" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f0cba11811..6c6795a1ec 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1219,6 +1219,9 @@ importers: react: specifier: 'catalog:' version: 19.2.6 + testcontainers: + specifier: ^12.0.1 + version: 12.0.1 typescript: specifier: 'catalog:' version: 6.0.3