Skip to content

Commit 093a2c6

Browse files
committed
internal/ci: use githubactions schema from registry
This change uses the WIP githubactions schema from `github.com/cue-tmp/jsonschema-pub/exp1/githubactions`, This enables us to remove the code that vendors the schema from the SchemaStore repository. Signed-off-by: Roger Peppe <[email protected]> Change-Id: Ib57d02be507ad08e7ad726b6c85696d662f50cec Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1201986 Reviewed-by: Daniel Martí <[email protected]> TryBot-Result: CUEcueckoo <[email protected]> Unity-Result: CUE porcuepine <[email protected]>
1 parent 92330b4 commit 093a2c6

File tree

10 files changed

+69
-1080
lines changed

10 files changed

+69
-1080
lines changed

.github/workflows/trybot.yaml

+6-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,12 @@ jobs:
167167
exit 1
168168
fi
169169
- name: Generate
170-
run: go generate ./...
170+
env:
171+
CUE_LOGINS: ${{ secrets.NOTCUECKOO_CUE_LOGINS }}
172+
run: |-
173+
export CUE_CONFIG_DIR=$(mktemp -d)
174+
echo "$CUE_LOGINS" > $CUE_CONFIG_DIR/logins.json
175+
go generate ./...
171176
if: (matrix.go-version == '1.23.x' && matrix.runner == 'ubuntu-22.04')
172177
- name: Check that git is clean at the end of the job
173178
if: always()

cue.mod/module.cue

+6
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,9 @@ module: "cuelang.org/go"
22
language: {
33
version: "v0.8.0"
44
}
5+
deps: {
6+
"github.com/cue-tmp/jsonschema-pub/exp1/githubactions@v0": {
7+
v: "v0.3.0"
8+
default: true
9+
}
10+
}

cue.mod/pkg/github.com/SchemaStore/schemastore/src/schemas/json/github-workflow.cue

-977
This file was deleted.

cue.mod/usr/github.com/SchemaStore/schemastore/src/schemas/json/workflow.cue

-4
This file was deleted.

internal/ci/base/gerrithub.cue

+11-11
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ package base
33
// This file contains gerrithub related definitions etc
44

55
import (
6-
encjson "encoding/json"
6+
"encoding/json"
77
"strings"
88

9-
"github.com/SchemaStore/schemastore/src/schemas/json"
9+
"github.com/cue-tmp/jsonschema-pub/exp1/githubactions"
1010
)
1111

1212
// trybotWorkflows is a template for trybot-based repos
1313
trybotWorkflows: {
14-
(trybot.key): json.#Workflow & {
14+
(trybot.key): githubactions.#Workflow & {
1515
on: workflow_dispatch: {}
1616
}
1717
"\(trybot.key)_dispatch": trybotDispatchWorkflow
@@ -45,7 +45,7 @@ trybotDispatchWorkflow: bashWorkflow & {
4545
(trybot.key): {
4646
"runs-on": linuxMachine
4747

48-
let goodDummyData = [if encjson.Marshal(#dummyDispatch) != _|_ {true}, false][0]
48+
let goodDummyData = [if json.Marshal(#dummyDispatch) != _|_ {true}, false][0]
4949

5050
// We set the "on" conditions above, but this would otherwise mean we
5151
// run for all dispatch events.
@@ -68,7 +68,7 @@ trybotDispatchWorkflow: bashWorkflow & {
6868
steps: [
6969
writeNetrcFile,
7070

71-
json.#step & {
71+
githubactions.#Step & {
7272
name: "Write fake payload"
7373
id: "payload"
7474
if: "github.repository == '\(githubRepositoryPath)' && \(isTestDefaultBranch)"
@@ -80,7 +80,7 @@ trybotDispatchWorkflow: bashWorkflow & {
8080
run: #"""
8181
cat <<EOD >> $GITHUB_OUTPUT
8282
value<<DOE
83-
\#(*encjson.Marshal(#dummyDispatch) | "null")
83+
\#(*json.Marshal(#dummyDispatch) | "null")
8484
DOE
8585
EOD
8686
"""#
@@ -97,7 +97,7 @@ trybotDispatchWorkflow: bashWorkflow & {
9797
for v in cases {
9898
let localBranchExpr = "local_${{ \(v.expr).targetBranch }}"
9999
let targetBranchExpr = "${{ \(v.expr).targetBranch }}"
100-
json.#step & {
100+
githubactions.#Step & {
101101
name: "Trigger \(trybot.name) (\(v.nameSuffix))"
102102
if: "github.event.client_payload.type \(v.condition) '\(trybot.key)'"
103103
run: """
@@ -174,7 +174,7 @@ pushTipToTrybotWorkflow: bashWorkflow & {
174174
jobs: push: {
175175
steps: [
176176
writeNetrcFile,
177-
json.#step & {
177+
githubactions.#Step & {
178178
name: "Push tip to trybot"
179179
run: """
180180
mkdir tmpgit
@@ -248,7 +248,7 @@ evictCaches: bashWorkflow & {
248248
steps: [
249249
for v in checkoutCode {v},
250250

251-
json.#step & {
251+
githubactions.#Step & {
252252
name: "Delete caches"
253253
run: """
254254
set -x
@@ -269,7 +269,7 @@ evictCaches: bashWorkflow & {
269269
"""
270270
},
271271

272-
json.#step & {
272+
githubactions.#Step & {
273273
name: "Trigger workflow runs to repopulate caches"
274274
let branchPatterns = strings.Join(protectedBranchPatterns, " ")
275275

@@ -343,7 +343,7 @@ evictCaches: bashWorkflow & {
343343
}
344344
}
345345

346-
writeNetrcFile: json.#step & {
346+
writeNetrcFile: githubactions.#Step & {
347347
name: "Write netrc file for \(botGerritHubUser) Gerrithub"
348348
run: """
349349
cat <<EOD > ~/.netrc

internal/ci/base/github.cue

+20-20
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ package base
33
// This file contains aspects principally related to GitHub workflows
44

55
import (
6-
encjson "encoding/json"
6+
"encoding/json"
77
"list"
88
"strings"
99
"strconv"
1010

11-
"github.com/SchemaStore/schemastore/src/schemas/json"
11+
"github.com/cue-tmp/jsonschema-pub/exp1/githubactions"
1212
)
1313

14-
bashWorkflow: json.#Workflow & {
14+
bashWorkflow: githubactions.#Workflow & {
1515
jobs: [string]: defaults: run: shell: "bash"
1616
}
1717

1818
installGo: {
19-
#setupGo: json.#step & {
19+
#setupGo: githubactions.#Step & {
2020
name: "Install Go"
2121
uses: "actions/setup-go@v5"
2222
with: {
@@ -49,7 +49,7 @@ installGo: {
4949
#setupGo,
5050

5151
{
52-
json.#step & {
52+
githubactions.#Step & {
5353
name: "Set common go env vars"
5454
run: """
5555
go env -w GOTOOLCHAIN=local
@@ -63,7 +63,7 @@ installGo: {
6363
}
6464

6565
checkoutCode: {
66-
#actionsCheckout: json.#step & {
66+
#actionsCheckout: githubactions.#Step & {
6767
name: "Checkout code"
6868
uses: "actions/checkout@v4"
6969

@@ -90,17 +90,17 @@ checkoutCode: {
9090
// per the bug report at https://github.com/MestreLion/git-tools/issues/47,
9191
// so we first reset all directory timestamps to a static time as a fallback.
9292
// TODO(mvdan): May be unnecessary once the Go bug above is fixed.
93-
json.#step & {
93+
githubactions.#Step & {
9494
name: "Reset git directory modification times"
9595
run: "touch -t 202211302355 $(find * -type d)"
9696
},
97-
json.#step & {
97+
githubactions.#Step & {
9898
name: "Restore git file modification times"
9999
uses: "chetan/git-restore-mtime-action@075f9bc9d159805603419d50f794bd9f33252ebe"
100100
},
101101

102102
{
103-
json.#step & {
103+
githubactions.#Step & {
104104
name: "Try to extract \(dispatchTrailer)"
105105
id: dispatchTrailerStepID
106106
run: """
@@ -124,7 +124,7 @@ checkoutCode: {
124124

125125
// Safety nets to flag if we ever have a Dispatch-Trailer slip through the
126126
// net and make it to master
127-
json.#step & {
127+
githubactions.#Step & {
128128
name: "Check we don't have \(dispatchTrailer) on a protected branch"
129129
if: "\(isProtectedBranch) && \(containsDispatchTrailer)"
130130
run: """
@@ -135,7 +135,7 @@ checkoutCode: {
135135
]
136136
}
137137

138-
earlyChecks: json.#step & {
138+
earlyChecks: githubactions.#Step & {
139139
name: "Early git and code sanity checks"
140140
run: *"go run cuelang.org/go/internal/ci/[email protected]" | string
141141
}
@@ -177,7 +177,7 @@ setupGoActionsCaches: {
177177

178178
let cacheRestoreKeys = "\(#os)-\(#goVersion)"
179179

180-
let cacheStep = json.#step & {
180+
let cacheStep = githubactions.#Step & {
181181
with: {
182182
path: strings.Join(cacheDirs, "\n")
183183

@@ -197,12 +197,12 @@ setupGoActionsCaches: {
197197
[
198198
// TODO: once https://github.com/actions/setup-go/issues/54 is fixed,
199199
// we could use `go env` outputs from the setup-go step.
200-
json.#step & {
200+
githubactions.#Step & {
201201
name: "Get go mod cache directory"
202202
id: goModCacheDirID
203203
run: #"echo "dir=$(go env GOMODCACHE)" >> ${GITHUB_OUTPUT}"#
204204
},
205-
json.#step & {
205+
githubactions.#Step & {
206206
name: "Get go build/test cache directory"
207207
id: goCacheDirID
208208
run: #"echo "dir=$(go env GOCACHE)" >> ${GITHUB_OUTPUT}"#
@@ -240,7 +240,7 @@ setupGoActionsCaches: {
240240
//
241241
// Critically we only want to do this in the main repo, not the trybot
242242
// repo.
243-
json.#step & {
243+
githubactions.#Step & {
244244
if: "github.repository == '\(githubRepositoryPath)' && (\(isProtectedBranch) || github.ref == 'refs/heads/\(testDefaultBranch)')"
245245
run: "go clean -testcache"
246246
}
@@ -270,13 +270,13 @@ isReleaseTag: {
270270
(_matchPattern & {variable: "github.ref", pattern: "refs/tags/\(releaseTagPattern)"}).expr
271271
}
272272

273-
checkGitClean: json.#step & {
273+
checkGitClean: githubactions.#Step & {
274274
name: "Check that git is clean at the end of the job"
275275
if: "always()"
276276
run: "test -z \"$(git status --porcelain)\" || (git status; git diff; false)"
277277
}
278278

279-
repositoryDispatch: json.#step & {
279+
repositoryDispatch: githubactions.#Step & {
280280
#githubRepositoryPath: *githubRepositoryPath | string
281281
#botGitHubUserTokenSecretsKey: *botGitHubUserTokenSecretsKey | string
282282
#arg: _
@@ -285,11 +285,11 @@ repositoryDispatch: json.#step & {
285285

286286
name: string
287287
run: #"""
288-
\#(_curlGitHubAPI) --fail --request POST --data-binary \#(strconv.Quote(encjson.Marshal(#arg))) https://api.github.com/repos/\#(#githubRepositoryPath)/dispatches
288+
\#(_curlGitHubAPI) --fail --request POST --data-binary \#(strconv.Quote(json.Marshal(#arg))) https://api.github.com/repos/\#(#githubRepositoryPath)/dispatches
289289
"""#
290290
}
291291

292-
workflowDispatch: json.#step & {
292+
workflowDispatch: githubactions.#Step & {
293293
#githubRepositoryPath: *githubRepositoryPath | string
294294
#botGitHubUserTokenSecretsKey: *botGitHubUserTokenSecretsKey | string
295295
#workflowID: string
@@ -303,7 +303,7 @@ workflowDispatch: json.#step & {
303303

304304
name: string
305305
run: #"""
306-
\#(_curlGitHubAPI) --fail --request POST --data-binary \#(strconv.Quote(encjson.Marshal(#params))) https://api.github.com/repos/\#(#githubRepositoryPath)/actions/workflows/\#(#workflowID)/dispatches
306+
\#(_curlGitHubAPI) --fail --request POST --data-binary \#(strconv.Quote(json.Marshal(#params))) https://api.github.com/repos/\#(#githubRepositoryPath)/actions/workflows/\#(#workflowID)/dispatches
307307
"""#
308308
}
309309

internal/ci/gen.go

-1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,4 @@
1414

1515
package ci
1616

17-
//go:generate go run cuelang.org/go/cmd/cue cmd importjsonschema ./vendor
1817
//go:generate go run cuelang.org/go/cmd/cue cmd gen

internal/ci/github/release.cue

+7-7
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ package github
1717
import (
1818
"list"
1919

20-
"github.com/SchemaStore/schemastore/src/schemas/json"
20+
"github.com/cue-tmp/jsonschema-pub/exp1/githubactions"
2121
)
2222

2323
// _cueVersionRef is a workflow job-runtime expression that evaluates to the
@@ -50,15 +50,15 @@ workflows: release: _repo.bashWorkflow & {
5050
steps: [
5151
for v in _repo.checkoutCode {v},
5252
for v in installGo {v},
53-
json.#step & {
53+
githubactions.#Step & {
5454
name: "Setup qemu"
5555
uses: "docker/setup-qemu-action@v3"
5656
},
57-
json.#step & {
57+
githubactions.#Step & {
5858
name: "Set up Docker Buildx"
5959
uses: "docker/setup-buildx-action@v3"
6060
},
61-
json.#step & {
61+
githubactions.#Step & {
6262
name: "Docker Login"
6363
uses: "docker/login-action@v3"
6464
with: {
@@ -67,19 +67,19 @@ workflows: release: _repo.bashWorkflow & {
6767
password: "${{ secrets.CUECKOO_DOCKER_PAT }}"
6868
}
6969
},
70-
json.#step & {
70+
githubactions.#Step & {
7171
name: "Install CUE"
7272
run: "go install ./cmd/cue"
7373
},
74-
json.#step & {
74+
githubactions.#Step & {
7575
name: "Install GoReleaser"
7676
uses: "goreleaser/goreleaser-action@v5"
7777
with: {
7878
"install-only": true
7979
version: _repo.goreleaserVersion
8080
}
8181
},
82-
json.#step & {
82+
githubactions.#Step & {
8383
// Note that the logic for what gets run at release time
8484
// is defined with the release command in CUE.
8585
name: "Run GoReleaser with CUE"

0 commit comments

Comments
 (0)