cuelang.org/go@v0.13.0/internal/ci/base/base.cue (about)

     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  unprivilegedBotGitHubUser:                               "not" + botGitHubUser
    59  unprivilegedBotGitHubUserCentralRegistryTokenSecretsKey: *(strings.ToUpper(unprivilegedBotGitHubUser) + "_CUE_TOKEN") | string
    60  
    61  cueCommand: *"cue" | string
    62  
    63  workflowFileExtension: ".yaml"
    64  
    65  linuxMachine: string
    66  
    67  codeReview: #codeReview & {
    68  	github: githubRepositoryURL
    69  	gerrit: gerritHubRepositoryURL
    70  }
    71  
    72  // Define some shared keys and human-readable names.
    73  //
    74  // trybot.key and unity.key are shared with
    75  // github.com/cue-lang/contrib-tools/cmd/cueckoo.  The keys are used across various CUE
    76  // workflows and their consistency in those various locations is therefore
    77  // crucial. As such, we assert specific values for the keys here rather than
    78  // just deriving values from the human-readable names.
    79  //
    80  // trybot.name is by the trybot GitHub workflow and by gerritstatusupdater as
    81  // an identifier in the status updates that are posted as reviews for this
    82  // workflows, but also as the result label key, e.g.  "TryBot-Result" would be
    83  // the result label key for the "TryBot" workflow. This name also shows up in
    84  // the CI badge in the top-level README.
    85  trybot: {
    86  	key:  "trybot" & strings.ToLower(name)
    87  	name: "TryBot"
    88  }
    89  
    90  unity: {
    91  	key:  "unity" & strings.ToLower(name)
    92  	name: "Unity"
    93  }