Skip to content

Commit 4ef5060

Browse files
authored
CUS-349: CI: enable remote execution in jobs that can use it (#45)
Added platform and C++ toolchain configurations for platforms we use that have configured remote execution pools. This is mostly copied from github.com/EngFlow/examples. In .bazelrc, added platform configurations like remote_linux_x64. One of these needs to be specified when using remote execution. Also, rename the opal configuration to engflow and split out engflow_bes. We'll only support one cluster for this repo. In workflows, added --config=<remote_platform> and replaced the CLUSTER_CONFIG environment variable with either engflow or engflow_bes as appropriate. The jobs driven with 'bazel run' cannot use remote execution because that always runs on the host, so they're engflow_bes.
1 parent cd40f05 commit 4ef5060

File tree

18 files changed

+10667
-38
lines changed

18 files changed

+10667
-38
lines changed

.bazelrc

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,46 @@ build:noninteractive --keep_going
2424
build:release --config=noninteractive
2525
build:release --stamp
2626

27+
# Platform-specific options for each supported platform.
28+
build:remote_linux_x64 --extra_execution_platforms=//platform/linux_x64
29+
build:remote_linux_x64 --extra_toolchains=//platform/linux_x64:cc-toolchain
30+
build:remote_linux_x64 --host_platform=//platform/linux_x64
31+
build:remote_linux_x64 --platforms=//platform/linux_x64
32+
33+
build:remote_macos_x64 --extra_execution_platforms=//platform/macos_x64
34+
build:remote_macos_x64 --host_action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
35+
build:remote_macos_x64 --host_platform=//platform/macos_x64
36+
build:remote_macos_x64 --macos_minimum_os=12
37+
build:remote_macos_x64 --platforms=//platform/macos_x64
38+
39+
build:remote_windows_x64 --extra_execution_platforms=//platform/windows_x64
40+
build:remote_windows_x64 --extra_toolchains=//platform/windows_x64:cc-toolchain
41+
build:remote_windows_x64 --host_platform=//platform/windows_x64
42+
build:remote_windows_x64 --platforms=//platform/windows_x64
43+
44+
# Options for EngFlow remote execution.
2745
build:engflow_common --jobs=40
2846
build:engflow_common --define=EXECUTOR=remote
2947
build:engflow_common --experimental_inmemory_dotd_files
3048
build:engflow_common --experimental_inmemory_jdeps_files
3149
build:engflow_common --incompatible_strict_action_env=true
3250
build:engflow_common --remote_timeout=600
33-
build:engflow_common --legacy_important_outputs=false
51+
build:engflow_common --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
3452
build:engflow_common --grpc_keepalive_time=30s
3553
build:engflow_common --experimental_remote_cache_compression=true
36-
build:engflow_common --remote_instance_name=auth
37-
build:engflow_common --bes_instance_name=auth
38-
build:engflow_common --bes_lifecycle_events
54+
build:engflow_common --remote_download_minimal
55+
56+
build:engflow_bes --bes_backend=grpcs://opal.cluster.engflow.com
57+
build:engflow_bes --bes_results_url=https://opal.cluster.engflow.com/invocations/auth/
58+
build:engflow_bes --bes_instance_name=auth
59+
build:engflow_bes --bes_lifecycle_events
3960

40-
build:opal --config=engflow_common
41-
build:opal --bes_backend=grpcs://opal.cluster.engflow.com
42-
build:opal --bes_results_url=https://opal.cluster.engflow.com/invocations/auth/
43-
# TODO(CUS-349): enable remote execution
61+
build:engflow --config=engflow_common
62+
build:engflow --config=engflow_bes
63+
build:engflow --remote_executor=grpcs://opal.cluster.engflow.com
64+
build:engflow --remote_instance_name=auth
4465

45-
# Load authentication flags for the remote service, if any.
66+
# To authenticate with the clusters above, either add flags to this
67+
# .bazelrc.user file or to your $HOME/.bazelrc. These files may contain
68+
# credentials and local file system paths, so they're not checked in.
4669
try-import .bazelrc.user

.github/workflows/main.yml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@ env:
2828
# Recommended here: https://github.com/bazelbuild/bazelisk/issues/88#issuecomment-625178467
2929
BAZELISK_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3030
CLUSTER_HOST: opal.cluster.engflow.com
31-
CLUSTER_CONFIG: opal
3231
CRED_HELPER_TOKEN: ${{ secrets.OPAL_CRED_HELPER_TOKEN }}
3332
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34-
OPAL_RPC_CREDENTIALS: ${{ secrets.OPAL_RPC_CREDENTIALS }}
3533

3634
jobs:
3735
# TODO(OND-616): use remote execution and caching for all CI Runner jobs.
@@ -44,7 +42,7 @@ jobs:
4442
- "engflow-pool=ci_sysbox_x64"
4543
- "engflow-runtime=sysbox-runc"
4644
- "engflow-runner-id=${{ github.repository_id }}_bazel-builder_${{ github.run_id }}_${{ github.run_number }}_${{ github.run_attempt }}"
47-
timeout-minutes: 10
45+
timeout-minutes: 30
4846

4947
env:
5048
ARCH: "x64"
@@ -59,8 +57,7 @@ jobs:
5957
- name: Run all tests
6058
if: success()
6159
run: |
62-
# TODO(CUS-345): Enable remote execution
63-
bazel test --config=noninteractive --config="${CLUSTER_CONFIG}" //...
60+
bazel test --config=noninteractive --config=engflow --config=remote_linux_x64 //...
6461
6562
- name: Log out
6663
run: infra/logout.sh
@@ -106,8 +103,8 @@ jobs:
106103
shell: bash
107104
run: |
108105
# TODO(CUS-345): Enable remote execution
109-
bazel run --config=noninteractive --config="${CLUSTER_CONFIG}" @rules_go//go -- test ./...
110-
bazel run --config=noninteractive --config="${CLUSTER_CONFIG}" @rules_go//go -- clean -cache -modcache
106+
bazel run --config=noninteractive --config=engflow_bes @rules_go//go -- test ./...
107+
bazel run --config=noninteractive --config=engflow_bes @rules_go//go -- clean -cache -modcache
111108
112109
- name: Log out
113110
shell: bash
@@ -138,8 +135,8 @@ jobs:
138135
if: success()
139136
run: |
140137
# TODO(CUS-345): Enable remote execution
141-
bazel run --config=noninteractive @rules_go//go -- test ./...
142-
bazel run --config=noninteractive @rules_go//go -- clean -cache -modcache
138+
bazel run --config=noninteractive --config=engflow_bes @rules_go//go -- test ./...
139+
bazel run --config=noninteractive --config=engflow_bes @rules_go//go -- clean -cache -modcache
143140
144141
- name: Log out
145142
run: infra/logout.sh
@@ -168,7 +165,7 @@ jobs:
168165
- name: Check copyright headers
169166
if: success()
170167
run: |
171-
bazel run --config=noninteractive --config="${CLUSTER_CONFIG}" //infra/internal/check_copyright_headers
168+
bazel run --config=noninteractive --config=engflow_bes //infra/internal/check_copyright_headers
172169
173170
- name: Log out
174171
run: infra/logout.sh

.github/workflows/presubmit.yml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,10 @@ env:
3030
# Recommended here: https://github.com/bazelbuild/bazelisk/issues/88#issuecomment-625178467
3131
BAZELISK_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3232
CLUSTER_HOST: opal.cluster.engflow.com
33-
CLUSTER_CONFIG: opal
3433
CRED_HELPER_TOKEN: ${{ secrets.OPAL_CRED_HELPER_TOKEN }}
3534
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3635

3736
jobs:
38-
# TODO(OND-616): use remote execution and caching for all CI Runner jobs.
3937
bazel-builder:
4038
runs-on:
4139
- self-hosted
@@ -45,7 +43,7 @@ jobs:
4543
- "engflow-pool=ci_sysbox_x64"
4644
- "engflow-runtime=sysbox-runc"
4745
- "engflow-runner-id=${{ github.repository_id }}_bazel-builder_${{ github.run_id }}_${{ github.run_number }}_${{ github.run_attempt }}"
48-
timeout-minutes: 10
46+
timeout-minutes: 30
4947

5048
env:
5149
ARCH: "x64"
@@ -60,8 +58,11 @@ jobs:
6058
- name: Run all tests
6159
if: success()
6260
run: |
63-
# TODO(CUS-345): Enable remote execution
64-
bazel test --config=noninteractive --config="${CLUSTER_CONFIG}" //...
61+
bazel test \
62+
--config=noninteractive \
63+
--config=engflow \
64+
--config=remote_linux_x64 \
65+
//...
6566
6667
- name: Log out
6768
run: infra/logout.sh
@@ -107,8 +108,8 @@ jobs:
107108
shell: bash
108109
run: |
109110
# TODO(CUS-345): Enable remote execution
110-
bazel run --config=noninteractive --config="${CLUSTER_CONFIG}" @rules_go//go -- test ./...
111-
bazel run --config=noninteractive --config="${CLUSTER_CONFIG}" @rules_go//go -- clean -cache -modcache
111+
bazel run --config=noninteractive --config=engflow_bes @rules_go//go -- test ./...
112+
bazel run --config=noninteractive --config=engflow_bes @rules_go//go -- clean -cache -modcache
112113
113114
- name: Log out
114115
shell: bash
@@ -139,8 +140,8 @@ jobs:
139140
if: success()
140141
run: |
141142
# TODO(CUS-345): Enable remote execution
142-
bazel run --config=noninteractive --config="${CLUSTER_CONFIG}" @rules_go//go -- test ./...
143-
bazel run --config=noninteractive --config="${CLUSTER_CONFIG}" @rules_go//go -- clean -cache -modcache
143+
bazel run --config=noninteractive --config=engflow_bes @rules_go//go -- test ./...
144+
bazel run --config=noninteractive --config=engflow_bes @rules_go//go -- clean -cache -modcache
144145
145146
- name: Log out
146147
run: infra/logout.sh
@@ -169,7 +170,7 @@ jobs:
169170
- name: Check copyright headers
170171
if: success()
171172
run: |
172-
bazel run --config=noninteractive --config="${CLUSTER_CONFIG}" //infra/internal/check_copyright_headers
173+
bazel run --config=noninteractive --config=engflow_bes //infra/internal/check_copyright_headers
173174
174175
- name: Log out
175176
run: infra/logout.sh

.github/workflows/release.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ permissions:
2626
contents: write
2727

2828
jobs:
29-
# TODO(OND-616): use remote execution and caching for all CI Runner jobs.
3029
release:
3130
runs-on:
3231
- self-hosted
@@ -40,8 +39,16 @@ jobs:
4039

4140
steps:
4241
- uses: actions/checkout@v4
42+
43+
- name: Log in
44+
run: infra/login.sh
45+
4346
- name: release
47+
if: success()
4448
run: |
4549
infra/release.sh "${{ inputs.version }}"
4650
env:
4751
GITHUB_TOKEN: ${{ github.token }}
52+
53+
- name: Log out
54+
run: infra/logout.sh

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
bazel-*
2+
.bazelrc.user
23

34
# TODO(CUS-389): This file seems to thrash contents between builds (possibly due
45
# to VSCode extension behavior). Ignore changes until we can better understand

cmd/engflow_auth/BUILD

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ go_test(
3434
"//internal/oauthdevice",
3535
"//internal/oauthtoken",
3636
"@com_github_stretchr_testify//assert",
37-
"@com_github_zalando_go_keyring//:go-keyring",
3837
"@org_golang_x_oauth2//:oauth2",
3938
],
4039
)

cmd/engflow_auth/main_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,12 @@ import (
3030
"github.com/EngFlow/auth/internal/oauthdevice"
3131
"github.com/EngFlow/auth/internal/oauthtoken"
3232
"github.com/stretchr/testify/assert"
33-
"github.com/zalando/go-keyring"
3433
"golang.org/x/oauth2"
3534
)
3635

3736
func init() {
3837
// Tests should not interact with the user's real keyring.
39-
keyring.MockInit()
38+
oauthtoken.KeyringMockInit()
4039
}
4140

4241
func codedErrorContains(t *testing.T, gotErr error, code int, wantMsg string) bool {

infra/internal/check_copyright_headers/main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ var (
3030
skipRegexps = []*regexp.Regexp{
3131
regexp.MustCompile(`^go\.mod$`),
3232
regexp.MustCompile(`^go\.sum$`),
33-
regexp.MustCompile(`^LICENSE$`),
33+
regexp.MustCompile(`(^|/)LICENSE$`),
3434
regexp.MustCompile(`^MODULE\.bazel\.lock$`),
3535
regexp.MustCompile(`^MODULE\.bazel$`),
3636
regexp.MustCompile(`^README.md$`),
@@ -40,6 +40,8 @@ var (
4040
regexp.MustCompile(`^\.bazelversion$`),
4141
regexp.MustCompile(`^\.gitignore$`),
4242
regexp.MustCompile(`\.bzl$`),
43+
regexp.MustCompile(`^platform/linux_x64/builtin_include_directory_paths`),
44+
regexp.MustCompile(`^platform/linux_x64/module.modulemap`),
4345
}
4446
copyrightRegexp = regexp.MustCompile(`^(#|//) Copyright [0-9-]+ EngFlow Inc\.`)
4547
)

infra/release.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ echo "[START] Building artifacts"
8585
BUILD_RELEASE_VERSION="${RELEASE_VERSION}" \
8686
bazel build \
8787
--config=release \
88+
--config=engflow \
89+
--config=remote_linux_x64 \
8890
-- \
8991
//:release_artifacts
9092
echo "[FINISH] Building artifacts"

internal/oauthtoken/keyring.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ import (
2525
"golang.org/x/oauth2"
2626
)
2727

28+
// KeyringMockInit initializes this package so that its methods may be called
29+
// from a test without reading or writing external state.
30+
func KeyringMockInit() {
31+
mockUsername = "test"
32+
keyring.MockInit()
33+
}
34+
35+
var mockUsername string = ""
36+
2837
type keyringNotFoundError struct {
2938
service string
3039
user string
@@ -47,12 +56,16 @@ type Keyring struct {
4756
var _ LoadStorer = (*Keyring)(nil)
4857

4958
func NewKeyring() (LoadStorer, error) {
50-
u, err := user.Current()
51-
if err != nil {
52-
return nil, err
59+
username := mockUsername
60+
if username == "" {
61+
u, err := user.Current()
62+
if err != nil {
63+
return nil, err
64+
}
65+
username = u.Username
5366
}
5467
return &Keyring{
55-
username: u.Username,
68+
username: username,
5669
}, nil
5770
}
5871

0 commit comments

Comments
 (0)