|
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 | { |
| 77 | + "if": "matrix.host.upload", |
59 | 78 | "name": "linux_amd64: copy bb_browser", |
60 | 79 | "run": "rm -f bb_browser && bazel run --run_under cp --platforms=@rules_go//go/toolchain:linux_amd64 //cmd/bb_browser $(pwd)/bb_browser" |
61 | 80 | }, |
62 | 81 | { |
| 82 | + "if": "matrix.host.upload", |
63 | 83 | "name": "linux_amd64: upload bb_browser", |
64 | 84 | "uses": "actions/upload-artifact@v4", |
65 | 85 | "with": { |
|
68 | 88 | } |
69 | 89 | }, |
70 | 90 | { |
71 | | - "name": "linux_386: build and test", |
72 | | - "run": "bazel test --test_output=errors --platforms=@rules_go//go/toolchain:linux_386 //..." |
| 91 | + "if": "matrix.host.cross_compile || matrix.host.platform_name == 'linux_386'", |
| 92 | + "name": "linux_386: build${{ matrix.host.platform_name == 'linux_amd64' && ' and test' || '' }}", |
| 93 | + "run": "bazel ${{ matrix.host.platform_name == 'linux_amd64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:linux_386 //..." |
73 | 94 | }, |
74 | 95 | { |
| 96 | + "if": "matrix.host.upload", |
75 | 97 | "name": "linux_386: copy bb_browser", |
76 | 98 | "run": "rm -f bb_browser && bazel run --run_under cp --platforms=@rules_go//go/toolchain:linux_386 //cmd/bb_browser $(pwd)/bb_browser" |
77 | 99 | }, |
78 | 100 | { |
| 101 | + "if": "matrix.host.upload", |
79 | 102 | "name": "linux_386: upload bb_browser", |
80 | 103 | "uses": "actions/upload-artifact@v4", |
81 | 104 | "with": { |
|
84 | 107 | } |
85 | 108 | }, |
86 | 109 | { |
87 | | - "name": "linux_arm: build and test", |
88 | | - "run": "bazel build --platforms=@rules_go//go/toolchain:linux_arm //..." |
| 110 | + "if": "matrix.host.cross_compile || matrix.host.platform_name == 'linux_arm'", |
| 111 | + "name": "linux_arm: build${{ matrix.host.platform_name == 'linux_arm' && ' and test' || '' }}", |
| 112 | + "run": "bazel ${{ matrix.host.platform_name == 'linux_arm' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:linux_arm //..." |
89 | 113 | }, |
90 | 114 | { |
| 115 | + "if": "matrix.host.upload", |
91 | 116 | "name": "linux_arm: copy bb_browser", |
92 | 117 | "run": "rm -f bb_browser && bazel run --run_under cp --platforms=@rules_go//go/toolchain:linux_arm //cmd/bb_browser $(pwd)/bb_browser" |
93 | 118 | }, |
94 | 119 | { |
| 120 | + "if": "matrix.host.upload", |
95 | 121 | "name": "linux_arm: upload bb_browser", |
96 | 122 | "uses": "actions/upload-artifact@v4", |
97 | 123 | "with": { |
|
100 | 126 | } |
101 | 127 | }, |
102 | 128 | { |
103 | | - "name": "linux_arm64: build and test", |
104 | | - "run": "bazel build --platforms=@rules_go//go/toolchain:linux_arm64 //..." |
| 129 | + "if": "matrix.host.cross_compile || matrix.host.platform_name == 'linux_arm64'", |
| 130 | + "name": "linux_arm64: build${{ matrix.host.platform_name == 'linux_arm64' && ' and test' || '' }}", |
| 131 | + "run": "bazel ${{ matrix.host.platform_name == 'linux_arm64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:linux_arm64 //..." |
105 | 132 | }, |
106 | 133 | { |
| 134 | + "if": "matrix.host.upload", |
107 | 135 | "name": "linux_arm64: copy bb_browser", |
108 | 136 | "run": "rm -f bb_browser && bazel run --run_under cp --platforms=@rules_go//go/toolchain:linux_arm64 //cmd/bb_browser $(pwd)/bb_browser" |
109 | 137 | }, |
110 | 138 | { |
| 139 | + "if": "matrix.host.upload", |
111 | 140 | "name": "linux_arm64: upload bb_browser", |
112 | 141 | "uses": "actions/upload-artifact@v4", |
113 | 142 | "with": { |
|
116 | 145 | } |
117 | 146 | }, |
118 | 147 | { |
119 | | - "name": "darwin_amd64: build and test", |
120 | | - "run": "bazel build --platforms=@rules_go//go/toolchain:darwin_amd64 //..." |
| 148 | + "if": "matrix.host.cross_compile || matrix.host.platform_name == 'darwin_amd64'", |
| 149 | + "name": "darwin_amd64: build${{ matrix.host.platform_name == 'darwin_amd64' && ' and test' || '' }}", |
| 150 | + "run": "bazel ${{ matrix.host.platform_name == 'darwin_amd64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:darwin_amd64 //..." |
121 | 151 | }, |
122 | 152 | { |
| 153 | + "if": "matrix.host.upload", |
123 | 154 | "name": "darwin_amd64: copy bb_browser", |
124 | 155 | "run": "rm -f bb_browser && bazel run --run_under cp --platforms=@rules_go//go/toolchain:darwin_amd64 //cmd/bb_browser $(pwd)/bb_browser" |
125 | 156 | }, |
126 | 157 | { |
| 158 | + "if": "matrix.host.upload", |
127 | 159 | "name": "darwin_amd64: upload bb_browser", |
128 | 160 | "uses": "actions/upload-artifact@v4", |
129 | 161 | "with": { |
|
132 | 164 | } |
133 | 165 | }, |
134 | 166 | { |
135 | | - "name": "darwin_arm64: build and test", |
136 | | - "run": "bazel build --platforms=@rules_go//go/toolchain:darwin_arm64 //..." |
| 167 | + "if": "matrix.host.cross_compile || matrix.host.platform_name == 'darwin_arm64'", |
| 168 | + "name": "darwin_arm64: build${{ matrix.host.platform_name == 'darwin_arm64' && ' and test' || '' }}", |
| 169 | + "run": "bazel ${{ matrix.host.platform_name == 'darwin_arm64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:darwin_arm64 //..." |
137 | 170 | }, |
138 | 171 | { |
| 172 | + "if": "matrix.host.upload", |
139 | 173 | "name": "darwin_arm64: copy bb_browser", |
140 | 174 | "run": "rm -f bb_browser && bazel run --run_under cp --platforms=@rules_go//go/toolchain:darwin_arm64 //cmd/bb_browser $(pwd)/bb_browser" |
141 | 175 | }, |
142 | 176 | { |
| 177 | + "if": "matrix.host.upload", |
143 | 178 | "name": "darwin_arm64: upload bb_browser", |
144 | 179 | "uses": "actions/upload-artifact@v4", |
145 | 180 | "with": { |
|
148 | 183 | } |
149 | 184 | }, |
150 | 185 | { |
151 | | - "name": "freebsd_amd64: build and test", |
152 | | - "run": "bazel build --platforms=@rules_go//go/toolchain:freebsd_amd64 //cmd/bb_browser" |
| 186 | + "if": "matrix.host.cross_compile || matrix.host.platform_name == 'freebsd_amd64'", |
| 187 | + "name": "freebsd_amd64: build${{ matrix.host.platform_name == 'freebsd_amd64' && ' and test' || '' }}", |
| 188 | + "run": "bazel ${{ matrix.host.platform_name == 'freebsd_amd64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:freebsd_amd64 //..." |
153 | 189 | }, |
154 | 190 | { |
| 191 | + "if": "matrix.host.upload", |
155 | 192 | "name": "freebsd_amd64: copy bb_browser", |
156 | 193 | "run": "rm -f bb_browser && bazel run --run_under cp --platforms=@rules_go//go/toolchain:freebsd_amd64 //cmd/bb_browser $(pwd)/bb_browser" |
157 | 194 | }, |
158 | 195 | { |
| 196 | + "if": "matrix.host.upload", |
159 | 197 | "name": "freebsd_amd64: upload bb_browser", |
160 | 198 | "uses": "actions/upload-artifact@v4", |
161 | 199 | "with": { |
|
164 | 202 | } |
165 | 203 | }, |
166 | 204 | { |
167 | | - "name": "windows_amd64: build and test", |
168 | | - "run": "bazel build --platforms=@rules_go//go/toolchain:windows_amd64 //cmd/bb_browser" |
| 205 | + "if": "matrix.host.cross_compile || matrix.host.platform_name == 'windows_amd64'", |
| 206 | + "name": "windows_amd64: build${{ matrix.host.platform_name == 'windows_amd64' && ' and test' || '' }}", |
| 207 | + "run": "bazel ${{ matrix.host.platform_name == 'windows_amd64' && 'test --test_output=errors' || 'build' }} --platforms=@rules_go//go/toolchain:windows_amd64 //..." |
169 | 208 | }, |
170 | 209 | { |
| 210 | + "if": "matrix.host.upload", |
171 | 211 | "name": "windows_amd64: copy bb_browser", |
172 | 212 | "run": "rm -f bb_browser.exe && bazel run --run_under cp --platforms=@rules_go//go/toolchain:windows_amd64 //cmd/bb_browser $(pwd)/bb_browser.exe" |
173 | 213 | }, |
174 | 214 | { |
| 215 | + "if": "matrix.host.upload", |
175 | 216 | "name": "windows_amd64: upload bb_browser", |
176 | 217 | "uses": "actions/upload-artifact@v4", |
177 | 218 | "with": { |
|
183 | 224 | "env": { |
184 | 225 | "GITHUB_TOKEN": "${{ secrets.GITHUB_TOKEN }}" |
185 | 226 | }, |
| 227 | + "if": "matrix.host.upload", |
186 | 228 | "name": "Install Docker credentials", |
187 | 229 | "run": "echo \"${GITHUB_TOKEN}\" | docker login ghcr.io -u $ --password-stdin" |
188 | 230 | }, |
189 | 231 | { |
| 232 | + "if": "matrix.host.upload", |
190 | 233 | "name": "Push container bb_browser:bb_browser", |
191 | 234 | "run": "bazel run --stamp //cmd/bb_browser:bb_browser_container_push" |
192 | 235 | } |
193 | | - ] |
| 236 | + ], |
| 237 | + "strategy": { |
| 238 | + "matrix": { |
| 239 | + "host": [ |
| 240 | + { |
| 241 | + "bazel_os": "linux", |
| 242 | + "cross_compile": true, |
| 243 | + "lint": true, |
| 244 | + "os": "ubuntu-latest", |
| 245 | + "platform_name": "linux_amd64", |
| 246 | + "upload": true |
| 247 | + }, |
| 248 | + { |
| 249 | + "bazel_os": "windows", |
| 250 | + "cross_compile": false, |
| 251 | + "lint": false, |
| 252 | + "os": "windows-latest", |
| 253 | + "platform_name": "windows_amd64", |
| 254 | + "upload": false |
| 255 | + } |
| 256 | + ] |
| 257 | + } |
| 258 | + } |
194 | 259 | } |
195 | 260 | }, |
196 | 261 | "name": "master", |
|
0 commit comments