From fed759ec0e7ce83b7b90a72490175ca3ad19d68e Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 31 Oct 2022 18:11:38 +0000 Subject: [PATCH] Allow the docker tag for the sliding sync proxy to be specified in env (#9496) --- cypress.config.ts | 4 ++++ cypress/plugins/sliding-sync/index.ts | 13 ++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/cypress.config.ts b/cypress.config.ts index bc64b7d726..87f8952dbc 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -30,6 +30,10 @@ export default defineConfig({ experimentalSessionAndOrigin: true, specPattern: 'cypress/e2e/**/*.{js,jsx,ts,tsx}', }, + env: { + // Docker tag to use for `ghcr.io/matrix-org/sliding-sync-proxy` image. + SLIDING_SYNC_PROXY_TAG: "v0.6.0", + }, retries: { runMode: 4, openMode: 0, diff --git a/cypress/plugins/sliding-sync/index.ts b/cypress/plugins/sliding-sync/index.ts index 608ada8dbf..44dcaecfcb 100644 --- a/cypress/plugins/sliding-sync/index.ts +++ b/cypress/plugins/sliding-sync/index.ts @@ -22,7 +22,8 @@ import { dockerExec, dockerIp, dockerRun, dockerStop } from "../docker"; import { getFreePort } from "../utils/port"; import { SynapseInstance } from "../synapsedocker"; -// A cypress plugins to add command to start & stop https://github.com/matrix-org/sliding-sync +// A cypress plugin to add command to start & stop https://github.com/matrix-org/sliding-sync +// SLIDING_SYNC_PROXY_TAG env used as the docker tag to use for `ghcr.io/matrix-org/sliding-sync-proxy` image. export interface ProxyInstance { containerId: string; @@ -34,7 +35,7 @@ const instances = new Map(); const PG_PASSWORD = "p4S5w0rD"; -async function proxyStart(synapse: SynapseInstance): Promise { +async function proxyStart(dockerTag: string, synapse: SynapseInstance): Promise { console.log(new Date(), "Starting sliding sync proxy..."); const postgresId = await dockerRun({ @@ -75,9 +76,9 @@ async function proxyStart(synapse: SynapseInstance): Promise { } const port = await getFreePort(); - console.log(new Date(), "starting proxy container..."); + console.log(new Date(), "starting proxy container...", dockerTag); const containerId = await dockerRun({ - image: "ghcr.io/matrix-org/sliding-sync-proxy:v0.6.0", + image: "ghcr.io/matrix-org/sliding-sync-proxy:" + dockerTag, containerName: "react-sdk-cypress-sliding-sync-proxy", params: [ "--rm", @@ -114,8 +115,10 @@ async function proxyStop(instance: ProxyInstance): Promise { * @type {Cypress.PluginConfig} */ export function slidingSyncProxyDocker(on: PluginEvents, config: PluginConfigOptions) { + const dockerTag = config.env["SLIDING_SYNC_PROXY_TAG"]; + on("task", { - proxyStart, + proxyStart: proxyStart.bind(null, dockerTag), proxyStop, });