Skip to content

Commit

Permalink
internal/ci: move pushTipToTryBot workflow to gerrithub package
Browse files Browse the repository at this point in the history
It's a core workflow that only needs to parameterised in a simple way.
This is a mechanical change.

The difference in the pushTipToTryBot.yml workflow file is an ordering
difference. The files are semantically identical.

Signed-off-by: Paul Jolly <paul@myitcv.io>
Change-Id: I6529cee239230db2a9cb5b0ec51fd91442716024
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/551507
Unity-Result: CUEcueckoo <cueckoo@cuelang.org>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
  • Loading branch information
myitcv committed Mar 25, 2023
1 parent e3ed297 commit e440409
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/push_tip_to_trybot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ jobs:
defaults:
run:
shell: bash
if: ${{github.repository == 'cue-lang/cue'}}
steps:
- name: Write netrc file for cueckoo Gerrithub
run: |-
Expand All @@ -35,3 +34,4 @@ jobs:
git remote add trybot https://github.com/cue-lang/cue-trybot
git fetch origin "${{ github.ref }}"
git push trybot "FETCH_HEAD:${{ github.ref }}"
if: ${{github.repository == 'cue-lang/cue'}}
34 changes: 32 additions & 2 deletions internal/ci/gerrithub/gerrithub.cue
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ _#linuxMachine: "ubuntu-20.04"
"runs-on": _#linuxMachine
if: "${{ github.event.client_payload.type == '\(#type)' }}"
steps: [
#writeNetrcFile,
_#writeNetrcFile,
// Out of the entire ref (e.g. refs/changes/38/547738/7) we only
// care about the CL number and patchset, (e.g. 547738/7).
// Note that gerrithub_ref is two path elements.
Expand Down Expand Up @@ -94,7 +94,37 @@ _#linuxMachine: "ubuntu-20.04"
}
}

#writeNetrcFile: json.#step & {
#pushTipToTrybotWorkflow: json.#Workflow & {
jobs: [string]: defaults: run: shell: "bash"

name: "Push tip to \(#trybotKey)"

concurrency: "push_tip_to_trybot"

jobs: push: {
steps: [
_#writeNetrcFile,
json.#step & {
name: "Push tip to trybot"
run: """
mkdir tmpgit
cd tmpgit
git init
git config user.name \(#botGitHubUser)
git config user.email \(#botGitHubUserEmail)
git config http.https://github.com/.extraheader "AUTHORIZATION: basic $(echo -n \(#botGitHubUser):${{ secrets.\(#botGitHubUserTokenSecretsKey) }} | base64)"
git remote add origin \(#gerritHubRepository)
git remote add trybot \(#trybotRepositoryURL)
git fetch origin "${{ github.ref }}"
git push trybot "FETCH_HEAD:${{ github.ref }}"
"""
},
]
}

}

_#writeNetrcFile: json.#step & {
name: "Write netrc file for cueckoo Gerrithub"
run: """
cat <<EOD > ~/.netrc
Expand Down
28 changes: 1 addition & 27 deletions internal/ci/github/push_tip_to_trybot.cue
Original file line number Diff line number Diff line change
Expand Up @@ -16,43 +16,17 @@ package github

import (
"cuelang.org/go/internal/ci/core"

"github.com/SchemaStore/schemastore/src/schemas/json"
)

// push_tip_to_trybot "syncs" active branches to the trybot repo.
// Since the workflow is triggered by a push to any of the branches,
// the step only needs to sync the pushed branch.
workflows: push_tip_to_trybot: _base.#bashWorkflow & {

name: "Push tip to trybot"
workflows: push_tip_to_trybot: _gerrithub.#pushTipToTrybotWorkflow & {
on: {
push: branches: core.protectedBranchPatterns
}

concurrency: "push_tip_to_trybot"

jobs: push: {
"runs-on": core.linuxMachine
if: "${{github.repository == '\(core.githubRepositoryPath)'}}"
steps: [
_gerrithub.#writeNetrcFile,
json.#step & {
name: "Push tip to trybot"
run: """
mkdir tmpgit
cd tmpgit
git init
git config user.name \(_gerrithub.#botGitHubUser)
git config user.email \(_gerrithub.#botGitHubUserEmail)
git config http.https://github.com/.extraheader "AUTHORIZATION: basic $(echo -n \(_gerrithub.#botGitHubUser):${{ secrets.\(_gerrithub.#botGitHubUserTokenSecretsKey) }} | base64)"
git remote add origin \(_gerrithub.#gerritHubRepository)
git remote add trybot \(_gerrithub.#trybotRepositoryURL)
git fetch origin "${{ github.ref }}"
git push trybot "FETCH_HEAD:${{ github.ref }}"
"""
},
]
}

}

0 comments on commit e440409

Please sign in to comment.