|
1 | 1 | {
|
2 | 2 | "jobs": {
|
3 | 3 | "build_and_test": {
|
4 |
| - "runs-on": "ubuntu-latest", |
| 4 | + "name": "build_and_test ${{ matrix.host.os }}", |
| 5 | + "runs-on": "${{ matrix.host.os }}", |
5 | 6 | "steps": [
|
6 | 7 | {
|
7 | 8 | "name": "Check out source code",
|
8 | 9 | "uses": "actions/checkout@v1"
|
9 | 10 | },
|
10 | 11 | {
|
11 | 12 | "name": "Installing Bazel",
|
12 |
| - "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}" |
| 13 | + "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}", |
| 14 | + "shell": "bash" |
13 | 15 | },
|
14 | 16 | {
|
| 17 | + "if": "matrix.host.platform_name == 'windows_amd64'", |
| 18 | + "name": "Override .bazelrc", |
| 19 | + "run": "echo \"startup --output_base=D:/bazel_output\" >> .bazelrc" |
| 20 | + }, |
| 21 | + { |
| 22 | + "if": "matrix.host.lint", |
15 | 23 | "name": "Bazel mod tidy",
|
16 | 24 | "run": "bazel mod tidy"
|
17 | 25 | },
|
18 | 26 | {
|
| 27 | + "if": "matrix.host.lint", |
19 | 28 | "name": "Gazelle",
|
20 | 29 | "run": "rm -f $(find . -name '*.pb.go' | sed -e 's/[^/]*$/BUILD.bazel/') && bazel run //:gazelle"
|
21 | 30 | },
|
22 | 31 | {
|
| 32 | + "if": "matrix.host.lint", |
23 | 33 | "name": "Buildifier",
|
24 | 34 | "run": "bazel run @com_github_bazelbuild_buildtools//:buildifier"
|
25 | 35 | },
|
26 | 36 | {
|
| 37 | + "if": "matrix.host.lint", |
27 | 38 | "name": "Gofmt",
|
28 | 39 | "run": "bazel run @cc_mvdan_gofumpt//:gofumpt -- -w -extra $(pwd)"
|
29 | 40 | },
|
30 | 41 | {
|
| 42 | + "if": "matrix.host.lint", |
31 | 43 | "name": "Clang format",
|
32 | 44 | "run": "find . -name '*.proto' -exec bazel run @llvm_toolchain_llvm//:bin/clang-format -- -i {} +"
|
33 | 45 | },
|
34 | 46 | {
|
| 47 | + "if": "matrix.host.lint", |
35 | 48 | "name": "GitHub workflows",
|
36 | 49 | "run": "bazel build //tools/github_workflows && cp bazel-bin/tools/github_workflows/*.yaml .github/workflows"
|
37 | 50 | },
|
38 | 51 | {
|
| 52 | + "if": "matrix.host.lint", |
39 | 53 | "name": "Protobuf generation",
|
40 | 54 | "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"
|
41 | 55 | },
|
42 | 56 | {
|
| 57 | + "if": "matrix.host.lint", |
43 | 58 | "name": "Embedded asset generation",
|
44 | 59 | "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"
|
45 | 60 | },
|
46 | 61 | {
|
| 62 | + "if": "matrix.host.lint", |
47 | 63 | "name": "Test style conformance",
|
48 | 64 | "run": "git add . && git diff --exit-code HEAD --"
|
49 | 65 | },
|
50 | 66 | {
|
| 67 | + "if": "matrix.host.lint", |
51 | 68 | "name": "Golint",
|
52 | 69 | "run": "bazel run @org_golang_x_lint//golint -- -set_exit_status $(pwd)/..."
|
53 | 70 | },
|
54 | 71 | {
|
55 |
| - "name": "linux_amd64: build and test", |
56 |
| - "run": "bazel test --test_output=errors --platforms=@rules_go//go/toolchain:linux_amd64 //..." |
| 72 | + "if": "matrix.host.cross_compile || matrix.host.platform_name == 'linux_amd64'", |
| 73 | + "name": "linux_amd64: build${{ matrix.host.platform_name == 'linux_amd64' && ' and test' || '' }}", |
| 74 | + "run": "bazel ${{ matrix.host.platform_name == 'linux_amd64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:linux_amd64 //..." |
57 | 75 | },
|
58 | 76 | {
|
59 |
| - "name": "linux_386: build and test", |
60 |
| - "run": "bazel test --test_output=errors --platforms=@rules_go//go/toolchain:linux_386 //..." |
| 77 | + "if": "matrix.host.cross_compile || matrix.host.platform_name == 'linux_386'", |
| 78 | + "name": "linux_386: build${{ matrix.host.platform_name == 'linux_amd64' && ' and test' || '' }}", |
| 79 | + "run": "bazel ${{ matrix.host.platform_name == 'linux_amd64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:linux_386 //..." |
61 | 80 | },
|
62 | 81 | {
|
63 |
| - "name": "linux_arm: build and test", |
64 |
| - "run": "bazel build --platforms=@rules_go//go/toolchain:linux_arm //..." |
| 82 | + "if": "matrix.host.cross_compile || matrix.host.platform_name == 'linux_arm'", |
| 83 | + "name": "linux_arm: build${{ matrix.host.platform_name == 'linux_arm' && ' and test' || '' }}", |
| 84 | + "run": "bazel ${{ matrix.host.platform_name == 'linux_arm' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:linux_arm //..." |
65 | 85 | },
|
66 | 86 | {
|
67 |
| - "name": "linux_arm64: build and test", |
68 |
| - "run": "bazel build --platforms=@rules_go//go/toolchain:linux_arm64 //..." |
| 87 | + "if": "matrix.host.cross_compile || matrix.host.platform_name == 'linux_arm64'", |
| 88 | + "name": "linux_arm64: build${{ matrix.host.platform_name == 'linux_arm64' && ' and test' || '' }}", |
| 89 | + "run": "bazel ${{ matrix.host.platform_name == 'linux_arm64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:linux_arm64 //..." |
69 | 90 | },
|
70 | 91 | {
|
71 |
| - "name": "darwin_amd64: build and test", |
72 |
| - "run": "bazel build --platforms=@rules_go//go/toolchain:darwin_amd64 //..." |
| 92 | + "if": "matrix.host.cross_compile || matrix.host.platform_name == 'darwin_amd64'", |
| 93 | + "name": "darwin_amd64: build${{ matrix.host.platform_name == 'darwin_amd64' && ' and test' || '' }}", |
| 94 | + "run": "bazel ${{ matrix.host.platform_name == 'darwin_amd64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:darwin_amd64 //..." |
73 | 95 | },
|
74 | 96 | {
|
75 |
| - "name": "darwin_arm64: build and test", |
76 |
| - "run": "bazel build --platforms=@rules_go//go/toolchain:darwin_arm64 //..." |
| 97 | + "if": "matrix.host.cross_compile || matrix.host.platform_name == 'darwin_arm64'", |
| 98 | + "name": "darwin_arm64: build${{ matrix.host.platform_name == 'darwin_arm64' && ' and test' || '' }}", |
| 99 | + "run": "bazel ${{ matrix.host.platform_name == 'darwin_arm64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:darwin_arm64 //..." |
77 | 100 | },
|
78 | 101 | {
|
79 |
| - "name": "freebsd_amd64: build and test", |
80 |
| - "run": "bazel build --platforms=@rules_go//go/toolchain:freebsd_amd64 //cmd/bb_noop_worker //cmd/bb_runner //cmd/bb_scheduler //cmd/bb_virtual_tmp //cmd/bb_worker //cmd/fake_python //cmd/fake_xcrun" |
| 102 | + "if": "matrix.host.cross_compile || matrix.host.platform_name == 'freebsd_amd64'", |
| 103 | + "name": "freebsd_amd64: build${{ matrix.host.platform_name == 'freebsd_amd64' && ' and test' || '' }}", |
| 104 | + "run": "bazel ${{ matrix.host.platform_name == 'freebsd_amd64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:freebsd_amd64 //..." |
81 | 105 | },
|
82 | 106 | {
|
83 |
| - "name": "windows_amd64: build and test", |
84 |
| - "run": "bazel build --platforms=@rules_go//go/toolchain:windows_amd64 //cmd/bb_noop_worker //cmd/bb_runner //cmd/bb_scheduler //cmd/bb_virtual_tmp //cmd/bb_worker //cmd/fake_python //cmd/fake_xcrun" |
| 107 | + "if": "matrix.host.cross_compile || matrix.host.platform_name == 'windows_amd64'", |
| 108 | + "name": "windows_amd64: build${{ matrix.host.platform_name == 'windows_amd64' && ' and test' || '' }}", |
| 109 | + "run": "bazel ${{ matrix.host.platform_name == 'windows_amd64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:windows_amd64 //..." |
85 | 110 | }
|
86 |
| - ] |
| 111 | + ], |
| 112 | + "strategy": { |
| 113 | + "matrix": { |
| 114 | + "host": [ |
| 115 | + { |
| 116 | + "bazel_os": "linux", |
| 117 | + "cross_compile": true, |
| 118 | + "lint": true, |
| 119 | + "os": "ubuntu-latest", |
| 120 | + "platform_name": "linux_amd64", |
| 121 | + "upload": true |
| 122 | + }, |
| 123 | + { |
| 124 | + "bazel_os": "windows", |
| 125 | + "cross_compile": false, |
| 126 | + "lint": false, |
| 127 | + "os": "windows-latest", |
| 128 | + "platform_name": "windows_amd64", |
| 129 | + "upload": false |
| 130 | + } |
| 131 | + ] |
| 132 | + } |
| 133 | + } |
87 | 134 | }
|
88 | 135 | },
|
89 | 136 | "name": "pull-requests",
|
|
0 commit comments