screwdriver-data-schema 22.4.0 → 22.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/base.js +6 -2
- package/config/job.js +7 -1
- package/config/regex.js +2 -1
- package/core/scm.js +1 -1
- package/migrations/20221003-add_column_setup_teardown_startFrom_to_stage.js +52 -0
- package/migrations/20230328-initdb-stageBuilds.js +56 -0
- package/models/banner.js +2 -2
- package/models/build.js +1 -1
- package/models/buildCluster.js +1 -1
- package/models/collection.js +1 -1
- package/models/command.js +1 -1
- package/models/commandTag.js +1 -1
- package/models/event.js +1 -1
- package/models/index.js +2 -0
- package/models/pipeline.js +1 -1
- package/models/secret.js +1 -1
- package/models/stage.js +30 -3
- package/models/stageBuild.js +83 -0
- package/models/step.js +1 -1
- package/models/template.js +1 -1
- package/models/templateTag.js +1 -1
- package/models/token.js +1 -1
- package/models/trigger.js +1 -1
- package/models/user.js +1 -1
- package/package.json +7 -7
package/config/base.js
CHANGED
|
@@ -37,11 +37,14 @@ const SCHEMA_CHILD_PIPELINES = Joi.object()
|
|
|
37
37
|
startAll: Joi.boolean()
|
|
38
38
|
})
|
|
39
39
|
.unknown(false);
|
|
40
|
-
|
|
40
|
+
const SCHEMA_SETUP_TEARDOWN_JOB = Job.job.keys({ requires: Joi.forbidden() });
|
|
41
41
|
const SCHEMA_STAGE = Joi.object()
|
|
42
42
|
.keys({
|
|
43
43
|
description: Joi.string(),
|
|
44
|
-
jobs: Joi.array().items(Job.jobName).min(0)
|
|
44
|
+
jobs: Joi.array().items(Job.jobName).min(0),
|
|
45
|
+
setup: SCHEMA_SETUP_TEARDOWN_JOB,
|
|
46
|
+
teardown: SCHEMA_SETUP_TEARDOWN_JOB,
|
|
47
|
+
requires: Job.requires
|
|
45
48
|
})
|
|
46
49
|
.unknown(false);
|
|
47
50
|
|
|
@@ -86,6 +89,7 @@ module.exports = {
|
|
|
86
89
|
cachePerm: SCHEMA_CACHE_PERMUTATION,
|
|
87
90
|
childPipelines: SCHEMA_CHILD_PIPELINES,
|
|
88
91
|
config: SCHEMA_CONFIG,
|
|
92
|
+
stageSetupTeardownJob: SCHEMA_SETUP_TEARDOWN_JOB,
|
|
89
93
|
stage: SCHEMA_STAGE,
|
|
90
94
|
stages: SCHEMA_STAGES,
|
|
91
95
|
subscribe: SCHEMA_SUBSCRIBE
|
package/config/job.js
CHANGED
|
@@ -138,8 +138,14 @@ const SCHEMA_TEMPLATEID = Joi.number()
|
|
|
138
138
|
const SCHEMA_TRIGGER = sdJoi.string().branchFilter();
|
|
139
139
|
const SCHEMA_INTERNAL_TRIGGER = Joi.string().regex(Regex.INTERNAL_TRIGGER); // ~main, ~jobOne
|
|
140
140
|
const SCHEMA_EXTERNAL_TRIGGER = Joi.string().regex(Regex.EXTERNAL_TRIGGER_ALL).example('~sd@1234:component'); // ~sd@123:main or sd@123:main
|
|
141
|
+
const SCHEMA_STAGE_TRIGGER = Joi.string().regex(Regex.STAGE_TRIGGER); // ~stage@deploy, ~stage@deploy:main
|
|
141
142
|
const SCHEMA_CRON_EXPRESSION = sdCron.string().cron();
|
|
142
|
-
const SCHEMA_REQUIRES_VALUE = Joi.alternatives().try(
|
|
143
|
+
const SCHEMA_REQUIRES_VALUE = Joi.alternatives().try(
|
|
144
|
+
SCHEMA_INTERNAL_TRIGGER,
|
|
145
|
+
SCHEMA_JOBNAME,
|
|
146
|
+
SCHEMA_TRIGGER,
|
|
147
|
+
SCHEMA_STAGE_TRIGGER
|
|
148
|
+
);
|
|
143
149
|
const SCHEMA_REQUIRES = Joi.alternatives().try(Joi.array().items(SCHEMA_REQUIRES_VALUE), SCHEMA_REQUIRES_VALUE);
|
|
144
150
|
const SCHEMA_BLOCKEDBY_VALUE = Joi.alternatives().try(
|
|
145
151
|
SCHEMA_INTERNAL_TRIGGER,
|
package/config/regex.js
CHANGED
|
@@ -50,7 +50,8 @@ module.exports = {
|
|
|
50
50
|
INTERNAL_TRIGGER: /^~([\w-]+)$/,
|
|
51
51
|
// Stages can only be named with A-Z,a-z,0-9,-,_
|
|
52
52
|
STAGE_NAME: /^[\w-]+$/,
|
|
53
|
-
|
|
53
|
+
// Stage trigger like ~stage@deploy or ~stage@stageName:jobName
|
|
54
|
+
STAGE_TRIGGER: /^~stage@([\w-]+)(?::([\w-]+))?$/,
|
|
54
55
|
// Don't combine EXTERNAL_TRIGGER and EXTERNAL_TRIGGER_AND for backward compatibility
|
|
55
56
|
// BlockBy does not support EXTERNAL_TRIGGER_AND
|
|
56
57
|
// External trigger like ~sd@123:component (OR case)
|
package/core/scm.js
CHANGED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/* eslint-disable new-cap */
|
|
2
|
+
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
const prefix = process.env.DATASTORE_SEQUELIZE_PREFIX || '';
|
|
6
|
+
const table = `${prefix}stages`;
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
up: async (queryInterface, Sequelize) => {
|
|
10
|
+
await queryInterface.sequelize.transaction(async transaction => {
|
|
11
|
+
try {
|
|
12
|
+
await queryInterface.removeColumn(table, 'groupEventId');
|
|
13
|
+
|
|
14
|
+
await queryInterface.addColumn(
|
|
15
|
+
table,
|
|
16
|
+
'setup',
|
|
17
|
+
{
|
|
18
|
+
type: Sequelize.INTEGER
|
|
19
|
+
},
|
|
20
|
+
{ transaction }
|
|
21
|
+
);
|
|
22
|
+
await queryInterface.addColumn(
|
|
23
|
+
table,
|
|
24
|
+
'teardown',
|
|
25
|
+
{
|
|
26
|
+
type: Sequelize.INTEGER
|
|
27
|
+
},
|
|
28
|
+
{ transaction }
|
|
29
|
+
);
|
|
30
|
+
await queryInterface.addColumn(
|
|
31
|
+
table,
|
|
32
|
+
'archived',
|
|
33
|
+
{
|
|
34
|
+
type: Sequelize.BOOLEAN
|
|
35
|
+
},
|
|
36
|
+
{ transaction }
|
|
37
|
+
);
|
|
38
|
+
await queryInterface.removeConstraint(table, `${table}_pipeline_id_name_group_event_id_key`, {
|
|
39
|
+
transaction
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
await queryInterface.addConstraint(table, {
|
|
43
|
+
fields: ['pipelineId', 'name'],
|
|
44
|
+
name: `${table}_pipeline_id_name_key`,
|
|
45
|
+
type: 'unique',
|
|
46
|
+
transaction
|
|
47
|
+
});
|
|
48
|
+
// eslint-disable-next-line no-empty
|
|
49
|
+
} catch (e) {}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/* eslint-disable new-cap */
|
|
2
|
+
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
const prefix = process.env.DATASTORE_SEQUELIZE_PREFIX || '';
|
|
6
|
+
const table = `${prefix}stageBuilds`;
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
up: async (queryInterface, Sequelize) => {
|
|
10
|
+
await queryInterface.sequelize.transaction(async transaction => {
|
|
11
|
+
await queryInterface.createTable(
|
|
12
|
+
table,
|
|
13
|
+
{
|
|
14
|
+
id: {
|
|
15
|
+
allowNull: false,
|
|
16
|
+
autoIncrement: true,
|
|
17
|
+
primaryKey: true,
|
|
18
|
+
type: Sequelize.INTEGER.UNSIGNED
|
|
19
|
+
},
|
|
20
|
+
stageId: {
|
|
21
|
+
type: Sequelize.DOUBLE
|
|
22
|
+
},
|
|
23
|
+
status: {
|
|
24
|
+
type: Sequelize.TEXT
|
|
25
|
+
},
|
|
26
|
+
eventId: {
|
|
27
|
+
type: Sequelize.DOUBLE
|
|
28
|
+
},
|
|
29
|
+
workflowGraph: {
|
|
30
|
+
type: Sequelize.TEXT
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
{ transaction }
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
await queryInterface.addConstraint(table, {
|
|
37
|
+
name: `${table}_stage_id_event_id_key`,
|
|
38
|
+
fields: ['stageId', 'eventId'],
|
|
39
|
+
type: 'unique',
|
|
40
|
+
transaction
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
await queryInterface.addIndex(table, {
|
|
44
|
+
name: `${table}_stage_id`,
|
|
45
|
+
fields: ['stageId'],
|
|
46
|
+
transaction
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
await queryInterface.addIndex(table, {
|
|
50
|
+
name: `${table}_event_id`,
|
|
51
|
+
fields: ['eventId'],
|
|
52
|
+
transaction
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
};
|
package/models/banner.js
CHANGED
|
@@ -26,7 +26,7 @@ const MODEL = {
|
|
|
26
26
|
|
|
27
27
|
module.exports = {
|
|
28
28
|
/**
|
|
29
|
-
* All the available properties of
|
|
29
|
+
* All the available properties of Banner
|
|
30
30
|
*
|
|
31
31
|
* @property base
|
|
32
32
|
* @type {Joi}
|
|
@@ -34,7 +34,7 @@ module.exports = {
|
|
|
34
34
|
base: Joi.object(MODEL).label('Banner'),
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
|
-
* All the available properties of
|
|
37
|
+
* All the available properties of Banner
|
|
38
38
|
*
|
|
39
39
|
* @property fields
|
|
40
40
|
* @type {Object}
|
package/models/build.js
CHANGED
package/models/buildCluster.js
CHANGED
package/models/collection.js
CHANGED
package/models/command.js
CHANGED
package/models/commandTag.js
CHANGED
package/models/event.js
CHANGED
package/models/index.js
CHANGED
|
@@ -10,6 +10,7 @@ const pipeline = require('./pipeline');
|
|
|
10
10
|
const user = require('./user');
|
|
11
11
|
const secret = require('./secret');
|
|
12
12
|
const stage = require('./stage');
|
|
13
|
+
const stageBuild = require('./stageBuild');
|
|
13
14
|
const template = require('./template');
|
|
14
15
|
const templateTag = require('./templateTag');
|
|
15
16
|
const token = require('./token');
|
|
@@ -29,6 +30,7 @@ module.exports = {
|
|
|
29
30
|
user,
|
|
30
31
|
secret,
|
|
31
32
|
stage,
|
|
33
|
+
stageBuild,
|
|
32
34
|
template,
|
|
33
35
|
templateTag,
|
|
34
36
|
token,
|
package/models/pipeline.js
CHANGED
package/models/secret.js
CHANGED
package/models/stage.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const Joi = require('joi');
|
|
4
4
|
const Regex = require('../config/regex');
|
|
5
|
+
const mutate = require('../lib/mutate');
|
|
5
6
|
|
|
6
7
|
const MODEL = {
|
|
7
8
|
id: Joi.number().integer().positive().example(12345),
|
|
@@ -10,13 +11,21 @@ const MODEL = {
|
|
|
10
11
|
|
|
11
12
|
name: Joi.string().regex(Regex.STAGE_NAME).max(110).description('Name of the Stage').example('deploy'),
|
|
12
13
|
|
|
14
|
+
setup: Joi.array()
|
|
15
|
+
.items(Joi.number().integer().positive().description('Identifier for this job').example(123345))
|
|
16
|
+
.description('Job IDs in this Stage'),
|
|
17
|
+
|
|
18
|
+
teardown: Joi.array()
|
|
19
|
+
.items(Joi.number().integer().positive().description('Identifier for this job').example(123345))
|
|
20
|
+
.description('Job IDs in this Stage'),
|
|
21
|
+
|
|
13
22
|
jobIds: Joi.array()
|
|
14
23
|
.items(Joi.number().integer().positive().description('Identifier for this job').example(123345))
|
|
15
24
|
.description('Job IDs in this Stage'),
|
|
16
25
|
|
|
17
26
|
description: Joi.string().max(256).description('Description of the Stage').example('Deploys canary jobs'),
|
|
18
27
|
|
|
19
|
-
|
|
28
|
+
archived: Joi.boolean().description('Flag if the stage is archived').example(true).default(false)
|
|
20
29
|
};
|
|
21
30
|
|
|
22
31
|
module.exports = {
|
|
@@ -36,13 +45,31 @@ module.exports = {
|
|
|
36
45
|
*/
|
|
37
46
|
fields: MODEL,
|
|
38
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Properties for Stage that will come back during a GET request
|
|
50
|
+
*
|
|
51
|
+
* @property get
|
|
52
|
+
* @type {Joi}
|
|
53
|
+
*/
|
|
54
|
+
get: Joi.object(
|
|
55
|
+
mutate(MODEL, ['id', 'pipelineId', 'name', 'jobIds'], ['description', 'setup', 'teardown', 'archived'])
|
|
56
|
+
).label('Get Stage metadata'),
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Properties for Stage that will be passed during an UPDATE request
|
|
60
|
+
*
|
|
61
|
+
* @property update
|
|
62
|
+
* @type {Joi}
|
|
63
|
+
*/
|
|
64
|
+
update: Joi.object(mutate(MODEL, [], ['jobIds', 'description', 'setup', 'teardown'])).label('Update Stage'),
|
|
65
|
+
|
|
39
66
|
/**
|
|
40
67
|
* List of fields that determine a unique row
|
|
41
68
|
*
|
|
42
69
|
* @property keys
|
|
43
70
|
* @type {Array}
|
|
44
71
|
*/
|
|
45
|
-
keys: ['pipelineId', 'name'
|
|
72
|
+
keys: ['pipelineId', 'name'],
|
|
46
73
|
|
|
47
74
|
/**
|
|
48
75
|
* List of all fields in the model
|
|
@@ -65,5 +92,5 @@ module.exports = {
|
|
|
65
92
|
* @property indexes
|
|
66
93
|
* @type {Array}
|
|
67
94
|
*/
|
|
68
|
-
indexes: [{ fields: ['pipelineId'] }
|
|
95
|
+
indexes: [{ fields: ['pipelineId'] }]
|
|
69
96
|
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const Joi = require('joi');
|
|
4
|
+
const mutate = require('../lib/mutate');
|
|
5
|
+
const WorkflowGraph = require('../config/workflowGraph');
|
|
6
|
+
const status = require('./build').base.extract('status');
|
|
7
|
+
|
|
8
|
+
const MODEL = {
|
|
9
|
+
id: Joi.number().integer().positive().example(12345),
|
|
10
|
+
|
|
11
|
+
stageId: Joi.number().integer().positive().description('Stage associated with the Stage build').example(123345),
|
|
12
|
+
|
|
13
|
+
eventId: Joi.number().integer().positive().description('Identifier of the event').example(123345),
|
|
14
|
+
|
|
15
|
+
workflowGraph: WorkflowGraph.workflowGraph.description('Graph representation of the workflow').example({
|
|
16
|
+
nodes: [{ name: '~commit' }, { name: 'main' }, { name: 'publish' }],
|
|
17
|
+
edges: [
|
|
18
|
+
{ src: '~commit', dest: 'main' },
|
|
19
|
+
{ src: 'main', dest: 'publish' }
|
|
20
|
+
]
|
|
21
|
+
}),
|
|
22
|
+
|
|
23
|
+
status
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
module.exports = {
|
|
27
|
+
/**
|
|
28
|
+
* All the available properties of StageBuild
|
|
29
|
+
*
|
|
30
|
+
* @property base
|
|
31
|
+
* @type {Joi}
|
|
32
|
+
*/
|
|
33
|
+
base: Joi.object(MODEL).label('Stage Build'),
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* All the available properties of StageBuild
|
|
37
|
+
*
|
|
38
|
+
* @property fields
|
|
39
|
+
* @type {Object}
|
|
40
|
+
*/
|
|
41
|
+
fields: MODEL,
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Properties for StageBuild that will come back during a GET request
|
|
45
|
+
*
|
|
46
|
+
* @property get
|
|
47
|
+
* @type {Joi}
|
|
48
|
+
*/
|
|
49
|
+
get: Joi.object(mutate(MODEL, ['id', 'stageId', 'eventId'], ['workflowGraph', 'status'])).label(
|
|
50
|
+
'Get Stage Build metadata'
|
|
51
|
+
),
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* List of fields that determine a unique row
|
|
55
|
+
*
|
|
56
|
+
* @property keys
|
|
57
|
+
* @type {Array}
|
|
58
|
+
*/
|
|
59
|
+
keys: ['stageId', 'eventId'],
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* List of all fields in the model
|
|
63
|
+
* @property allKeys
|
|
64
|
+
* @type {Array}
|
|
65
|
+
*/
|
|
66
|
+
allKeys: Object.keys(MODEL),
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Tablename to be used in the datastore
|
|
70
|
+
*
|
|
71
|
+
* @property tableName
|
|
72
|
+
* @type {String}
|
|
73
|
+
*/
|
|
74
|
+
tableName: 'stageBuilds',
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* List of indexes to create in the datastore
|
|
78
|
+
*
|
|
79
|
+
* @property indexes
|
|
80
|
+
* @type {Array}
|
|
81
|
+
*/
|
|
82
|
+
indexes: [{ fields: ['stageId'] }, { fields: ['eventId'] }]
|
|
83
|
+
};
|
package/models/step.js
CHANGED
package/models/template.js
CHANGED
package/models/templateTag.js
CHANGED
package/models/token.js
CHANGED
package/models/trigger.js
CHANGED
package/models/user.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "screwdriver-data-schema",
|
|
3
|
-
"version": "22.4.
|
|
3
|
+
"version": "22.4.2",
|
|
4
4
|
"description": "Internal Data Schema of Screwdriver",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"url": "git+https://github.com/screwdriver-cd/data-schema.git"
|
|
14
14
|
},
|
|
15
15
|
"homepage": "https://github.com/screwdriver-cd/data-schema",
|
|
16
|
-
"bugs": "https://github.com/screwdriver-cd/
|
|
16
|
+
"bugs": "https://github.com/screwdriver-cd/screwdriver/issues",
|
|
17
17
|
"keywords": [
|
|
18
18
|
"screwdriver",
|
|
19
19
|
"yahoo"
|
|
@@ -39,23 +39,23 @@
|
|
|
39
39
|
"debug": false
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"chai": "^4.3.
|
|
43
|
-
"eslint": "^8.
|
|
42
|
+
"chai": "^4.3.7",
|
|
43
|
+
"eslint": "^8.28.0",
|
|
44
44
|
"eslint-config-screwdriver": "^7.0.0",
|
|
45
45
|
"js-yaml": "^4.1.0",
|
|
46
46
|
"mocha": "^10.1.0",
|
|
47
47
|
"mocha-multi-reporters": "^1.5.1",
|
|
48
48
|
"mocha-sonarqube-reporter": "^1.0.2",
|
|
49
49
|
"mysql2": "^1.7.0",
|
|
50
|
-
"npx": "^
|
|
50
|
+
"npx": "^3.0.0",
|
|
51
51
|
"nyc": "^15.1.0",
|
|
52
52
|
"pg": "^7.18.2",
|
|
53
|
-
"sequelize": "^6.25.
|
|
53
|
+
"sequelize": "^6.25.8",
|
|
54
54
|
"sequelize-cli": "^6.5.2",
|
|
55
55
|
"sqlite3": "^5.1.2"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"cron-parser": "^4.
|
|
58
|
+
"cron-parser": "^4.7.0",
|
|
59
59
|
"joi": "^17.7.0"
|
|
60
60
|
}
|
|
61
61
|
}
|