Skip to content

Commit

Permalink
internal/ci: use core directly instead of _base alias
Browse files Browse the repository at this point in the history
In the previous CL we embedded base into core. _base is therefore an
alias of core and the latter can be used directly.

This change should not result in any .github/workflows changes.

Signed-off-by: Paul Jolly <paul@myitcv.io>
Change-Id: Ib8204905521ec9b919599fc11cf443f37052d8ce
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/551591
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 305dc1d commit f446b87
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 38 deletions.
8 changes: 4 additions & 4 deletions internal/ci/github/evict_caches.cue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import (
//
// In testing with @mvdan, this resulted in cache sizes for Linux dropping from
// ~1GB to ~125MB. This is a considerable saving.
workflows: evict_caches: _base.#bashWorkflow & {
workflows: evict_caches: core.#bashWorkflow & {
name: "Evict caches"

on: {
Expand All @@ -66,8 +66,8 @@ workflows: evict_caches: _base.#bashWorkflow & {
#repo: string
#branch: string
"""
id=$(\(_base.#curlGitHubAPI) "https://github.com/gitapi/repos/\(#repo)/actions/workflows/trybot.yml/runs?branch=\(#branch)&event=push&per_page=1" | jq '.workflow_runs[] | .id')
\(_base.#curlGitHubAPI) -X POST https://github.com/gitapi/repos/\(#repo)/actions/runs/$id/rerun
id=$(\(core.#curlGitHubAPI) "https://github.com/gitapi/repos/\(#repo)/actions/workflows/trybot.yml/runs?branch=\(#branch)&event=push&per_page=1" | jq '.workflow_runs[] | .id')
\(core.#curlGitHubAPI) -X POST https://github.com/gitapi/repos/\(#repo)/actions/runs/$id/rerun
"""
}
Expand All @@ -92,7 +92,7 @@ workflows: evict_caches: _base.#bashWorkflow & {
# Now trigger the most recent workflow run on each of the default branches.
# We do this by listing all the branches on the main repo and finding those
# which match the protected branch patterns (globs).
for j in $(\(_base.#curlGitHubAPI) -f https://github.com/gitapi/repos/\(core.githubRepositoryPath)/branches | jq -r '.[] | .name')
for j in $(\(core.#curlGitHubAPI) -f https://github.com/gitapi/repos/\(core.githubRepositoryPath)/branches | jq -r '.[] | .name')
do
for i in \(branchPatterns)
do
Expand Down
2 changes: 1 addition & 1 deletion internal/ci/github/push_tip_to_trybot.cue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
// 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.#pushTipToTrybotWorkflow & {
workflows: push_tip_to_trybot: core.#pushTipToTrybotWorkflow & {
on: {
push: branches: core.protectedBranchPatterns
}
Expand Down
16 changes: 8 additions & 8 deletions internal/ci/github/release.cue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
_#cueVersionRef: "${GITHUB_REF##refs/tags/}"

// The release workflow
workflows: release: _base.#bashWorkflow & {
workflows: release: core.#bashWorkflow & {

name: "Release"

Expand All @@ -38,14 +38,14 @@ workflows: release: _base.#bashWorkflow & {

on: push: {
tags: [core.releaseTagPattern, "!" + core.zeroReleaseTagPattern]
branches: list.Concat([[_base.testDefaultBranch], core.protectedBranchPatterns])
branches: list.Concat([[core.testDefaultBranch], core.protectedBranchPatterns])
}
jobs: goreleaser: {
"runs-on": core.linuxMachine
if: "${{github.repository == '\(core.githubRepositoryPath)'}}"
steps: [
for v in _base.#checkoutCode {v},
_base.#installGo & {
for v in core.#checkoutCode {v},
core.#installGo & {
with: "go-version": core.pinnedReleaseGo
},
json.#step & {
Expand Down Expand Up @@ -85,17 +85,17 @@ workflows: release: _base.#bashWorkflow & {
run: "cue cmd release"
"working-directory": "./internal/ci/goreleaser"
},
_base.#repositoryDispatch & {
core.#repositoryDispatch & {
name: "Re-test cuelang.org"
if: _base.#isReleaseTag
if: core.#isReleaseTag
#repositoryURL: "https://github.com/cue-lang/cuelang.org"
#arg: {
event_type: "Re-test post release of \(_#cueVersionRef)"
}
},
_base.#repositoryDispatch & {
core.#repositoryDispatch & {
name: "Trigger unity build"
if: _base.#isReleaseTag
if: core.#isReleaseTag
#repositoryURL: core.unityRepositoryURL
#arg: {
event_type: "Check against CUE \(_#cueVersionRef)"
Expand Down
6 changes: 3 additions & 3 deletions internal/ci/github/tip_triggers.cue
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ import (

// The tip_triggers workflow. This fires for each new commit that hits the
// default branch.
workflows: tip_triggers: _base.#bashWorkflow & {
workflows: tip_triggers: core.#bashWorkflow & {

name: "Triggers on push to tip"
on: push: branches: [core.defaultBranch]
jobs: push: {
"runs-on": core.linuxMachine
if: "${{github.repository == '\(core.githubRepositoryPath)'}}"
steps: [
_base.#repositoryDispatch & {
core.#repositoryDispatch & {
name: "Trigger tip.cuelang.org deploy"
#repositoryURL: "https://github.com/cue-lang/cuelang.org"
#arg: {
Expand All @@ -38,7 +38,7 @@ workflows: tip_triggers: _base.#bashWorkflow & {
}
}
},
_base.#repositoryDispatch & {
core.#repositoryDispatch & {
name: "Trigger unity build"
#repositoryURL: "https://github.com/cue-unity/unity"
#arg: {
Expand Down
24 changes: 12 additions & 12 deletions internal/ci/github/trybot.cue
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ import (
)

// The trybot workflow.
workflows: trybot: _base.#bashWorkflow & {
name: _base.trybot.name
workflows: trybot: core.#bashWorkflow & {
name: core.trybot.name

on: {
push: {
branches: list.Concat([["trybot/*/*", _base.testDefaultBranch], core.protectedBranchPatterns]) // do not run PR branches
branches: list.Concat([["trybot/*/*", core.testDefaultBranch], core.protectedBranchPatterns]) // do not run PR branches
"tags-ignore": [core.releaseTagPattern]
}
pull_request: {}
Expand All @@ -39,11 +39,11 @@ workflows: trybot: _base.#bashWorkflow & {
strategy: _#testStrategy
"runs-on": "${{ matrix.os }}"

let goCaches = _base.#setupGoActionsCaches & {#protectedBranchExpr: _base.#isProtectedBranch, _}
let goCaches = core.#setupGoActionsCaches & {#protectedBranchExpr: core.#isProtectedBranch, _}

steps: [
for v in _base.#checkoutCode {v},
_base.#installGo,
for v in core.#checkoutCode {v},
core.#installGo,

// cachePre must come after installing Node and Go, because the cache locations
// are established by running each tool.
Expand All @@ -55,28 +55,28 @@ workflows: trybot: _base.#bashWorkflow & {
// subsequent CLs in the trybot repo can leverage the updated
// cache. Therefore, we instead perform a clean of the testcache.
json.#step & {
if: "github.repository == '\(core.githubRepositoryPath)' && (\(_base.#isProtectedBranch) || github.ref == 'refs/heads/\(_base.testDefaultBranch)')"
if: "github.repository == '\(core.githubRepositoryPath)' && (\(core.#isProtectedBranch) || github.ref == 'refs/heads/\(core.testDefaultBranch)')"
run: "go clean -testcache"
},

_base.#earlyChecks & {
core.#earlyChecks & {
// These checks don't vary based on the Go version or OS,
// so we only need to run them on one of the matrix jobs.
if: core.isLatestLinux
},
json.#step & {
if: "\(_base.#isProtectedBranch) || \(core.isLatestLinux)"
if: "\(core.#isProtectedBranch) || \(core.isLatestLinux)"
run: "echo CUE_LONG=true >> $GITHUB_ENV"
},
_#goGenerate,
_#goTest & {
if: "\(_base.#isProtectedBranch) || !\(core.isLatestLinux)"
if: "\(core.#isProtectedBranch) || !\(core.isLatestLinux)"
},
_#goTestRace & {
if: core.isLatestLinux
},
_#goCheck,
_base.#checkGitClean,
core.#checkGitClean,
_#pullThroughProxy,
]
}
Expand Down Expand Up @@ -123,7 +123,7 @@ workflows: trybot: _base.#bashWorkflow & {
echo "giving up after a number of retries"
exit 1
"""
if: "\(_base.#isProtectedBranch) && \(core.isLatestLinux)"
if: "\(core.#isProtectedBranch) && \(core.isLatestLinux)"
}

_#goGenerate: json.#step & {
Expand Down
8 changes: 6 additions & 2 deletions internal/ci/github/trybot_dispatch.cue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@

package github

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

// The trybot_dispatch workflow.
workflows: trybot_dispatch: _base.#bashWorkflow & _base.#trybotDispatchWorkflow & {
#type: _base.trybot.key
workflows: trybot_dispatch: core.#bashWorkflow & core.#trybotDispatchWorkflow & {
#type: core.trybot.key
}
9 changes: 1 addition & 8 deletions internal/ci/github/workflows.cue
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,10 @@ import (
workflows: close({
[string]: json.#Workflow

(_base.trybot.key): _
(core.trybot.key): _
trybot_dispatch: _
release: _
tip_triggers: _
push_tip_to_trybot: _
evict_caches: _
})

// _base is an instance of ./base, parameterised by the configuration in core
//
// TODO: revisit the naming strategy here. _base and base are very similar.
// Perhaps rename the import to something more obviously not intended to be
// used, and then rename the field base?
_base: core

0 comments on commit f446b87

Please sign in to comment.