diff --git a/components/gitpod-protocol/data/gitpod-schema.json b/components/gitpod-protocol/data/gitpod-schema.json index 7ae43145801b23..ca24e5fa20e1e1 100644 --- a/components/gitpod-protocol/data/gitpod-schema.json +++ b/components/gitpod-protocol/data/gitpod-schema.json @@ -9,9 +9,7 @@ "description": "List of exposed ports.", "items": { "type": "object", - "required": [ - "port" - ], + "required": ["port"], "properties": { "port": { "type": ["number", "string"], @@ -20,20 +18,12 @@ }, "onOpen": { "type": "string", - "enum": [ - "open-browser", - "open-preview", - "notify", - "ignore" - ], + "enum": ["open-browser", "open-preview", "notify", "ignore"], "description": "What to do when a service on this port was detected. 'notify' (default) will show a notification asking the user what to do. 'open-browser' will open a new browser tab. 'open-preview' will open in the preview on the right of the IDE. 'ignore' will do nothing." }, "visibility": { "type": "string", - "enum": [ - "private", - "public" - ], + "enum": ["private", "public"], "default": "private", "description": "Whether the port visibility should be private or public. 'private' (default) will only allow users with workspace access to access the port. 'public' will allow everyone with the port URL to access the port." }, @@ -43,11 +33,7 @@ }, "protocol": { "type": "string", - "enum": [ - "http", - "TCP", - "UDP" - ], + "enum": ["http", "TCP", "UDP"], "deprecationMessage": "The 'protocol' property is deprecated.", "description": "The protocol to be used. (deprecated)" }, @@ -92,22 +78,12 @@ }, "openIn": { "type": "string", - "enum": [ - "bottom", - "main", - "left", - "right" - ], + "enum": ["bottom", "main", "left", "right"], "description": "The panel/area where to open the terminal. Default is 'bottom' panel." }, "openMode": { "type": "string", - "enum": [ - "split-left", - "split-right", - "tab-before", - "tab-after" - ], + "enum": ["split-left", "split-right", "tab-before", "tab-after"], "description": "The opening mode. Default is 'tab-after'." } }, @@ -115,15 +91,10 @@ } }, "image": { - "type": [ - "object", - "string" - ], + "type": ["object", "string"], "description": "The Docker image to run your workspace in.", "default": "gitpod/workspace-full", - "required": [ - "file" - ], + "required": ["file"], "properties": { "file": { "type": "string", @@ -141,9 +112,7 @@ "description": "List of additional repositories that are part of this project.", "items": { "type": "object", - "required": [ - "url" - ], + "required": ["url"], "properties": { "url": { "type": ["string"], @@ -170,9 +139,7 @@ "description": "Path to where the IDE's workspace should be opened. Supports vscode's `*.code-workspace` files." }, "gitConfig": { - "type": [ - "object" - ], + "type": ["object"], "description": "Git config values should be provided in pairs. E.g. `core.autocrlf: input`. See https://git-scm.com/docs/git-config#_values.", "additionalProperties": { "type": "string" @@ -183,15 +150,17 @@ "description": "Configures Gitpod's GitHub app", "properties": { "prebuilds": { - "type": [ - "boolean", - "object" - ], + "type": ["boolean", "object"], "description": "Set to true to enable workspace prebuilds, false to disable them. Defaults to true.", "properties": { "master": { "type": "boolean", - "description": "Enable prebuilds for the default branch (typically master). Defaults to true." + "description": "Enable prebuilds for the default branch (typically master). Defaults to true.", + "deprecationMessage": "Deprecated. Please use `defaultBranch` instead. See https://www.gitpod.io/docs/configure/projects/prebuilds#github-specific-configuration." + }, + "defaultBranch": { + "type": "boolean", + "description": "Enable prebuilds for the default branch (typically main). Defaults to true." }, "branches": { "type": "boolean", @@ -210,22 +179,12 @@ "description": "Add a Review in Gitpod badge to pull requests. Defaults to true." }, "addCheck": { - "type": [ - "boolean", - "string" - ], - "enum": [ - true, - false, - "prevent-merge-on-error" - ], + "type": ["boolean", "string"], + "enum": [true, false, "prevent-merge-on-error"], "description": "Add a commit check to pull requests. Set to 'fail-on-error' if you want broken prebuilds to block merging. Defaults to true." }, "addLabel": { - "type": [ - "boolean", - "string" - ], + "type": ["boolean", "string"], "description": "Add a label to a PR when it's prebuilt. Set to true to use the default label (prebuilt-in-gitpod) or set to a string to use a different label name. This is a beta feature and may be unreliable. Defaults to false." } } @@ -339,11 +298,7 @@ "properties": { "version": { "type": "string", - "enum": [ - "stable", - "latest", - "both" - ], + "enum": ["stable", "latest", "both"], "description": "Whether only stable, latest or both versions should be warmed up. Default is stable only." } } diff --git a/components/gitpod-protocol/go/gitpod-config-types.go b/components/gitpod-protocol/go/gitpod-config-types.go index f563eadd9340c4..e006bd587f7241 100644 --- a/components/gitpod-protocol/go/gitpod-config-types.go +++ b/components/gitpod-protocol/go/gitpod-config-types.go @@ -179,6 +179,9 @@ type Prebuilds_object struct { // Enable prebuilds for all branches. Defaults to false. Branches bool `yaml:"branches,omitempty" json:"branches,omitempty"` + // Enable prebuilds for the default branch (typically main). Defaults to true. + DefaultBranch bool `yaml:"defaultBranch,omitempty" json:"defaultBranch,omitempty"` + // Enable prebuilds for the default branch (typically master). Defaults to true. Master bool `yaml:"master,omitempty" json:"master,omitempty"` diff --git a/components/gitpod-protocol/go/gitpod-service.go b/components/gitpod-protocol/go/gitpod-service.go index 64c2be3ec397eb..f2efd73f12140d 100644 --- a/components/gitpod-protocol/go/gitpod-service.go +++ b/components/gitpod-protocol/go/gitpod-service.go @@ -1926,7 +1926,8 @@ type GithubAppPrebuildConfig struct { AddComment bool `json:"addComment,omitempty"` AddLabel interface{} `json:"addLabel,omitempty"` Branches bool `json:"branches,omitempty"` - Master bool `json:"master,omitempty"` + Master bool `json:"master,omitempty"` // Deprecated: use DefaultBranch instead + DefaultBranch bool `json:"defaultBranch,omitempty"` PullRequests bool `json:"pullRequests,omitempty"` PullRequestsFromForks bool `json:"pullRequestsFromForks,omitempty"` } diff --git a/components/gitpod-protocol/src/protocol.ts b/components/gitpod-protocol/src/protocol.ts index 6998576516d65f..1577b1acdb5479 100644 --- a/components/gitpod-protocol/src/protocol.ts +++ b/components/gitpod-protocol/src/protocol.ts @@ -849,7 +849,8 @@ export interface GithubAppConfig { prebuilds?: GithubAppPrebuildConfig; } export interface GithubAppPrebuildConfig { - master?: boolean; + master?: boolean; // Deprecated: use defaultBranch instead + defaultBranch?: boolean; branches?: boolean; pullRequests?: boolean; pullRequestsFromForks?: boolean; diff --git a/components/server/ee/src/prebuilds/github-app-rules.ts b/components/server/ee/src/prebuilds/github-app-rules.ts index 2591ed1803cfc0..3e948e7d76df79 100644 --- a/components/server/ee/src/prebuilds/github-app-rules.ts +++ b/components/server/ee/src/prebuilds/github-app-rules.ts @@ -16,7 +16,8 @@ const defaultConfig: GithubAppConfig = { addComment: false, addLabel: false, branches: false, - master: true, + master: false, // Deprecated: use defaultBranch instead + defaultBranch: true, pullRequests: true, pullRequestsFromForks: false, }, @@ -52,7 +53,7 @@ export class GithubAppRules { return !!prebuildCfg.pullRequests; } } else if (isDefaultBranch) { - return !!prebuildCfg.master; + return /* !!prebuildCfg.master || */ !!prebuildCfg.defaultBranch; } else { return !!prebuildCfg.branches; } diff --git a/components/server/ee/src/prebuilds/github-app.spec.ts b/components/server/ee/src/prebuilds/github-app.spec.ts index 900f4ee7f2ac8b..68753c8c499424 100644 --- a/components/server/ee/src/prebuilds/github-app.spec.ts +++ b/components/server/ee/src/prebuilds/github-app.spec.ts @@ -37,10 +37,15 @@ describe("GitHub app", () => { tasks: [{ init: "ls" }], }; + // chai.assert.equal( + // rules.shouldRunPrebuild(cfg, true, false, false), + // expectation[0], + // `master prebuild check failed with ${JSON.stringify(pbcfg)}`, + // ); chai.assert.equal( rules.shouldRunPrebuild(cfg, true, false, false), expectation[0], - `master prebuild check failed with ${JSON.stringify(pbcfg)}`, + `defaultBranch prebuild check failed with ${JSON.stringify(pbcfg)}`, ); chai.assert.equal( rules.shouldRunPrebuild(cfg, false, true, false), @@ -60,10 +65,14 @@ describe("GitHub app", () => { }; checkConfig({ branches: true }, [true, true, true, false]); - checkConfig({ master: false }, [false, true, false, false]); - checkConfig({ master: false, branches: true }, [false, true, true, false]); + // checkConfig({ master: false }, [false, true, false, false]); + // checkConfig({ master: false, branches: true }, [false, true, true, false]); + checkConfig({ defaultBranch: false }, [false, true, false, false]); + // checkConfig({ master: false, defaultBranch: false }, [false, true, false, false]); + checkConfig({ defaultBranch: false, branches: true }, [false, true, true, false]); checkConfig({ pullRequests: false }, [true, false, false, false]); - checkConfig({ pullRequests: false, master: false }, [false, false, false, false]); + // checkConfig({ pullRequests: false, master: false }, [false, false, false, false]); + checkConfig({ pullRequests: false, defaultBranch: false }, [false, false, false, false]); checkConfig({ pullRequests: true, pullRequestsFromForks: true }, [true, true, false, true]); checkConfig({ pullRequestsFromForks: true }, [true, true, false, true]); });