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

feat(3143): Add regex for stage setup or teardown job names #574

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 3 additions & 1 deletion config/regex.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,7 @@ module.exports = {
// Provider Role. Can be arn:aws:iam::xxxxxx:role/some-role
ROLE_ARN: /^arn:aws:iam::\d{12}:role\/.+/,
// Stage setup pattern. Can be stage@stage-name:setup
STAGE_SETUP_PATTERN: /^stage@([\w-]+):setup$/
STAGE_SETUP_PATTERN: /^stage@([\w-]+):setup$/,
// Stage setup pattern. Can be stage@stage-name:setup or stage@stage-name:teardown
STAGE_SETUP_TEARDOWN_PATTERN: /^stage@([\w-]+):(setup|teardown)$/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets move this where the regex related to job names are declared.
May be after PR_JOB_NAME

Suggested change
STAGE_SETUP_TEARDOWN_PATTERN: /^stage@([\w-]+):(setup|teardown)$/
STAGE_SETUP_TEARDOWN_JOB_NAME: /^stage@([\w-]+):(setup|teardown)$/

};
16 changes: 16 additions & 0 deletions test/config/regex.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,4 +524,20 @@ describe('config regex', () => {
});
});
});

describe('stageSetupTeardown', () => {
const stageSetupTeardownRegex = config.regex.STAGE_SETUP_TEARDOWN_PATTERN;

it('matches valid stage setup or teardown jobs', () => {
['stage@alpha:setup', 'stage@alpha:teardown'].forEach(trigger => {
assert.isTrue(stageSetupTeardownRegex.test(trigger));
});
});

it('does not match invalid stage setup or teardown jobs', () => {
['stage@alpha', 'alpha-deploy', 'alpha:setup', 'stage@setup'].forEach(trigger => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add more samples stage@alpha:deploy, stage@teardown, sd@1234:stage@alpha:setup, sd@1234:stage@alpha:teardown

assert.isFalse(stageSetupTeardownRegex.test(trigger));
});
});
});
});