Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(3106): Allow shared.requires for pipeline template yaml #565

Merged
merged 2 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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