From f0ecf9c8e5abf92f6d24bbb145b0c5c6feb1e9e9 Mon Sep 17 00:00:00 2001 From: Thorarinn Sigurdsson Date: Thu, 4 Mar 2021 13:30:20 +0100 Subject: [PATCH] feat(enterprise): add baseBranch trigger filters --- core/src/config/workflow.ts | 40 ++++++++++++--------------- core/test/unit/src/config/workflow.ts | 10 ------- 2 files changed, 18 insertions(+), 32 deletions(-) diff --git a/core/src/config/workflow.ts b/core/src/config/workflow.ts index 256028db21..78ba6af0aa 100644 --- a/core/src/config/workflow.ts +++ b/core/src/config/workflow.ts @@ -247,9 +247,9 @@ export interface TriggerSpec { namespace?: string events?: string[] branches?: string[] - tags?: string[] + baseBranches?: string[] ignoreBranches?: string[] - ignoreTags?: string[] + ignoreBaseBranches?: string[] } export const triggerSchema = () => { @@ -282,26 +282,22 @@ export const triggerSchema = () => { \n ` ), - branches: joi - .array() - .items(joi.string()) - .unique() - .description("If specified, only run the workflow for branches matching one of these filters."), - tags: joi - .array() - .items(joi.string()) - .unique() - .description("If specified, only run the workflow for tags matching one of these filters."), - ignoreBranches: joi - .array() - .items(joi.string()) - .unique() - .description("If specified, do not run the workflow for branches matching one of these filters."), - ignoreTags: joi - .array() - .items(joi.string()) - .unique() - .description("If specified, do not run the workflow for tags matching one of these filters."), + branches: joi.array().items(joi.string()).unique().description(deline` + If specified, only run the workflow for branches matching one of these filters. These filters refer to the + pull/merge request's head branch (e.g. \`my-feature-branch\`), not the base branch that the pull/merge request + would be merged into if approved (e.g. \`main\`). + `), + baseBranches: joi.array().items(joi.string()).unique().description(deline` + If specified, only run the workflow for pull/merge requests whose base branch matches one of these filters. + `), + ignoreBranches: joi.array().items(joi.string()).unique().description(deline` + If specified, do not run the workflow for branches matching one of these filters. These filters refer to the + pull/merge request's head branch (e.g. \`my-feature-branch\`), not the base branch that the pull/merge request + would be merged into if approved (e.g. \`main\`). + `), + ignoreBaseBranches: joi.array().items(joi.string()).unique().description(deline` + If specified, do not run the workflow for pull/merge requests whose base branch matches one of these filters. + `), }) } diff --git a/core/test/unit/src/config/workflow.ts b/core/test/unit/src/config/workflow.ts index e0ec3738a7..ad6cca512f 100644 --- a/core/test/unit/src/config/workflow.ts +++ b/core/test/unit/src/config/workflow.ts @@ -53,8 +53,6 @@ describe("resolveWorkflowConfig", () => { events: ["pull-request"], branches: ["feature*"], ignoreBranches: ["feature-ignored*"], - tags: ["v1*"], - ignoreTags: ["v1-ignored*"], }, ], } @@ -196,8 +194,6 @@ describe("resolveWorkflowConfig", () => { events: ["pull-request"], branches: ["feature*"], ignoreBranches: ["feature-ignored*"], - tags: ["v1*"], - ignoreTags: ["v1-ignored*"], }, ], } @@ -223,8 +219,6 @@ describe("resolveWorkflowConfig", () => { events: ["pull-request"], branches: ["feature*"], ignoreBranches: ["feature-ignored*"], - tags: ["v1*"], - ignoreTags: ["v1-ignored*"], }, ], } @@ -250,8 +244,6 @@ describe("resolveWorkflowConfig", () => { events: ["pull-request"], branches: ["feature*"], ignoreBranches: ["feature-ignored*"], - tags: ["v1*"], - ignoreTags: ["v1-ignored*"], }, ], } @@ -268,8 +260,6 @@ describe("resolveWorkflowConfig", () => { events: ["pull-request"], branches: ["feature*"], ignoreBranches: ["feature-ignored*"], - tags: ["v1*"], - ignoreTags: ["v1-ignored*"], } const config: WorkflowConfig = { ...defaults,