Skip to content

Commit 5a916ae

Browse files
committed
Make test-deployment-bare run on Windows
This uses the WinFSP-based VFS implementation.
1 parent 7cf0fe2 commit 5a916ae

24 files changed

+716
-446
lines changed

.bazelrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
build --cxxopt=-std=c++17
33
build --host_cxxopt=-std=c++17
44

5+
common --enable_platform_specific_config
6+
57
# Don't inherit the user environment as that trashes the cache.
68
build --incompatible_strict_action_env
79
# Use the new way of defining toolchains.
@@ -35,7 +37,13 @@ build:remote-exec --extra_toolchains=//tools/remote-toolchains:all
3537
build:remote-ubuntu-22-04 --config=remote-exec
3638
build:remote-ubuntu-22-04 --extra_execution_platforms=//tools/remote-toolchains:ubuntu-act-22-04-platform
3739

40+
# Workaround https://github.com/bazelbuild/bazel/issues/19733
41+
common:remote-exec-windows --features=-parse_showincludes --host_features=-parse_showincludes
42+
3843
# When running bare executors on your own host machine.
3944
build:remote-local --config=remote-exec
4045

4146
common --incompatible_enable_proto_toolchain_resolution
47+
48+
# Required to make protobuf compile on Windows
49+
common:windows --define=protobuf_allow_msvc=true

.bazelversion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8.0.1
1+
8.3.1

.gitattributes

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# jsonnet fails to recognise blank lines with windows line endings,
2+
# so you get errors like:
3+
# monitoring\prometheus\recording-rules.jsonnet:103:17
4+
# Text block's first line must start with whitespace
5+
# Instead we disable all line ending translation.
6+
* -text

.github/workflows/master.yaml

Lines changed: 130 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,207 @@
11
{
22
"jobs": {
33
"build_and_test": {
4-
"runs-on": "ubuntu-latest",
4+
"name": "build_and_test ${{ matrix.host.os }}",
5+
"runs-on": "${{ matrix.host.os }}",
56
"steps": [
67
{
8+
"name": "Check out source code",
9+
"uses": "actions/checkout@v1"
10+
},
11+
{
12+
"if": "matrix.host.platform_name == 'linux_amd64'",
713
"name": "Installing grpcurl",
814
"run": "mkdir -p ~/.cache/grpcurl &&\ncurl -L https://github.com/fullstorydev/grpcurl/releases/download/v1.8.9/grpcurl_1.8.9_linux_x86_64.tar.gz | tar -xz -C ~/.cache/grpcurl &&\necho \"~/.cache/grpcurl\" >> ${GITHUB_PATH}\n"
915
},
1016
{
17+
"if": "matrix.host.platform_name == 'linux_amd64'",
1118
"name": "Install k3d",
1219
"run": "curl -s https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash"
1320
},
1421
{
15-
"name": "Check out source code",
16-
"uses": "actions/checkout@v1"
22+
"if": "matrix.host.platform_name == 'windows_amd64'",
23+
"name": "Install WinFSP",
24+
"run": "choco install winfsp"
1725
},
1826
{
1927
"name": "Installing Bazel",
20-
"run": "v=$(cat .bazelversion) && curl -L https://github.com/bazelbuild/bazel/releases/download/${v}/bazel-${v}-linux-x86_64 > ~/bazel && chmod +x ~/bazel && echo ~ >> ${GITHUB_PATH}"
28+
"run": "v=$(cat .bazelversion) && curl -L https://github.com/bazelbuild/bazel/releases/download/${v}/bazel-${v}-${{matrix.host.bazel_os}}-x86_64 > ~/bazel && chmod +x ~/bazel && echo ~ >> ${GITHUB_PATH}",
29+
"shell": "bash"
2130
},
2231
{
32+
"if": "matrix.host.platform_name == 'windows_amd64'",
33+
"name": "Override .bazelrc",
34+
"run": "echo \"startup --output_base=D:/bazel_output\" >> .bazelrc"
35+
},
36+
{
37+
"if": "matrix.host.lint",
38+
"name": "Bazel mod tidy",
39+
"run": "bazel mod tidy"
40+
},
41+
{
42+
"if": "matrix.host.lint",
2343
"name": "Gazelle",
24-
"run": "bazel run //:gazelle"
44+
"run": "rm -f $(find . -name '*.pb.go' | sed -e 's/[^/]*$/BUILD.bazel/') && bazel run //:gazelle"
2545
},
2646
{
47+
"if": "matrix.host.lint",
2748
"name": "Buildifier",
28-
"run": "bazel run //:buildifier.check"
49+
"run": "bazel run @com_github_bazelbuild_buildtools//:buildifier"
2950
},
3051
{
52+
"if": "matrix.host.lint",
3153
"name": "Gofmt",
3254
"run": "bazel run @cc_mvdan_gofumpt//:gofumpt -- -w -extra $(pwd)"
3355
},
3456
{
57+
"if": "matrix.host.lint",
58+
"name": "Clang format",
59+
"run": "find . -name '*.proto' -exec bazel run @llvm_toolchain_llvm//:bin/clang-format -- -i {} +"
60+
},
61+
{
62+
"if": "matrix.host.lint",
3563
"name": "GitHub workflows",
3664
"run": "bazel build //tools/github_workflows && cp bazel-bin/tools/github_workflows/*.yaml .github/workflows"
3765
},
3866
{
39-
"name": "Check the diff between docker-compose and Kubernetes configs",
40-
"run": "tools/diff-docker-and-k8s-configs.sh > tools/expected-docker-and-k8s-configs.diff"
67+
"if": "matrix.host.lint",
68+
"name": "Protobuf generation",
69+
"run": "if [ -d pkg/proto ]; then\n find . bazel-bin/pkg/proto -name '*.pb.go' -delete || true\n bazel build $(bazel query --output=label 'kind(\"go_proto_library\", //...)')\n find bazel-bin/pkg/proto -name '*.pb.go' | while read f; do\n cat $f > $(echo $f | sed -e 's|.*/pkg/proto/|pkg/proto/|')\n done\nfi\n"
4170
},
4271
{
43-
"name": "Update versions of the container images",
44-
"run": "tools/update-container-image-versions.sh"
72+
"if": "matrix.host.lint",
73+
"name": "Embedded asset generation",
74+
"run": "bazel build $(git grep '^[[:space:]]*//go:embed ' | sed -e 's|\\(.*\\)/.*//go:embed |//\\1:|; s|\"||g; s| .*||' | sort -u)\ngit grep '^[[:space:]]*//go:embed ' | sed -e 's|\\(.*\\)/.*//go:embed |\\1/|' | while read o; do\n if [ -e \"bazel-bin/$o\" ]; then\n rm -rf \"$o\"\n cp -r \"bazel-bin/$o\" \"$o\"\n find \"$o\" -type f -exec chmod -x {} +\n fi\ndone\n"
4575
},
4676
{
77+
"if": "matrix.host.lint",
4778
"name": "Test style conformance",
48-
"run": "git diff --exit-code HEAD --"
79+
"run": "git add . && git diff --exit-code HEAD --"
4980
},
5081
{
82+
"if": "matrix.host.lint",
5183
"name": "Golint",
5284
"run": "bazel run @org_golang_x_lint//golint -- -set_exit_status $(pwd)/..."
5385
},
5486
{
55-
"name": "Test bare deployment",
56-
"run": "tools/test-deployment-bare.sh"
87+
"if": "matrix.host.cross_compile || matrix.host.platform_name == 'linux_amd64'",
88+
"name": "linux_amd64: build${{ matrix.host.platform_name == 'linux_amd64' && ' and test' || '' }}",
89+
"run": "bazel ${{ matrix.host.platform_name == 'linux_amd64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:linux_amd64 //..."
5790
},
5891
{
59-
"name": "Test docker-compose deployment",
60-
"run": "tools/test-deployment-docker-compose.sh"
92+
"if": "matrix.host.cross_compile || matrix.host.platform_name == 'linux_386'",
93+
"name": "linux_386: build${{ matrix.host.platform_name == 'linux_amd64' && ' and test' || '' }}",
94+
"run": "bazel ${{ matrix.host.platform_name == 'linux_amd64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:linux_386 //..."
6195
},
6296
{
63-
"name": "Test Kubernetes deployment",
64-
"run": "tools/test-deployment-kubernetes"
97+
"if": "matrix.host.cross_compile || matrix.host.platform_name == 'linux_arm'",
98+
"name": "linux_arm: build${{ matrix.host.platform_name == 'linux_arm' && ' and test' || '' }}",
99+
"run": "bazel ${{ matrix.host.platform_name == 'linux_arm' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:linux_arm //..."
65100
},
66101
{
102+
"if": "matrix.host.cross_compile || matrix.host.platform_name == 'linux_arm64'",
103+
"name": "linux_arm64: build${{ matrix.host.platform_name == 'linux_arm64' && ' and test' || '' }}",
104+
"run": "bazel ${{ matrix.host.platform_name == 'linux_arm64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:linux_arm64 //..."
105+
},
106+
{
107+
"if": "matrix.host.cross_compile || matrix.host.platform_name == 'darwin_amd64'",
108+
"name": "darwin_amd64: build${{ matrix.host.platform_name == 'darwin_amd64' && ' and test' || '' }}",
109+
"run": "bazel ${{ matrix.host.platform_name == 'darwin_amd64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:darwin_amd64 //..."
110+
},
111+
{
112+
"if": "matrix.host.cross_compile || matrix.host.platform_name == 'darwin_arm64'",
113+
"name": "darwin_arm64: build${{ matrix.host.platform_name == 'darwin_arm64' && ' and test' || '' }}",
114+
"run": "bazel ${{ matrix.host.platform_name == 'darwin_arm64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:darwin_arm64 //..."
115+
},
116+
{
117+
"if": "matrix.host.cross_compile || matrix.host.platform_name == 'freebsd_amd64'",
118+
"name": "freebsd_amd64: build${{ matrix.host.platform_name == 'freebsd_amd64' && ' and test' || '' }}",
119+
"run": "bazel ${{ matrix.host.platform_name == 'freebsd_amd64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:freebsd_amd64 //..."
120+
},
121+
{
122+
"if": "matrix.host.cross_compile || matrix.host.platform_name == 'windows_amd64'",
123+
"name": "windows_amd64: build${{ matrix.host.platform_name == 'windows_amd64' && ' and test' || '' }}",
124+
"run": "bazel ${{ matrix.host.platform_name == 'windows_amd64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:windows_amd64 //..."
125+
},
126+
{
127+
"if": "matrix.host.lint",
67128
"name": "bazel mod integrity",
68129
"run": "bazel mod graph || true"
69130
},
70131
{
71-
"name": "linux_amd64: build and test",
72-
"run": "bazel build --platforms=@rules_go//go/toolchain:linux_amd64 //..."
132+
"if": "matrix.host.lint",
133+
"name": "Check the diff between docker-compose and Kubernetes configs",
134+
"run": "tools/diff-docker-and-k8s-configs.sh > tools/expected-docker-and-k8s-configs.diff"
73135
},
74136
{
75-
"name": "linux_386: build and test",
76-
"run": "bazel build --platforms=@rules_go//go/toolchain:linux_386 //..."
137+
"if": "matrix.host.lint",
138+
"name": "Update versions of the container images",
139+
"run": "tools/update-container-image-versions.sh"
77140
},
78141
{
79-
"name": "linux_arm: build and test",
80-
"run": "bazel build --platforms=@rules_go//go/toolchain:linux_arm //..."
142+
"if": "matrix.host.lint",
143+
"name": "Test bb-deployments style conformance",
144+
"run": "git diff --exit-code HEAD --"
81145
},
82146
{
83-
"name": "linux_arm64: build and test",
84-
"run": "bazel build --platforms=@rules_go//go/toolchain:linux_arm64 //..."
147+
"if": "matrix.host.platform_name != 'windows_amd64'",
148+
"name": "Test bare deployment (Unix)",
149+
"run": "tools/test-deployment-bare.sh",
150+
"shell": "bash"
85151
},
86152
{
87-
"name": "darwin_amd64: build and test",
88-
"run": "bazel build --platforms=@rules_go//go/toolchain:darwin_amd64 //..."
153+
"if": "matrix.host.platform_name == 'windows_amd64'",
154+
"name": "Test bare deployment (Windows)",
155+
"run": "tools/run-with-console.ps1 -Command 'bash.exe -c ./tools/test-deployment-bare.sh'"
89156
},
90157
{
91-
"name": "darwin_arm64: build and test",
92-
"run": "bazel build --platforms=@rules_go//go/toolchain:darwin_arm64 //..."
158+
"if": "matrix.host.platform_name == 'linux_amd64'",
159+
"name": "Test docker-compose deployment",
160+
"run": "tools/test-deployment-docker-compose.sh"
93161
},
94162
{
95-
"name": "freebsd_amd64: build and test",
96-
"run": "bazel build --platforms=@rules_go//go/toolchain:freebsd_amd64 //..."
163+
"if": "matrix.host.platform_name == 'linux_amd64'",
164+
"name": "Test Kubernetes deployment",
165+
"run": "tools/test-deployment-kubernetes"
97166
},
98167
{
99-
"name": "windows_amd64: build and test",
100-
"run": "bazel build --platforms=@rules_go//go/toolchain:windows_amd64 //..."
168+
"env": {
169+
"GITHUB_TOKEN": "${{ secrets.GITHUB_TOKEN }}"
170+
},
171+
"if": "matrix.host.upload",
172+
"name": "Install Docker credentials",
173+
"run": "echo \"${GITHUB_TOKEN}\" | docker login ghcr.io -u $ --password-stdin"
101174
}
102-
]
175+
],
176+
"strategy": {
177+
"matrix": {
178+
"host": [
179+
{
180+
"bazel_os": "linux",
181+
"cross_compile": true,
182+
"lint": true,
183+
"os": "ubuntu-latest",
184+
"platform_name": "linux_amd64",
185+
"upload": true
186+
},
187+
{
188+
"bazel_os": "windows",
189+
"cross_compile": false,
190+
"lint": false,
191+
"os": "windows-latest",
192+
"platform_name": "windows_amd64",
193+
"upload": false
194+
}
195+
]
196+
}
197+
}
103198
}
104199
},
105200
"name": "master",
106201
"on": {
107202
"push": {
108203
"branches": [
204+
"main",
109205
"master"
110206
]
111207
}

0 commit comments

Comments
 (0)