Debian Codegraph @

internal/ci/base/base.cue

raw
1 // Copyright 2022 The CUE Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 // package base is a collection of workflows, jobs, stes etc that are common to
16 // CUE projects and the workflows they specify. The package itself needs to be
17 // instantiated to parameterise many of the exported definitions.
18 //
19 // For example a package using base would do something like this:
20 //
21 // package workflows
22 //
23 // import "cuelang.org/go/internal/ci/base"
24 //
25 // // Create an instance of base
26 // _base: base & core { params: {
27 // // any values you need to set that are outside of core
28 // ...
29 // }}
30 //
31 package base
32
33 import (
34 "strings"
35 )
36
37 // Package parameters
38 githubRepositoryPath: *(URLPath & {#url: githubRepositoryURL, _}) | string
39 githubRepositoryURL: *("https://github.com/" + githubRepositoryPath) | string
40 gerritHubHostname: "review.gerrithub.io"
41 gerritHubRepositoryURL: *("https://\(gerritHubHostname)/a/" + githubRepositoryPath) | string
42 trybotRepositoryPath: *(githubRepositoryPath + "-" + trybot.key) | string
43 trybotRepositoryURL: *("https://github.com/" + trybotRepositoryPath) | string
44
45 defaultBranch: *"master" | string
46 testDefaultBranch: *"ci/test" | _
47 protectedBranchPatterns: *[defaultBranch] | [...string]
48 releaseTagPrefix: *"v" | string
49 releaseTagPattern: *(releaseTagPrefix + "*") | string
50
51 botGitHubUser: string
52 botGitHubUserTokenSecretsKey: *(strings.ToUpper(botGitHubUser) + "_GITHUB_PAT") | string
53 botGitHubUserEmail: string
54 botGerritHubUser: *botGitHubUser | string
55 botGerritHubUserPasswordSecretsKey: *(strings.ToUpper(botGitHubUser) + "_GERRITHUB_PASSWORD") | string
56 botGerritHubUserEmail: *botGitHubUserEmail | string
57
58 workflowFileExtension: ".yaml"
59
60 linuxMachine: string
61
62 codeReview: #codeReview & {
63 github: githubRepositoryURL
64 gerrit: gerritHubRepositoryURL
65 }
66
67 // Define some shared keys and human-readable names.
68 //
69 // trybot.key and unity.key are shared with
70 // github.com/cue-lang/contrib-tools/cmd/cueckoo. The keys are used across various CUE
71 // workflows and their consistency in those various locations is therefore
72 // crucial. As such, we assert specific values for the keys here rather than
73 // just deriving values from the human-readable names.
74 //
75 // trybot.name is by the trybot GitHub workflow and by gerritstatusupdater as
76 // an identifier in the status updates that are posted as reviews for this
77 // workflows, but also as the result label key, e.g. "TryBot-Result" would be
78 // the result label key for the "TryBot" workflow. This name also shows up in
79 // the CI badge in the top-level README.
80 trybot: {
81 key: "trybot" & strings.ToLower(name)
82 name: "TryBot"
83 }
84
85 unity: {
86 key: "unity" & strings.ToLower(name)
87 name: "Unity"
88 }