Skip to content

Commit

Permalink
internal/ci: remove hard-codings in gerrithub package
Browse files Browse the repository at this point in the history
Making these fields parameters simplifies later refactorings.

This results in a single expected change to the trybot_dispatch.yml
workfow file. It makes the use of a linux runner consistent with that
used in other workflows.

Signed-off-by: Paul Jolly <paul@myitcv.io>
Change-Id: I064fc10515f859b6ce9ecbae544e270d9f1ce5b8
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/551533
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Unity-Result: CUEcueckoo <cueckoo@cuelang.org>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
  • Loading branch information
myitcv committed Mar 26, 2023
1 parent 1bb7e10 commit f5277b9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/trybot_dispatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name: Dispatch trybot
- repository_dispatch
jobs:
trybot:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
defaults:
run:
shell: bash
Expand Down
12 changes: 5 additions & 7 deletions internal/ci/gerrithub/gerrithub.cue
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,13 @@ import (
#botGerritHubUser: *#botGitHubUser | string
#botGerritHubUserPasswordSecretsKey: string
#botGerritHubUserEmail: *#botGitHubUserEmail | string
#gerritHubHostname: string
#linuxMachine: string

// Pending cuelang.org/issue/1433, hack around defaulting #gerritHubRepository
// based on #repository
let _#repositoryURLNoScheme = strings.Split(#repositoryURL, "//")[1]
#gerritHubRepository: *("https://\(_#gerritHubHostname)/a/" + path.Base(path.Dir(_#repositoryURLNoScheme)) + "/" + path.Base(_#repositoryURLNoScheme)) | _

_#gerritHubHostname: "review.gerrithub.io"

_#linuxMachine: "ubuntu-20.04"
#gerritHubRepository: *("https://\(#gerritHubHostname)/a/" + path.Base(path.Dir(_#repositoryURLNoScheme)) + "/" + path.Base(_#repositoryURLNoScheme)) | _

#dispatchWorkflow: json.#Workflow & {
#type: string
Expand All @@ -57,7 +55,7 @@ _#linuxMachine: "ubuntu-20.04"
jobs: [string]: defaults: run: shell: "bash"
jobs: {
(#type): {
"runs-on": _#linuxMachine
"runs-on": #linuxMachine
if: "${{ github.event.client_payload.type == '\(#type)' }}"
steps: [
#writeNetrcFile,
Expand Down Expand Up @@ -98,7 +96,7 @@ _#linuxMachine: "ubuntu-20.04"
name: "Write netrc file for cueckoo Gerrithub"
run: """
cat <<EOD > ~/.netrc
machine \(_#gerritHubHostname)
machine \(#gerritHubHostname)
login \(#botGerritHubUser)
password ${{ secrets.\(#botGerritHubUserPasswordSecretsKey) }}
EOD
Expand Down
2 changes: 2 additions & 0 deletions internal/ci/github/workflows.cue
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ _gerrithub: gerrithub & {
#botGerritHubUser: core.botGitHubUser
#botGerritHubUserPasswordSecretsKey: core.botGerritHubUserPasswordSecretsKey
#botGerritHubUserEmail: core.botGitHubUserEmail
#gerritHubHostname: core.gerritHubHostname
#linuxMachine: core.linuxMachine
}

// _base is an instance of ./base, parameterised by the properties of this
Expand Down

0 comments on commit f5277b9

Please sign in to comment.