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 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
2 changes: 2 additions & 0 deletions config/regex.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ module.exports = {
JOB_NAME: /^(([\w-]+)|(?:stage@([\w-]+):(setup|teardown)))$/,
// PR JOB Name can only be PR-1 or PR-1:main, group1: PR-prNum, group2: jobName
PR_JOB_NAME: /^(PR-\d+)(?::([\w-]+))?$/,
// Stage setup or teardown job name. Can be stage@stage-name:setup or stage@stage-name:teardown
STAGE_SETUP_TEARDOWN_JOB_NAME: /^stage@([\w-]+):(setup|teardown)$/,
// Match all possible job name
ALL_JOB_NAME: /^(PR-[0-9]+:)?[\w-@:]+$/,
// Internal trigger like ~component or ~main
Expand Down
25 changes: 25 additions & 0 deletions test/config/regex.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,4 +524,29 @@ describe('config regex', () => {
});
});
});

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

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',
'stage@alpha:deploy',
'stage@teardown',
'sd@1234:stage@alpha:setup',
'sd@1234:stage@alpha:teardown'
].forEach(trigger => {
assert.isFalse(stageSetupTeardownRegex.test(trigger));
});
});
});
});