Skip to content

Commit

Permalink
fix(3106): Allow shared.requires for pipeline template yaml (#565)
Browse files Browse the repository at this point in the history
  • Loading branch information
tkyi committed May 31, 2024
1 parent cc3244b commit 0530a47
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
3 changes: 2 additions & 1 deletion config/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ const SCHEMA_CONFIG_PRE_TEMPLATE_MERGE = Joi.object()
then: Joi.object().keys({
image: Job.image,
environment: Job.environment,
settings: Job.settings
settings: Job.settings,
requires: Job.requires
}),
otherwise: SCHEMA_SHARED
}),
Expand Down
8 changes: 7 additions & 1 deletion test/config/base.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,18 @@ describe('config base', () => {
assert.isNull(validate('config.base.pipelineTemplate.yaml', config.base.configBeforeMergingTemplate).error);
});

it('if template is provided then unsupported fields are foridden', () => {
it('if template is provided then unsupported fields are forbidden', () => {
assert.isNotNull(
validate('config.base.pipelineTemplate-forbidden.yaml', config.base.configBeforeMergingTemplate).error
);
});

it('if template is provided then allow user yaml to customize image, settings, environment, and requires', () => {
assert.isNull(
validate('config.base.pipelineTemplate-customized.yaml', config.base.configBeforeMergingTemplate).error
);
});

it('if template is not provided then job is required', () => {
assert.isNotNull(
validate('config.base.pipelineTemplate-invalid.yaml', config.base.configBeforeMergingTemplate).error
Expand Down
8 changes: 8 additions & 0 deletions test/data/config.base.pipelineTemplate-customized.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
template: foo/bar@1.0.0
shared:
image: node:20
environment:
FOO: user overwrite
settings:
email: foo@example.com
requires: ~commit
1 change: 1 addition & 0 deletions test/data/config.base.pipelineTemplate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ shared:
FOO: user overwrite
settings:
email: foo@example.com
requires: ~commit
cache:
pipeline: ["node_modules/", "~/.sbt"]
event: ["target/generated-intermediate-resouce/*"]
Expand Down

0 comments on commit 0530a47

Please sign in to comment.