Skip to content

Commit 477351d

Browse files
committed
internal/ci: re-baseline base from cue-lang/cue@2d329b54
Includes: * Use CUE v0.10.0 in go:generate steps (we need a better way of driving this). * Define language.version in the repo's CUE module. * Changes to use new multi-step installGo. * Use go1.23.x as the Go version for the repo. Signed-off-by: Paul Jolly <[email protected]> Change-Id: Icbd05ac770aaf6b49ab400cf9654a1ef7d02e0e1 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue-api-java/+/1200743 TryBot-Result: CUEcueckoo <[email protected]> Reviewed-by: Daniel Martí <[email protected]>
1 parent c4bb242 commit 477351d

File tree

12 files changed

+232
-245
lines changed

12 files changed

+232
-245
lines changed

.github/workflows/evict_caches.yml renamed to .github/workflows/evict_caches.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ jobs:
8989
echo Latest commit: $sha
9090
9191
echo "Trigger workflow on cue-lang/cue-api-java"
92-
curl -s -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.CUECKOO_GITHUB_PAT }}" -H "X-GitHub-Api-Version: 2022-11-28" --fail-with-body -X POST https://api.github.com/repos/cue-lang/cue-api-java/actions/workflows/trybot.yml/dispatches -d "{\"ref\":\"$j\"}"
92+
curl -s -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.CUECKOO_GITHUB_PAT }}" -H "X-GitHub-Api-Version: 2022-11-28" --fail-with-body -X POST https://api.github.com/repos/cue-lang/cue-api-java/actions/workflows/trybot.yaml/dispatches -d "{\"ref\":\"$j\"}"
9393
9494
# Ensure that the trybot repo has the latest commit for
9595
# this branch. If the force-push results in a commit
@@ -121,7 +121,7 @@ jobs:
121121
# We are up-to-date, i.e. the push did nothing, hence we need to trigger a workflow_dispatch
122122
# in the trybot repo.
123123
echo "Trigger workflow on cue-lang/cue-api-java-trybot"
124-
curl -s -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.CUECKOO_GITHUB_PAT }}" -H "X-GitHub-Api-Version: 2022-11-28" --fail-with-body -X POST https://api.github.com/repos/cue-lang/cue-api-java-trybot/actions/workflows/trybot.yml/dispatches -d "{\"ref\":\"$j\"}"
124+
curl -s -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.CUECKOO_GITHUB_PAT }}" -H "X-GitHub-Api-Version: 2022-11-28" --fail-with-body -X POST https://api.github.com/repos/cue-lang/cue-api-java-trybot/actions/workflows/trybot.yaml/dispatches -d "{\"ref\":\"$j\"}"
125125
else
126126
echo "Force-push to cue-lang/cue-api-java-trybot did work; nothing to do"
127127
fi

.github/workflows/trybot.yml renamed to .github/workflows/trybot.yaml

Lines changed: 7 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ jobs:
6666
with:
6767
cache: false
6868
go-version: ${{ matrix.go-version }}
69+
- name: Set common go env vars
70+
run: |-
71+
go env -w GOTOOLCHAIN=local
72+
73+
# Dump env for good measure
74+
go env
6975
- name: Install Java
7076
uses: actions/setup-java@v4
7177
with:
@@ -113,43 +119,7 @@ jobs:
113119
cp libcue.so cue.dll
114120
working-directory: libcue
115121
- name: Early git and code sanity checks
116-
run: |-
117-
# Ensure that commit messages have a blank second line.
118-
# We know that a commit message must be longer than a single
119-
# line because each commit must be signed-off.
120-
if git log --format=%B -n 1 HEAD | sed -n '2{/^$/{q1}}'; then
121-
echo "second line of commit message must be blank"
122-
exit 1
123-
fi
124-
125-
# All authors, including co-authors, must have a signed-off trailer by email.
126-
# Note that trailers are in the form "Name <email>", so grab the email with sed.
127-
# For now, we require the sorted lists of author and signer emails to match.
128-
# Note that this also fails if a commit isn't signed-off at all.
129-
#
130-
# In Gerrit we already enable a form of this via https://gerrit-review.googlesource.com/Documentation/project-configuration.html#require-signed-off-by,
131-
# but it does not support co-authors nor can it be used when testing GitHub PRs.
132-
commit_authors="$(
133-
{
134-
git log -1 --pretty='%ae'
135-
git log -1 --pretty='%(trailers:key=Co-authored-by,valueonly)' | sed -ne 's/.* <\(.*\)>/\1/p'
136-
} | sort -u
137-
)"
138-
commit_signers="$(
139-
{
140-
git log -1 --pretty='%(trailers:key=Signed-off-by,valueonly)' | sed -ne 's/.* <\(.*\)>/\1/p'
141-
} | sort -u
142-
)"
143-
if [[ "${commit_authors}" != "${commit_signers}" ]]; then
144-
echo "Error: commit author email addresses do not match signed-off-by trailers"
145-
echo
146-
echo "Authors:"
147-
echo "${commit_authors}"
148-
echo
149-
echo "Signers:"
150-
echo "${commit_signers}"
151-
exit 1
152-
fi
122+
run: go run cuelang.org/go/internal/ci/[email protected]
153123
- name: Test
154124
run: mvn clean install package
155125
env:

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

Lines changed: 149 additions & 144 deletions
Large diffs are not rendered by default.
Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
package json
22

3-
#job: ((#Workflow & {}).jobs & {x: _}).x
4-
#step: ((#job & {steps: _}).steps & [_])[0]
3+
#job: ((#Workflow & {jobs: _}).jobs & {x: _}).x
4+
#step: ((#job & {steps: _}).steps & [_])[0]
5+
6+
// CUE does not properly encode a JSON Schema oneOf; see
7+
// https://cuelang.org/issue/3165. For now, apply a temporary workaround which
8+
// forces the other option to bottom.
9+
#Workflow: jobs?: [string]: steps?: [...(
10+
{
11+
uses?: _|_
12+
} | {
13+
run?: _|_
14+
}),
15+
]

internal/ci/base/base.cue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import (
3535
)
3636

3737
// Package parameters
38-
githubRepositoryPath: *(URLPath & {#url: githubRepositoryURL, _}) | string
38+
githubRepositoryPath: *(URLPath & {#url: githubRepositoryURL, _}) | string
3939
githubRepositoryURL: *("https://github.com/" + githubRepositoryPath) | string
4040
gerritHubHostname: "review.gerrithub.io"
4141
gerritHubRepositoryURL: *("https://\(gerritHubHostname)/a/" + githubRepositoryPath) | string
@@ -55,7 +55,7 @@ botGerritHubUser: *botGitHubUser | string
5555
botGerritHubUserPasswordSecretsKey: *(strings.ToUpper(botGitHubUser) + "_GERRITHUB_PASSWORD") | string
5656
botGerritHubUserEmail: *botGitHubUserEmail | string
5757

58-
workflowFileExtension: ".yml"
58+
workflowFileExtension: ".yaml"
5959

6060
linuxMachine: string
6161

@@ -67,7 +67,7 @@ codeReview: #codeReview & {
6767
// Define some shared keys and human-readable names.
6868
//
6969
// trybot.key and unity.key are shared with
70-
// github.com/cue-sh/tools/cmd/cueckoo. The keys are used across various CUE
70+
// github.com/cue-lang/contrib-tools/cmd/cueckoo. The keys are used across various CUE
7171
// workflows and their consistency in those various locations is therefore
7272
// crucial. As such, we assert specific values for the keys here rather than
7373
// just deriving values from the human-readable names.

internal/ci/base/codereview.cue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
// #codeReview defines the schema of a codereview.cfg file that
1111
// sits at the root of a repository. codereview.cfg is the configuration
1212
// file that drives golang.org/x/review/git-codereview. This config
13-
// file is also used by github.com/cue-sh/tools/cmd/cueckoo.
13+
// file is also used by github.com/cue-lang/contrib-tools/cmd/cueckoo.
1414
#codeReview: {
1515
gerrit?: string
1616
github?: string

internal/ci/base/github.cue

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,51 @@ bashWorkflow: json.#Workflow & {
1515
jobs: [string]: defaults: run: shell: "bash"
1616
}
1717

18-
installGo: json.#step & {
19-
name: "Install Go"
20-
uses: "actions/setup-go@v5"
21-
with: {
22-
// We do our own caching in setupGoActionsCaches.
23-
cache: false
24-
"go-version": string
18+
installGo: {
19+
#setupGo: json.#step & {
20+
name: "Install Go"
21+
uses: "actions/setup-go@v5"
22+
with: {
23+
// We do our own caching in setupGoActionsCaches.
24+
cache: false
25+
"go-version": string
26+
}
2527
}
28+
29+
// Why set GOTOOLCHAIN here? As opposed to an environment variable
30+
// elsewhere? No perfect answer to this question but here is the thinking:
31+
//
32+
// Setting the variable here localises it with the installation of Go. Doing
33+
// it elsewhere creates distance between the two steps which are
34+
// intrinsically related. And it's also hard to do: "when we use this step,
35+
// also ensure that we establish an environment variable in the job for
36+
// GOTOOLCHAIN".
37+
//
38+
// Environment variables can only be set at a workflow, job or step level.
39+
// Given we currently use a matrix strategy which varies the Go version,
40+
// that rules out using an environment variable based approach, because the
41+
// Go version is only available at runtime via GitHub actions provided
42+
// context. Whether we should instead be templating multiple workflows (i.e.
43+
// exploding the matrix ourselves) is a different question, but one that
44+
// has performance implications.
45+
//
46+
// So as clumsy as it is to use a step "template" that includes more than
47+
// one step, it's the best option available to us for now.
48+
[
49+
#setupGo,
50+
51+
{
52+
json.#step & {
53+
name: "Set common go env vars"
54+
run: """
55+
go env -w GOTOOLCHAIN=local
56+
57+
# Dump env for good measure
58+
go env
59+
"""
60+
}
61+
},
62+
]
2663
}
2764

2865
checkoutCode: {
@@ -100,44 +137,7 @@ checkoutCode: {
100137

101138
earlyChecks: json.#step & {
102139
name: "Early git and code sanity checks"
103-
run: #"""
104-
# Ensure that commit messages have a blank second line.
105-
# We know that a commit message must be longer than a single
106-
# line because each commit must be signed-off.
107-
if git log --format=%B -n 1 HEAD | sed -n '2{/^$/{q1}}'; then
108-
echo "second line of commit message must be blank"
109-
exit 1
110-
fi
111-
112-
# All authors, including co-authors, must have a signed-off trailer by email.
113-
# Note that trailers are in the form "Name <email>", so grab the email with sed.
114-
# For now, we require the sorted lists of author and signer emails to match.
115-
# Note that this also fails if a commit isn't signed-off at all.
116-
#
117-
# In Gerrit we already enable a form of this via https://gerrit-review.googlesource.com/Documentation/project-configuration.html#require-signed-off-by,
118-
# but it does not support co-authors nor can it be used when testing GitHub PRs.
119-
commit_authors="$(
120-
{
121-
git log -1 --pretty='%ae'
122-
git log -1 --pretty='%(trailers:key=Co-authored-by,valueonly)' | sed -ne 's/.* <\(.*\)>/\1/p'
123-
} | sort -u
124-
)"
125-
commit_signers="$(
126-
{
127-
git log -1 --pretty='%(trailers:key=Signed-off-by,valueonly)' | sed -ne 's/.* <\(.*\)>/\1/p'
128-
} | sort -u
129-
)"
130-
if [[ "${commit_authors}" != "${commit_signers}" ]]; then
131-
echo "Error: commit author email addresses do not match signed-off-by trailers"
132-
echo
133-
echo "Authors:"
134-
echo "${commit_authors}"
135-
echo
136-
echo "Signers:"
137-
echo "${commit_signers}"
138-
exit 1
139-
fi
140-
"""#
140+
run: *"go run cuelang.org/go/internal/ci/[email protected]" | string
141141
}
142142

143143
curlGitHubAPI: {

internal/ci/gen.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2024 The CUE Authors
1+
// Copyright 2021 The CUE Authors
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -14,5 +14,5 @@
1414

1515
package ci
1616

17-
//go:generate go run cuelang.org/go/cmd/cue@v0.8.1 cmd importjsonschema ./vendor
18-
//go:generate go run cuelang.org/go/cmd/cue@v0.8.1 cmd gen
17+
//go:generate go run cuelang.org/go/cmd/cue@v0.10.0 cmd importjsonschema ./vendor
18+
//go:generate go run cuelang.org/go/cmd/cue@v0.10.0 cmd gen

0 commit comments

Comments
 (0)