screwdriver-data-schema 25.4.0 → 25.5.0

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.
@@ -0,0 +1,31 @@
1
+ /* eslint-disable new-cap */
2
+
3
+ 'use strict';
4
+
5
+ const prefix = process.env.DATASTORE_SEQUELIZE_PREFIX || '';
6
+ const table = `${prefix}events`;
7
+
8
+ module.exports = {
9
+ up: async (queryInterface, Sequelize) => {
10
+ await queryInterface.sequelize.transaction(async transaction => {
11
+ await queryInterface.addColumn(
12
+ table,
13
+ 'status',
14
+ {
15
+ type: Sequelize.STRING(10),
16
+ defaultValue: 'UNKNOWN',
17
+ allowNull: false
18
+ },
19
+ { transaction }
20
+ );
21
+
22
+ await queryInterface.removeIndex(table, `${table}_create_time_pipeline_id`, { transaction });
23
+
24
+ await queryInterface.addIndex(table, {
25
+ name: `${table}_create_time_pipeline_id_status`,
26
+ fields: ['createTime', 'pipelineId', 'status'],
27
+ transaction
28
+ });
29
+ });
30
+ }
31
+ };
package/models/event.js CHANGED
@@ -11,6 +11,14 @@ const parentBuilds = require('./build').get.extract('parentBuilds');
11
11
  const buildId = require('./build').get.extract('id');
12
12
  const prNum = Scm.hook.extract('prNum');
13
13
  const { QUALIFIED_STAGE_NAME } = require('../config/regex');
14
+ const STATUSES = [
15
+ 'UNKNOWN',
16
+ 'ABORTED', // when one or more builds associated with the event is aborted
17
+ 'CREATED', // when the event is created but none of the builds are created
18
+ 'FAILURE',
19
+ 'IN_PROGRESS', // when one or more incomplete (being executed or awaiting execution) builds exists
20
+ 'SUCCESS'
21
+ ];
14
22
 
15
23
  const MODEL = {
16
24
  id: Joi.number().integer().positive().description('Identifier of this event').example(123345),
@@ -62,7 +70,14 @@ const MODEL = {
62
70
  }),
63
71
  pr: Scm.pr.description('Pull request object that holds information about the pull request'),
64
72
  prNum: prNum.description('Pull request number if it is a PR event'),
65
- baseBranch: Joi.string().description('build base branch').example('develop')
73
+ baseBranch: Joi.string().description('build base branch').example('develop'),
74
+ status: Joi.string()
75
+ .valid(...STATUSES)
76
+ .max(10)
77
+ .description('Current status of the event')
78
+ .example('SUCCESS')
79
+ .default('UNKNOWN')
80
+ .required()
66
81
  };
67
82
 
68
83
  const CREATE_MODEL = { ...MODEL, buildId, parentBuildId, parentBuilds, prNum };
@@ -83,6 +98,14 @@ module.exports = {
83
98
  */
84
99
  base: Joi.object(MODEL).label('Event'),
85
100
 
101
+ /**
102
+ * All the available statuses of Build
103
+ *
104
+ * @property statuses
105
+ * @type {Array}
106
+ */
107
+ allStatuses: STATUSES,
108
+
86
109
  /**
87
110
  * All the available properties of Event
88
111
  *
@@ -100,7 +123,7 @@ module.exports = {
100
123
  get: Joi.object(
101
124
  mutate(
102
125
  MODEL,
103
- ['id', 'commit', 'createTime', 'creator', 'pipelineId', 'sha', 'type'],
126
+ ['id', 'commit', 'createTime', 'creator', 'pipelineId', 'sha', 'type', 'status'],
104
127
  [
105
128
  'causeMessage',
106
129
  'meta',
@@ -177,7 +200,7 @@ module.exports = {
177
200
  * @type {Array}
178
201
  */
179
202
  indexes: [
180
- { fields: ['createTime', 'pipelineId'] },
203
+ { fields: ['createTime', 'pipelineId', 'status'] },
181
204
  { fields: ['pipelineId'] },
182
205
  { fields: ['type'] },
183
206
  { fields: ['groupEventId'] },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "screwdriver-data-schema",
3
- "version": "25.4.0",
3
+ "version": "25.5.0",
4
4
  "description": "Internal Data Schema of Screwdriver",
5
5
  "main": "index.js",
6
6
  "scripts": {