Skip to content

Commit

Permalink
internal/ci: rename core -> repo
Browse files Browse the repository at this point in the history
This better reflects the fact the package contains configuration common
to various configuration aspects of this repo.

Signed-off-by: Paul Jolly <paul@myitcv.io>
Change-Id: I069965c9cf8ce397bc6ad54c2f884b29149d096e
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/551776
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 27, 2023
1 parent d1a6da8 commit 6d6ffb4
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 76 deletions.
4 changes: 2 additions & 2 deletions internal/ci/ci_tool.cue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"tool/file"

"cuelang.org/go/internal/ci/base"
"cuelang.org/go/internal/ci/core"
"cuelang.org/go/internal/ci/repo"
"cuelang.org/go/internal/ci/github"
)

Expand Down Expand Up @@ -68,7 +68,7 @@ command: gen: {
command: gen: codereviewcfg: file.Create & {
_dir: path.FromSlash("../../", path.Unix)
filename: path.Join([_dir, "codereview.cfg"], _goos)
let res = base.toCodeReviewCfg & {#input: core.codeReview, _}
let res = base.toCodeReviewCfg & {#input: repo.codeReview, _}
let donotedit = base.doNotEditMessage & {#generatedBy: "internal/ci/ci_tool.cue", _}
contents: "# \(donotedit)\n\n\(res)\n"
}
22 changes: 11 additions & 11 deletions internal/ci/github/evict_caches.cue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package github
import (
"strings"

"cuelang.org/go/internal/ci/core"
"cuelang.org/go/internal/ci/repo"

"github.com/SchemaStore/schemastore/src/schemas/json"
)
Expand All @@ -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: core.bashWorkflow & {
workflows: evict_caches: repo.bashWorkflow & {
name: "Evict caches"

on: {
Expand All @@ -54,20 +54,20 @@ workflows: evict_caches: core.bashWorkflow & {
jobs: {
test: {
// We only want to run this in the main repo
if: "${{github.repository == '\(core.githubRepositoryPath)'}}"
"runs-on": core.linuxMachine
if: "${{github.repository == '\(repo.githubRepositoryPath)'}}"
"runs-on": repo.linuxMachine
steps: [
json.#step & {
let branchPatterns = strings.Join(core.protectedBranchPatterns, " ")
let branchPatterns = strings.Join(repo.protectedBranchPatterns, " ")

// rerunLatestWorkflow runs the latest trybot workflow in the
// specified repo for branches that match the specified branch.
let rerunLatestWorkflow = {
#repo: string
#branch: string
"""
id=$(\(core.curlGitHubAPI) "https://api.github.com/repos/\(#repo)/actions/workflows/trybot.yml/runs?branch=\(#branch)&event=push&per_page=1" | jq '.workflow_runs[] | .id')
\(core.curlGitHubAPI) -X POST https://api.github.com/repos/\(#repo)/actions/runs/$id/rerun
id=$(\(repo.curlGitHubAPI) "https://api.github.com/repos/\(#repo)/actions/workflows/trybot.yml/runs?branch=\(#branch)&event=push&per_page=1" | jq '.workflow_runs[] | .id')
\(repo.curlGitHubAPI) -X POST https://api.github.com/repos/\(#repo)/actions/runs/$id/rerun
"""
}
Expand All @@ -77,7 +77,7 @@ workflows: evict_caches: core.bashWorkflow & {
echo ${{ secrets.CUECKOO_GITHUB_PAT }} | gh auth login --with-token
gh extension install actions/gh-actions-cache
for i in \(core.githubRepositoryURL) \(core.githubRepositoryURL)-trybot
for i in \(repo.githubRepositoryURL) \(repo.githubRepositoryURL)-trybot
do
echo "Evicting caches for $i"
cd $(mktemp -d)
Expand All @@ -92,7 +92,7 @@ workflows: evict_caches: core.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 $(\(core.curlGitHubAPI) -f https://api.github.com/repos/\(core.githubRepositoryPath)/branches | jq -r '.[] | .name')
for j in $(\(repo.curlGitHubAPI) -f https://api.github.com/repos/\(repo.githubRepositoryPath)/branches | jq -r '.[] | .name')
do
for i in \(branchPatterns)
do
Expand All @@ -101,8 +101,8 @@ workflows: evict_caches: core.bashWorkflow & {
fi
echo "$j is a match with $i"
\(rerunLatestWorkflow & {#repo: core.githubRepositoryPath, #branch: "$j", _})
\(rerunLatestWorkflow & {#repo: core.githubRepositoryPath + "-trybot", #branch: "$j", _})
\(rerunLatestWorkflow & {#repo: repo.githubRepositoryPath, #branch: "$j", _})
\(rerunLatestWorkflow & {#repo: repo.githubRepositoryPath + "-trybot", #branch: "$j", _})
done
done
"""
Expand Down
10 changes: 5 additions & 5 deletions internal/ci/github/push_tip_to_trybot.cue
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@
package github

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

// 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: core.pushTipToTrybotWorkflow & {
workflows: push_tip_to_trybot: repo.pushTipToTrybotWorkflow & {
on: {
push: branches: core.protectedBranchPatterns
push: branches: repo.protectedBranchPatterns
}
jobs: push: {
"runs-on": core.linuxMachine
if: "${{github.repository == '\(core.githubRepositoryPath)'}}"
"runs-on": repo.linuxMachine
if: "${{github.repository == '\(repo.githubRepositoryPath)'}}"
}
}
32 changes: 16 additions & 16 deletions internal/ci/github/release.cue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package github
import (
"list"

"cuelang.org/go/internal/ci/core"
"cuelang.org/go/internal/ci/repo"
"github.com/SchemaStore/schemastore/src/schemas/json"
)

Expand All @@ -27,7 +27,7 @@ import (
_cueVersionRef: "${GITHUB_REF##refs/tags/}"

// The release workflow
workflows: release: core.bashWorkflow & {
workflows: release: repo.bashWorkflow & {

name: "Release"

Expand All @@ -37,16 +37,16 @@ workflows: release: core.bashWorkflow & {
concurrency: "release"

on: push: {
tags: [core.releaseTagPattern, "!" + core.zeroReleaseTagPattern]
branches: list.Concat([[core.testDefaultBranch], core.protectedBranchPatterns])
tags: [repo.releaseTagPattern, "!" + repo.zeroReleaseTagPattern]
branches: list.Concat([[repo.testDefaultBranch], repo.protectedBranchPatterns])
}
jobs: goreleaser: {
"runs-on": core.linuxMachine
if: "${{github.repository == '\(core.githubRepositoryPath)'}}"
"runs-on": repo.linuxMachine
if: "${{github.repository == '\(repo.githubRepositoryPath)'}}"
steps: [
for v in core.checkoutCode {v},
core.installGo & {
with: "go-version": core.pinnedReleaseGo
for v in repo.checkoutCode {v},
repo.installGo & {
with: "go-version": repo.pinnedReleaseGo
},
json.#step & {
name: "Setup qemu"
Expand Down Expand Up @@ -74,7 +74,7 @@ workflows: release: core.bashWorkflow & {
uses: "goreleaser/goreleaser-action@v3"
with: {
"install-only": true
version: core.goreleaserVersion
version: repo.goreleaserVersion
}
},
json.#step & {
Expand All @@ -85,18 +85,18 @@ workflows: release: core.bashWorkflow & {
run: "cue cmd release"
"working-directory": "./internal/ci/goreleaser"
},
core.repositoryDispatch & {
repo.repositoryDispatch & {
name: "Re-test cuelang.org"
if: core.isReleaseTag
#githubRepositoryPath: core.cuelangRepositoryPath
if: repo.isReleaseTag
#githubRepositoryPath: repo.cuelangRepositoryPath
#arg: {
event_type: "Re-test post release of \(_cueVersionRef)"
}
},
core.repositoryDispatch & {
repo.repositoryDispatch & {
name: "Trigger unity build"
if: core.isReleaseTag
#githubRepositoryPath: core.unityRepositoryPath
if: repo.isReleaseTag
#githubRepositoryPath: repo.unityRepositoryPath
#arg: {
event_type: "Check against CUE \(_cueVersionRef)"
client_payload: {
Expand Down
18 changes: 9 additions & 9 deletions internal/ci/github/tip_triggers.cue
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,32 @@
package github

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

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

name: "Triggers on push to tip"
on: push: branches: [core.defaultBranch]
on: push: branches: [repo.defaultBranch]
jobs: push: {
"runs-on": core.linuxMachine
if: "${{github.repository == '\(core.githubRepositoryPath)'}}"
"runs-on": repo.linuxMachine
if: "${{github.repository == '\(repo.githubRepositoryPath)'}}"
steps: [
core.repositoryDispatch & {
repo.repositoryDispatch & {
name: "Trigger tip.cuelang.org deploy"
#githubRepositoryPath: core.cuelangRepositoryPath
#githubRepositoryPath: repo.cuelangRepositoryPath
#arg: {
event_type: "Rebuild tip against ${GITHUB_SHA}"
client_payload: {
type: "rebuild_tip"
}
}
},
core.repositoryDispatch & {
repo.repositoryDispatch & {
name: "Trigger unity build"
#githubRepositoryPath: core.unityRepositoryPath
#githubRepositoryPath: repo.unityRepositoryPath
#arg: {
event_type: "Check against ${GITHUB_SHA}"
client_payload: {
Expand Down
42 changes: 21 additions & 21 deletions internal/ci/github/trybot.cue
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ package github
import (
"list"

"cuelang.org/go/internal/ci/core"
"cuelang.org/go/internal/ci/repo"

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

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

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

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

steps: [
for v in core.checkoutCode {v},
core.installGo,
for v in repo.checkoutCode {v},
repo.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: core.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)' && (\(core.isProtectedBranch) || github.ref == 'refs/heads/\(core.testDefaultBranch)')"
if: "github.repository == '\(repo.githubRepositoryPath)' && (\(repo.isProtectedBranch) || github.ref == 'refs/heads/\(repo.testDefaultBranch)')"
run: "go clean -testcache"
},

core.earlyChecks & {
repo.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
if: repo.isLatestLinux
},
json.#step & {
if: "\(core.isProtectedBranch) || \(core.isLatestLinux)"
if: "\(repo.isProtectedBranch) || \(repo.isLatestLinux)"
run: "echo CUE_LONG=true >> $GITHUB_ENV"
},
_goGenerate,
_goTest & {
if: "\(core.isProtectedBranch) || !\(core.isLatestLinux)"
if: "\(repo.isProtectedBranch) || !\(repo.isLatestLinux)"
},
_goTestRace & {
if: core.isLatestLinux
if: repo.isLatestLinux
},
_goCheck,
core.checkGitClean,
repo.checkGitClean,
_pullThroughProxy,
]
}
Expand All @@ -85,13 +85,13 @@ workflows: trybot: core.bashWorkflow & {
_testStrategy: {
"fail-fast": false
matrix: {
"go-version": ["1.19.x", core.latestStableGo]
os: [core.linuxMachine, core.macosMachine, core.windowsMachine]
"go-version": ["1.19.x", repo.latestStableGo]
os: [repo.linuxMachine, repo.macosMachine, repo.windowsMachine]
}
}

_pullThroughProxy: json.#step & {
name: "Pull this commit through the proxy on \(core.defaultBranch)"
name: "Pull this commit through the proxy on \(repo.defaultBranch)"
run: """
v=$(git rev-parse HEAD)
cd $(mktemp -d)
Expand Down Expand Up @@ -123,15 +123,15 @@ workflows: trybot: core.bashWorkflow & {
echo "giving up after a number of retries"
exit 1
"""
if: "\(core.isProtectedBranch) && \(core.isLatestLinux)"
if: "\(repo.isProtectedBranch) && \(repo.isLatestLinux)"
}

_goGenerate: json.#step & {
name: "Generate"
run: "go generate ./..."
// The Go version corresponds to the precise version specified in
// the matrix. Skip windows for now until we work out why re-gen is flaky
if: core.isLatestLinux
if: repo.isLatestLinux
}

_goTest: json.#step & {
Expand All @@ -146,7 +146,7 @@ workflows: trybot: core.bashWorkflow & {
// dependencies that vary wildly between platforms.
// For now, to save CI resources, just run the checks on one matrix job.
// TODO: consider adding more checks as per https://github.com/golang/go/issues/42119.
if: "\(core.isLatestLinux)"
if: "\(repo.isLatestLinux)"
name: "Check"
run: "go vet ./..."
}
Expand Down
6 changes: 3 additions & 3 deletions internal/ci/github/trybot_dispatch.cue
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
package github

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

// The trybot_dispatch workflow.
workflows: trybot_dispatch: core.bashWorkflow & core.trybotDispatchWorkflow & {
#type: core.trybot.key
workflows: trybot_dispatch: repo.bashWorkflow & repo.trybotDispatchWorkflow & {
#type: repo.trybot.key
}
4 changes: 2 additions & 2 deletions internal/ci/github/workflows.cue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package github

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

"github.com/SchemaStore/schemastore/src/schemas/json"
)
Expand All @@ -42,7 +42,7 @@ import (
workflows: close({
[string]: json.#Workflow

(core.trybot.key): _
(repo.trybot.key): _
trybot_dispatch: _
release: _
tip_triggers: _
Expand Down
Loading

0 comments on commit 6d6ffb4

Please sign in to comment.