Skip to content

Commit 6d3530b

Browse files
committed
internal/ci: split Linux runners into "small" and "large"
Cheap workflows like "tip triggers" and "trybot dispatch" do not need as much CPU and memory as expensive trybot workflows, so those always use the small runner. The trybot runner still uses "linuxMachine", which now defaults to the small runner, but can be opted into the large runner for those repositories which really need it. The majority of them should be perfectly fine on the smaller machine with half as much CPU and memory. The "small" size has been chosen in a relatively conservative way, only being half as large as the "large" machine. This is because even the public GitHub runners have four CPU cores and 16 GiB of RAM, so going all the way down to 2 CPU cores and 4 GiB might be too low. Thankfully, now that the split is made here, and given that these runner profiles have generic "small" and "large" names, we can later resize either of them without having to re-configure all repos. Signed-off-by: Daniel Martí <[email protected]> Change-Id: Ib62b2ef79cd7a6d64413b426843abbfdb5627e2a Reviewed-on: https://cue.gerrithub.io/c/cue-lang/cue/+/1218980 Unity-Result: CUE porcuepine <[email protected]> Reviewed-by: Paul Jolly <[email protected]> TryBot-Result: CUEcueckoo <[email protected]>
1 parent 5cc6d81 commit 6d3530b

File tree

9 files changed

+43
-20
lines changed

9 files changed

+43
-20
lines changed

.github/workflows/push_tip_to_trybot.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
defaults:
77
run:
88
shell: bash --noprofile --norc -euo pipefail {0}
9-
runs-on: ns-linux-amd64
9+
runs-on: ns-linux-amd64-small
1010
if: ${{github.repository == 'cue-lang/cue'}}
1111
steps:
1212
- name: Write netrc file for cueckoo Gerrithub

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
defaults:
1717
run:
1818
shell: bash --noprofile --norc -euo pipefail {0}
19-
runs-on: ns-linux-amd64
19+
runs-on: ns-linux-amd64-large
2020
if: ${{github.repository == 'cue-lang/cue'}}
2121
steps:
2222
- name: Checkout code

.github/workflows/tip_triggers.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
defaults:
1212
run:
1313
shell: bash --noprofile --norc -euo pipefail {0}
14-
runs-on: ns-linux-amd64
14+
runs-on: ns-linux-amd64-small
1515
if: ${{github.repository == 'cue-lang/cue'}}
1616
steps:
1717
- name: Trigger unity build

.github/workflows/trybot.yaml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- 1.23.x
2626
- 1.24.x
2727
runner:
28-
- ns-linux-amd64
28+
- ns-linux-amd64-large
2929
- ns-macos-arm64
3030
- ns-windows-amd64
3131
runs-on: ${{ matrix.runner }}
@@ -94,22 +94,22 @@ jobs:
9494
Dispatch-Trailer: {"type":"')))) || (github.ref == 'refs/heads/ci/test'))
9595
run: go env -w GOFLAGS=-count=1
9696
- run: go run cuelang.org/go/cmd/cue login --token=${{ secrets.NOTCUECKOO_CUE_TOKEN }}
97-
- if: (matrix.go-version == '1.24.x' && matrix.runner == 'ns-linux-amd64')
97+
- if: (matrix.go-version == '1.24.x' && matrix.runner == 'ns-linux-amd64-large')
9898
name: Early git and code sanity checks
9999
run: go run ./internal/ci/checks
100100
- if: |-
101101
((github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release-branch.')) && (! (contains(github.event.head_commit.message, '
102-
Dispatch-Trailer: {"type":"')))) || !(matrix.go-version == '1.24.x' && matrix.runner == 'ns-linux-amd64')
102+
Dispatch-Trailer: {"type":"')))) || !(matrix.go-version == '1.24.x' && matrix.runner == 'ns-linux-amd64-large')
103103
name: Test
104104
run: go test ./...
105-
- if: (matrix.go-version == '1.24.x' && matrix.runner == 'ns-linux-amd64')
105+
- if: (matrix.go-version == '1.24.x' && matrix.runner == 'ns-linux-amd64-large')
106106
name: Test with -race
107107
env:
108108
GORACE: atexit_sleep_ms=10
109109
run: go test -race ./...
110110
- if: |-
111111
(((github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release-branch.')) && (! (contains(github.event.head_commit.message, '
112-
Dispatch-Trailer: {"type":"')))) || (github.ref == 'refs/heads/ci/test')) && (matrix.go-version == '1.24.x' && matrix.runner == 'ns-linux-amd64')
112+
Dispatch-Trailer: {"type":"')))) || (github.ref == 'refs/heads/ci/test')) && (matrix.go-version == '1.24.x' && matrix.runner == 'ns-linux-amd64-large')
113113
name: Test on 32 bits
114114
env:
115115
GOARCH: "386"
@@ -119,32 +119,32 @@ jobs:
119119
- id: auth
120120
if: |-
121121
github.repository == 'cue-lang/cue' && (((github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release-branch.')) && (! (contains(github.event.head_commit.message, '
122-
Dispatch-Trailer: {"type":"')))) || (github.ref == 'refs/heads/ci/test')) && (matrix.go-version == '1.24.x' && matrix.runner == 'ns-linux-amd64')
122+
Dispatch-Trailer: {"type":"')))) || (github.ref == 'refs/heads/ci/test')) && (matrix.go-version == '1.24.x' && matrix.runner == 'ns-linux-amd64-large')
123123
name: gcloud auth for end-to-end tests
124124
uses: google-github-actions/auth@v2
125125
with:
126126
credentials_json: ${{ secrets.E2E_GCLOUD_KEY }}
127127
- if: |-
128128
github.repository == 'cue-lang/cue' && (((github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release-branch.')) && (! (contains(github.event.head_commit.message, '
129-
Dispatch-Trailer: {"type":"')))) || (github.ref == 'refs/heads/ci/test')) && (matrix.go-version == '1.24.x' && matrix.runner == 'ns-linux-amd64')
129+
Dispatch-Trailer: {"type":"')))) || (github.ref == 'refs/heads/ci/test')) && (matrix.go-version == '1.24.x' && matrix.runner == 'ns-linux-amd64-large')
130130
name: gcloud setup for end-to-end tests
131131
uses: google-github-actions/setup-gcloud@v2
132132
- if: |-
133133
github.repository == 'cue-lang/cue' && (((github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release-branch.')) && (! (contains(github.event.head_commit.message, '
134-
Dispatch-Trailer: {"type":"')))) || (github.ref == 'refs/heads/ci/test')) && (matrix.go-version == '1.24.x' && matrix.runner == 'ns-linux-amd64')
134+
Dispatch-Trailer: {"type":"')))) || (github.ref == 'refs/heads/ci/test')) && (matrix.go-version == '1.24.x' && matrix.runner == 'ns-linux-amd64-large')
135135
name: End-to-end test
136136
env:
137137
CUE_TEST_TOKEN: ${{ secrets.E2E_PORCUEPINE_CUE_TOKEN }}
138138
run: |-
139139
cd internal/_e2e
140140
go test -race
141-
- if: (matrix.go-version == '1.24.x' && matrix.runner == 'ns-linux-amd64')
141+
- if: (matrix.go-version == '1.24.x' && matrix.runner == 'ns-linux-amd64-large')
142142
name: Go checks
143143
run: |-
144144
go vet ./...
145145
go mod tidy
146146
(cd internal/_e2e && go test -run=-)
147-
- if: (matrix.go-version == '1.24.x' && matrix.runner == 'ns-linux-amd64')
147+
- if: (matrix.go-version == '1.24.x' && matrix.runner == 'ns-linux-amd64-large')
148148
name: staticcheck
149149
uses: dominikh/staticcheck-action@v1
150150
with:
@@ -153,7 +153,7 @@ jobs:
153153
use-cache: false
154154
- if: |-
155155
(((github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release-branch.')) && (! (contains(github.event.head_commit.message, '
156-
Dispatch-Trailer: {"type":"')))) || (github.ref == 'refs/heads/ci/test')) && (matrix.go-version == '1.24.x' && matrix.runner == 'ns-linux-amd64')
156+
Dispatch-Trailer: {"type":"')))) || (github.ref == 'refs/heads/ci/test')) && (matrix.go-version == '1.24.x' && matrix.runner == 'ns-linux-amd64-large')
157157
name: Check all git tags are available
158158
run: |-
159159
cd $(mktemp -d)
@@ -169,7 +169,7 @@ jobs:
169169
echo "Did you forget about refs/attic branches? https://github.com/cue-lang/cue/wiki/Notes-for-project-maintainers"
170170
exit 1
171171
fi
172-
- if: (matrix.go-version == '1.24.x' && matrix.runner == 'ns-linux-amd64')
172+
- if: (matrix.go-version == '1.24.x' && matrix.runner == 'ns-linux-amd64-large')
173173
name: Generate
174174
run: go generate ./...
175175
- if: always()

.github/workflows/trybot_dispatch.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
defaults:
1212
run:
1313
shell: bash --noprofile --norc -euo pipefail {0}
14-
runs-on: ns-linux-amd64
14+
runs-on: ns-linux-amd64-small
1515
if: ${{ ((github.ref == 'refs/heads/ci/test') && false) || github.event.client_payload.type == 'trybot' }}
1616
steps:
1717
- name: Write netrc file for cueckoo Gerrithub

internal/ci/base/base.cue

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,27 @@ cueCommand: *"cue" | string
6262

6363
workflowFileExtension: ".yaml"
6464

65-
linuxMachine: string | *"ns-linux-amd64"
65+
// Linux is used by lots of repositories for many workflows,
66+
// so each repository can decide which jobs really need larger machines.
67+
// Note that using a larger machine with more CPUs and memory lowers
68+
// the amount of jobs that can be run concurrently at once.
69+
//
70+
// At the time of writing, "small" is 4 CPUs and 8GiB of memory
71+
// and "large" is 8 CPUs and 16GiB of memory.
72+
// With our concurrency limit for Linux at 64 CPUs and 128 GiB,
73+
// using "small" rather than "large" allows 16 rather than 8 jobs at once.
74+
linuxSmallMachine: "ns-linux-amd64-small"
75+
linuxLargeMachine: "ns-linux-amd64-large"
76+
77+
// By default, the main "trybot" test job is run on the small machine.
78+
// Note that cheap workflows, or those which don't keep a human waiting,
79+
// should always use linuxSmallMachine.
80+
linuxMachine: string | *linuxSmallMachine
81+
82+
// MacOS on Namespace doesn't really provide small machines,
83+
// as the smallest is 6 CPUs and 14 GiB on M2 hardware.
84+
// Most repos only test on Linux - it's just the cue repo now -
85+
// so it's actually fine if we always use "large" MacOS and Windows machines.
6686
macosMachine: string | *"ns-macos-arm64"
6787
windowsMachine: string | *"ns-windows-amd64"
6888

internal/ci/base/gerrithub.cue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ trybotDispatchWorkflow: bashWorkflow & {
4747
}
4848
jobs: {
4949
(trybot.key): {
50-
"runs-on": linuxMachine
50+
"runs-on": linuxSmallMachine
5151

5252
let goodDummyData = [if json.Marshal(#dummyDispatch) != _|_ {true}, false][0]
5353

@@ -165,7 +165,7 @@ pushTipToTrybotWorkflow: bashWorkflow & {
165165
push: branches: protectedBranchPatterns
166166
}
167167
jobs: push: {
168-
"runs-on": linuxMachine
168+
"runs-on": linuxSmallMachine
169169
if: "${{github.repository == '\(githubRepositoryPath)'}}"
170170
}
171171

internal/ci/github/tip_triggers.cue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ workflows: tip_triggers: _repo.bashWorkflow & {
2121
name: "Triggers on push to tip"
2222
on: push: branches: [_repo.defaultBranch, _repo.testDefaultBranch]
2323
jobs: push: {
24-
"runs-on": _repo.linuxMachine
24+
"runs-on": _repo.linuxSmallMachine
2525
if: "${{github.repository == '\(_repo.githubRepositoryPath)'}}"
2626
steps: [
2727
_repo.repositoryDispatch & {

internal/ci/repo/repo.cue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ protectedBranchPatterns: [defaultBranch, releaseBranchPattern]
2626
botGitHubUser: "cueckoo"
2727
botGitHubUserEmail: "[email protected]"
2828

29+
// The tests on this repository are pretty CPU-intensive.
30+
linuxMachine: base.linuxLargeMachine
31+
2932
// Use the latest Go version for extra checks,
3033
// such as running tests with the data race detector.
3134
// This may be a release candidate if we are late into a Go release cycle.

0 commit comments

Comments
 (0)