mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-23 03:22:19 +03:00
UBERF-8044: staging model version (#6492)
Signed-off-by: Alexey Zinoviev <alexey.zinoviev@xored.com>
This commit is contained in:
parent
04e93939f6
commit
743c88c30d
1
.github/workflows/main.yml
vendored
1
.github/workflows/main.yml
vendored
@ -40,6 +40,7 @@ env:
|
|||||||
.prettierrc
|
.prettierrc
|
||||||
tools
|
tools
|
||||||
PublishTempFolder: publish_artifacts
|
PublishTempFolder: publish_artifacts
|
||||||
|
MODEL_VERSION_MODE: ${{ startsWith(github.ref, 'refs/tags/s') && 'tagTime' || 'file' }}
|
||||||
|
|
||||||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
||||||
jobs:
|
jobs:
|
||||||
|
@ -15,12 +15,40 @@
|
|||||||
|
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
const exec = require('child_process').exec
|
||||||
|
|
||||||
|
function main (mode) {
|
||||||
|
exec('git describe --tags --abbrev=0', (err, stdout) => {
|
||||||
|
if (err !== null) {
|
||||||
|
console.log('"0.7.0"')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const tag = stdout.trim()
|
||||||
|
|
||||||
|
if (mode === 'tagTime') {
|
||||||
|
// Take tagged git commit date as model version
|
||||||
|
exec(`git for-each-ref --shell --format="%(creatordate:format:%s)" "refs/tags/${tag}"`, (err, stdout) => {
|
||||||
|
console.log(`"0.7.${err === null ? stdout.trim().slice(1, -1) : 0}"`)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
// Take version from file
|
||||||
|
let version
|
||||||
try {
|
try {
|
||||||
const versionFilePath = path.resolve(__dirname, 'version.txt')
|
const versionFilePath = path.resolve(__dirname, 'version.txt')
|
||||||
const version = fs.readFileSync(versionFilePath, 'utf8').trim()
|
version = fs.readFileSync(versionFilePath, 'utf8').trim()
|
||||||
|
} catch (error) {
|
||||||
|
version = '"0.6.0"'
|
||||||
|
}
|
||||||
|
|
||||||
console.log(version)
|
console.log(version)
|
||||||
} catch (error) {
|
|
||||||
console.log('0.6.0')
|
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
let mode = process.env.MODEL_VERSION_MODE
|
||||||
|
if (mode !== 'tagTime') {
|
||||||
|
mode = 'file'
|
||||||
|
}
|
||||||
|
|
||||||
|
main(mode)
|
||||||
|
@ -1480,21 +1480,19 @@ export async function getPendingWorkspace (
|
|||||||
? pendingUpgradeQuery
|
? pendingUpgradeQuery
|
||||||
: [...pendingCreationQuery, ...pendingUpgradeQuery]
|
: [...pendingCreationQuery, ...pendingUpgradeQuery]
|
||||||
}
|
}
|
||||||
let query: Filter<Workspace>
|
const attemptsQuery = { $or: [{ attempts: { $exists: false } }, { attempts: { $lte: 3 } }] }
|
||||||
|
|
||||||
if (region !== '') {
|
// We must have all the conditions in the DB query and we cannot filter anything in the code
|
||||||
query = {
|
// because of possible concurrency between account services. We have to update "lastProcessingTime"
|
||||||
...operationQuery,
|
// at the time of retrieval and not after some additional processing.
|
||||||
region
|
const query: Filter<Workspace> = {
|
||||||
|
$and: [
|
||||||
|
operationQuery,
|
||||||
|
attemptsQuery,
|
||||||
|
region !== '' ? { region } : defaultRegionQuery,
|
||||||
|
{ lastProcessingTime: { $lt: Date.now() - processingTimeoutMs } }
|
||||||
|
]
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
query = {
|
|
||||||
$and: [operationQuery, defaultRegionQuery]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
query.lastProcessingTime = { $lt: Date.now() - processingTimeoutMs }
|
|
||||||
query.attempts = { $lte: 3 }
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
(await wsCollection.findOneAndUpdate(
|
(await wsCollection.findOneAndUpdate(
|
||||||
|
Loading…
Reference in New Issue
Block a user