mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-12 13:13:45 +01:00
[migrations] only apply non-blocking migrations in CI (#34665)
* [migrations] only apply non-blocking migrations in CI * [migrations] use "yarn run migrations" instead of "npm run migrations" GitOrigin-RevId: d9f96db398adf2febcd82333295fb8d5eab741bb
This commit is contained in:
@@ -5,6 +5,6 @@ before('run migrations', async function () {
|
|||||||
this.timeout(60_000)
|
this.timeout(60_000)
|
||||||
|
|
||||||
await promisify(exec)(
|
await promisify(exec)(
|
||||||
`cd ../../tools/migrations && npm run migrations -- migrate -t server-ce`
|
`cd ../../tools/migrations && yarn run migrations migrate -t 'server-ce & !nonblocking'`
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -5,6 +5,6 @@ before('run migrations', async function () {
|
|||||||
this.timeout(60_000)
|
this.timeout(60_000)
|
||||||
|
|
||||||
await promisify(exec)(
|
await promisify(exec)(
|
||||||
`cd ../../tools/migrations && npm run migrations -- migrate -t server-ce`
|
`cd ../../tools/migrations && yarn run migrations migrate -t 'server-ce & !nonblocking'`
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -5,6 +5,6 @@ before('run migrations', async function () {
|
|||||||
this.timeout(60_000)
|
this.timeout(60_000)
|
||||||
|
|
||||||
await promisify(exec)(
|
await promisify(exec)(
|
||||||
`cd ../../tools/migrations && npm run migrations -- migrate -t server-ce`
|
`cd ../../tools/migrations && yarn run migrations migrate -t 'server-ce & !nonblocking'`
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ async function setupMongoDatabase() {
|
|||||||
this.timeout(60_000)
|
this.timeout(60_000)
|
||||||
await promisify(exec)(
|
await promisify(exec)(
|
||||||
// Run saas migrations for backup indexes
|
// Run saas migrations for backup indexes
|
||||||
`cd ../../tools/migrations && npm run migrations -- migrate -t saas`
|
`cd ../../tools/migrations && yarn run migrations migrate -t 'saas & !nonblocking'`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,6 @@ import { promisify } from 'node:util'
|
|||||||
|
|
||||||
beforeAll(async function () {
|
beforeAll(async function () {
|
||||||
await promisify(exec)(
|
await promisify(exec)(
|
||||||
`cd ../../tools/migrations && npm run migrations -- migrate -t server-ce`
|
`cd ../../tools/migrations && yarn run migrations migrate -t 'server-ce & !nonblocking'`
|
||||||
)
|
)
|
||||||
}, 60_000)
|
}, 60_000)
|
||||||
|
|||||||
@@ -5,6 +5,6 @@ before('run migrations', async function () {
|
|||||||
this.timeout(60_000)
|
this.timeout(60_000)
|
||||||
|
|
||||||
await promisify(exec)(
|
await promisify(exec)(
|
||||||
`cd ../../tools/migrations && npm run migrations -- migrate -t server-ce`
|
`cd ../../tools/migrations && yarn run migrations migrate -t 'server-ce & !nonblocking'`
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ test_unit_module: mongo_migrations_for_tests
|
|||||||
$(MAKE) modules/$(MODULE_NAME)/test_unit
|
$(MAKE) modules/$(MODULE_NAME)/test_unit
|
||||||
|
|
||||||
mongo_migrations_for_tests:
|
mongo_migrations_for_tests:
|
||||||
$(DOCKER_COMPOSE) run $(DC_RUN_FLAGS) --workdir /overleaf/tools/migrations test_unit yarn run migrations migrate -t saas
|
$(DOCKER_COMPOSE) run $(DC_RUN_FLAGS) --workdir /overleaf/tools/migrations test_unit yarn run migrations migrate -t 'saas & !nonblocking'
|
||||||
|
|
||||||
#
|
#
|
||||||
# Frontend tests
|
# Frontend tests
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export default {
|
|||||||
this.timeout(60_000)
|
this.timeout(60_000)
|
||||||
|
|
||||||
await promisify(exec)(
|
await promisify(exec)(
|
||||||
`cd ../../tools/migrations && npm run migrations -- migrate -t ${Settings.env || DEFAULT_ENV}`
|
`cd ../../tools/migrations && yarn run migrations migrate -t '${Settings.env || DEFAULT_ENV} & !nonblocking'`
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -8,10 +8,7 @@
|
|||||||
// 1 one or more blocking pending migrations - rollout must not proceed
|
// 1 one or more blocking pending migrations - rollout must not proceed
|
||||||
// 2 the check itself failed (e.g. Mongo unreachable) - fail closed
|
// 2 the check itself failed (e.g. Mongo unreachable) - fail closed
|
||||||
//
|
//
|
||||||
// A migration is non-blocking when either:
|
// A migration is non-blocking when it is tagged "nonblocking".
|
||||||
// - it is tagged "nonblocking" (preferred; safe to set on an already-applied migration), or
|
|
||||||
// - its filename ends with "_nonBlocking" before the extension,
|
|
||||||
// e.g. 20260101000000_backfill_thing_nonBlocking.mjs.
|
|
||||||
|
|
||||||
import path from 'node:path'
|
import path from 'node:path'
|
||||||
import { fileURLToPath } from 'node:url'
|
import { fileURLToPath } from 'node:url'
|
||||||
@@ -19,7 +16,6 @@ import east from 'east'
|
|||||||
|
|
||||||
const { MigrationManager } = east
|
const { MigrationManager } = east
|
||||||
|
|
||||||
const NON_BLOCKING_SUFFIX = '_nonBlocking'
|
|
||||||
const NON_BLOCKING_TAG = 'nonblocking'
|
const NON_BLOCKING_TAG = 'nonblocking'
|
||||||
const TAG = process.env.MIGRATION_TAG || 'saas'
|
const TAG = process.env.MIGRATION_TAG || 'saas'
|
||||||
|
|
||||||
@@ -46,20 +42,14 @@ async function findBlockingMigrations() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const pending = await manager.getMigrationNames({ status: 'new' })
|
const pending = await manager.getMigrationNames({ status: 'new' })
|
||||||
const candidates = pending.filter(
|
const blocking = pending.length
|
||||||
name => !name.endsWith(NON_BLOCKING_SUFFIX)
|
|
||||||
)
|
|
||||||
const nonBlocking = pending.filter(name =>
|
|
||||||
name.endsWith(NON_BLOCKING_SUFFIX)
|
|
||||||
)
|
|
||||||
const blocking = candidates.length
|
|
||||||
? await manager.getMigrationNames({
|
? await manager.getMigrationNames({
|
||||||
migrations: candidates,
|
migrations: pending,
|
||||||
tag: `${TAG} & !${NON_BLOCKING_TAG}`,
|
tag: `${TAG} & !${NON_BLOCKING_TAG}`,
|
||||||
})
|
})
|
||||||
: []
|
: []
|
||||||
|
|
||||||
return { pending, nonBlocking, blocking }
|
return { pending, blocking }
|
||||||
} finally {
|
} finally {
|
||||||
await manager.disconnect()
|
await manager.disconnect()
|
||||||
}
|
}
|
||||||
@@ -74,14 +64,7 @@ async function main() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
const { pending, nonBlocking, blocking } = await findBlockingMigrations()
|
const { pending, blocking } = await findBlockingMigrations()
|
||||||
|
|
||||||
if (nonBlocking.length) {
|
|
||||||
console.log(
|
|
||||||
`Ignoring ${nonBlocking.length} non-blocking pending migration(s):\n` +
|
|
||||||
nonBlocking.map(name => ` - ${name}`).join('\n')
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (blocking.length === 0) {
|
if (blocking.length === 0) {
|
||||||
console.log(
|
console.log(
|
||||||
@@ -96,8 +79,7 @@ async function main() {
|
|||||||
`${blocking.length} blocking pending "${TAG}" migration(s) must be applied before deploying:\n` +
|
`${blocking.length} blocking pending "${TAG}" migration(s) must be applied before deploying:\n` +
|
||||||
blocking.map(name => ` - ${name}`).join('\n') +
|
blocking.map(name => ` - ${name}`).join('\n') +
|
||||||
`\n\nApply them, then retry the rollout. To intentionally ship a non-blocking ` +
|
`\n\nApply them, then retry the rollout. To intentionally ship a non-blocking ` +
|
||||||
`migration, add the "${NON_BLOCKING_TAG}" tag (preferred — safe on already-applied ` +
|
`migration, add the "${NON_BLOCKING_TAG}" tag.`
|
||||||
`migrations) or rename the file with the "${NON_BLOCKING_SUFFIX}" suffix.`
|
|
||||||
)
|
)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user