Skip to content

Commit

Permalink
feat(3171): Persist pipeline template workflowGraph in a new column (…
Browse files Browse the repository at this point in the history
…BREAKING CHANGE) (#575)
  • Loading branch information
sagar1312 authored Aug 29, 2024
1 parent 682ad4e commit cbd563a
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 18 deletions.
4 changes: 1 addition & 3 deletions config/pipelineTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const Annotations = require('./annotations');
const Parameters = require('./parameters');
const Template = require('./template');
const Regex = require('./regex');
const WorkflowGraph = require('./workflowGraph');

const SCHEMA_CONFIG = Joi.object()
.keys({
Expand All @@ -16,8 +15,7 @@ const SCHEMA_CONFIG = Joi.object()
annotations: Annotations.annotations,
cache: BaseSchema.cache,
subscribe: BaseSchema.subscribe,
stages: BaseSchema.stages,
workflowGraph: WorkflowGraph.workflowGraph
stages: BaseSchema.stages
})
.unknown(false);

Expand Down
4 changes: 2 additions & 2 deletions migrations/20220607152947-add_column_state_to_pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ module.exports = {
table,
'state',
{
type: Sequelize.STRING(10),
defaultValue: 'ACTIVE',
type: Sequelize.TEXT,
defaultValue: '{}',
allowNull: false
},
{ transaction }
Expand Down
11 changes: 8 additions & 3 deletions models/pipelineTemplateVersions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const Joi = require('joi');
const mutate = require('../lib/mutate');
const pipelineTemplateVersions = require('../config/pipelineTemplate');
const JobTemplateConfig = require('../config/template');
const WorkflowGraph = require('../config/workflowGraph');
const templateId = require('./templateMeta').base.extract('id');

const MODEL = {
Expand All @@ -17,6 +18,10 @@ const MODEL = {
.max(32)
.description('When this template was created')
.example('2038-01-19T03:14:08.131Z')
.required(),
workflowGraph: WorkflowGraph.workflowGraph
.description('Graph representation of the workflow')
.default('{"nodes": [],"edges":[]}')
.required()
};

Expand All @@ -43,9 +48,9 @@ module.exports = {
* @property get
* @type {Joi}
*/
get: Joi.object(mutate(MODEL, ['id', 'templateId', 'version'], ['description', 'config', 'createTime'])).label(
'Get Template'
),
get: Joi.object(
mutate(MODEL, ['id', 'templateId', 'version'], ['description', 'config', 'createTime', 'workflowGraph'])
).label('Get Template'),

/**
* List of fields that determine a unique row
Expand Down
20 changes: 10 additions & 10 deletions test/data/pipelineTemplateVersions.get.allFields.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ config:
user:
value: sd-bot
description: User running build
workflowGraph:
nodes:
- name: ~commit
- name: main
- name: publish
edges:
- src: ~commit
dest: main
- src: main
dest: publish
workflowGraph:
nodes:
- name: ~commit
- name: main
- name: publish
edges:
- src: ~commit
dest: main
- src: main
dest: publish

createTime: "2038-01-19T03:14:08.131Z"
11 changes: 11 additions & 0 deletions test/data/pipelineTemplateVersions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,15 @@ config:
steps:
- init: npm install
- test: npm test
publish:
steps:
- init: npm install
- publish: npm publish
workflowGraph:
nodes:
- name: main
- name: publish
edges:
- src: main
dest: publish
createTime: "2038-01-19T03:14:08.131Z"

0 comments on commit cbd563a

Please sign in to comment.