diff --git a/packages/builder/cypress/setup.js b/packages/builder/cypress/setup.js index 4ad8e5287d..1a6f1d5b2b 100644 --- a/packages/builder/cypress/setup.js +++ b/packages/builder/cypress/setup.js @@ -23,6 +23,7 @@ process.env.MINIO_SECRET_KEY = "budibase" process.env.COUCH_DB_USER = "budibase" process.env.COUCH_DB_PASSWORD = "budibase" process.env.INTERNAL_API_KEY = "budibase" +process.env.ALLOW_DEV_AUTOMATIONS = 1 // Stop info logs polluting test outputs process.env.LOG_LEVEL = "error" diff --git a/packages/server/src/automations/triggers.js b/packages/server/src/automations/triggers.js index d90511c7ba..ae98f0e73a 100644 --- a/packages/server/src/automations/triggers.js +++ b/packages/server/src/automations/triggers.js @@ -8,6 +8,7 @@ const { isDevAppID } = require("../db/utils") const { queue } = require("./bullboard") const { checkTestFlag } = require("../utilities/redis") const utils = require("./utils") +const env = require("../environment") const TRIGGER_DEFINITIONS = definitions @@ -30,21 +31,24 @@ async function queueRelevantRowAutomations(event, eventType) { }) for (let automation of automations) { - // don't queue events which are for dev apps, only way to test automations is - // running tests on them - // in production the test flag will never be checked due to lazy evaluation (first always false) - if (isDevAppID(event.appId) && !(await checkTestFlag(automation._id))) { - return - } let automationDef = automation.definition let automationTrigger = automationDef ? automationDef.trigger : {} + // don't queue events which are for dev apps, only way to test automations is + // running tests on them, in production the test flag will never + // be checked due to lazy evaluation (first always false) if ( - !automationTrigger.inputs || - automationTrigger.inputs.tableId !== event.row.tableId + !env.ALLOW_DEV_AUTOMATIONS && + isDevAppID(event.appId) && + !(await checkTestFlag(automation._id)) ) { continue } - await queue.add({ automation, event }) + if ( + automationTrigger.inputs && + automationTrigger.inputs.tableId === event.row.tableId + ) { + await queue.add({ automation, event }) + } } } diff --git a/packages/server/src/environment.js b/packages/server/src/environment.js index 9f69664ffb..9e029e440a 100644 --- a/packages/server/src/environment.js +++ b/packages/server/src/environment.js @@ -55,6 +55,7 @@ module.exports = { BUDIBASE_API_KEY: process.env.BUDIBASE_API_KEY, USERID_API_KEY: process.env.USERID_API_KEY, DEPLOYMENT_CREDENTIALS_URL: process.env.DEPLOYMENT_CREDENTIALS_URL, + ALLOW_DEV_AUTOMATIONS: process.env.ALLOW_DEV_AUTOMATIONS, _set(key, value) { process.env[key] = value module.exports[key] = value