|
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 | | - }, |
14 | | - { |
15 | | - "name": "Bazel mod tidy", |
16 | | - "run": "bazel mod tidy" |
17 | | - }, |
18 | | - { |
19 | | - "name": "Gazelle", |
20 | | - "run": "rm -f $(find . -name '*.pb.go' | sed -e 's/[^/]*$/BUILD.bazel/') && bazel run //:gazelle" |
21 | | - }, |
22 | | - { |
23 | | - "name": "Buildifier", |
24 | | - "run": "bazel run @com_github_bazelbuild_buildtools//:buildifier" |
25 | | - }, |
26 | | - { |
27 | | - "name": "Gofmt", |
28 | | - "run": "bazel run @cc_mvdan_gofumpt//:gofumpt -- -w -extra $(pwd)" |
29 | | - }, |
30 | | - { |
31 | | - "name": "Clang format", |
32 | | - "run": "find . -name '*.proto' -exec bazel run @llvm_toolchain_llvm//:bin/clang-format -- -i {} +" |
33 | | - }, |
34 | | - { |
35 | | - "name": "GitHub workflows", |
36 | | - "run": "bazel build //tools/github_workflows && cp bazel-bin/tools/github_workflows/*.yaml .github/workflows" |
| 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" |
37 | 15 | }, |
38 | 16 | { |
39 | | - "name": "Protobuf generation", |
40 | | - "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" |
| 17 | + "if": "matrix.host.platform_name == 'windows_amd64'", |
| 18 | + "name": "Override .bazelrc", |
| 19 | + "run": "echo \"startup --output_base=D:/bazel_output\" >> .bazelrc" |
41 | 20 | }, |
42 | 21 | { |
43 | | - "name": "Embedded asset generation", |
44 | | - "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 | | - }, |
46 | | - { |
47 | | - "name": "Test style conformance", |
48 | | - "run": "git add . && git diff --exit-code HEAD --" |
49 | | - }, |
50 | | - { |
51 | | - "name": "Golint", |
52 | | - "run": "bazel run @org_golang_x_lint//golint -- -set_exit_status $(pwd)/..." |
53 | | - }, |
54 | | - { |
55 | | - "name": "linux_amd64: build and test", |
56 | | - "run": "bazel test --test_output=errors --platforms=@rules_go//go/toolchain:linux_amd64 //..." |
| 22 | + "if": "matrix.host.cross_compile || matrix.host.platform_name == 'linux_amd64'", |
| 23 | + "name": "linux_amd64: build${{ matrix.host.platform_name == 'linux_amd64' && ' and test' || '' }}", |
| 24 | + "run": "bazel ${{ matrix.host.platform_name == 'linux_amd64' && 'test --test_output=errors' || 'build --platforms=@rules_go//go/toolchain:linux_amd64 --@bazel_tools//tools/test:incompatible_use_default_test_toolchain=False' }} //..." |
57 | 25 | }, |
58 | 26 | { |
| 27 | + "if": "matrix.host.upload", |
59 | 28 | "name": "linux_amd64: copy bb_remote_asset", |
60 | 29 | "run": "rm -f bb_remote_asset && bazel run --run_under cp --platforms=@rules_go//go/toolchain:linux_amd64 //cmd/bb_remote_asset $(pwd)/bb_remote_asset" |
61 | 30 | }, |
62 | 31 | { |
| 32 | + "if": "matrix.host.upload", |
63 | 33 | "name": "linux_amd64: upload bb_remote_asset", |
64 | 34 | "uses": "actions/upload-artifact@v4", |
65 | 35 | "with": { |
|
68 | 38 | } |
69 | 39 | }, |
70 | 40 | { |
71 | | - "name": "linux_386: build and test", |
72 | | - "run": "bazel test --test_output=errors --platforms=@rules_go//go/toolchain:linux_386 //..." |
| 41 | + "if": "matrix.host.cross_compile || matrix.host.platform_name == 'linux_386'", |
| 42 | + "name": "linux_386: build${{ matrix.host.platform_name == 'linux_amd64' && ' and test' || '' }}", |
| 43 | + "run": "bazel ${{ matrix.host.platform_name == 'linux_amd64' && 'test --test_output=errors' || 'build --platforms=@rules_go//go/toolchain:linux_386 --@bazel_tools//tools/test:incompatible_use_default_test_toolchain=False' }} //..." |
73 | 44 | }, |
74 | 45 | { |
| 46 | + "if": "matrix.host.upload", |
75 | 47 | "name": "linux_386: copy bb_remote_asset", |
76 | 48 | "run": "rm -f bb_remote_asset && bazel run --run_under cp --platforms=@rules_go//go/toolchain:linux_386 //cmd/bb_remote_asset $(pwd)/bb_remote_asset" |
77 | 49 | }, |
78 | 50 | { |
| 51 | + "if": "matrix.host.upload", |
79 | 52 | "name": "linux_386: upload bb_remote_asset", |
80 | 53 | "uses": "actions/upload-artifact@v4", |
81 | 54 | "with": { |
|
84 | 57 | } |
85 | 58 | }, |
86 | 59 | { |
87 | | - "name": "linux_arm: build and test", |
88 | | - "run": "bazel build --platforms=@rules_go//go/toolchain:linux_arm //..." |
| 60 | + "if": "matrix.host.cross_compile || matrix.host.platform_name == 'linux_arm'", |
| 61 | + "name": "linux_arm: build${{ matrix.host.platform_name == 'linux_arm' && ' and test' || '' }}", |
| 62 | + "run": "bazel ${{ matrix.host.platform_name == 'linux_arm' && 'test --test_output=errors' || 'build --platforms=@rules_go//go/toolchain:linux_arm --@bazel_tools//tools/test:incompatible_use_default_test_toolchain=False' }} //..." |
89 | 63 | }, |
90 | 64 | { |
| 65 | + "if": "matrix.host.upload", |
91 | 66 | "name": "linux_arm: copy bb_remote_asset", |
92 | 67 | "run": "rm -f bb_remote_asset && bazel run --run_under cp --platforms=@rules_go//go/toolchain:linux_arm //cmd/bb_remote_asset $(pwd)/bb_remote_asset" |
93 | 68 | }, |
94 | 69 | { |
| 70 | + "if": "matrix.host.upload", |
95 | 71 | "name": "linux_arm: upload bb_remote_asset", |
96 | 72 | "uses": "actions/upload-artifact@v4", |
97 | 73 | "with": { |
|
100 | 76 | } |
101 | 77 | }, |
102 | 78 | { |
103 | | - "name": "linux_arm64: build and test", |
104 | | - "run": "bazel build --platforms=@rules_go//go/toolchain:linux_arm64 //..." |
| 79 | + "if": "matrix.host.cross_compile || matrix.host.platform_name == 'linux_arm64'", |
| 80 | + "name": "linux_arm64: build${{ matrix.host.platform_name == 'linux_arm64' && ' and test' || '' }}", |
| 81 | + "run": "bazel ${{ matrix.host.platform_name == 'linux_arm64' && 'test --test_output=errors' || 'build --platforms=@rules_go//go/toolchain:linux_arm64 --@bazel_tools//tools/test:incompatible_use_default_test_toolchain=False' }} //..." |
105 | 82 | }, |
106 | 83 | { |
| 84 | + "if": "matrix.host.upload", |
107 | 85 | "name": "linux_arm64: copy bb_remote_asset", |
108 | 86 | "run": "rm -f bb_remote_asset && bazel run --run_under cp --platforms=@rules_go//go/toolchain:linux_arm64 //cmd/bb_remote_asset $(pwd)/bb_remote_asset" |
109 | 87 | }, |
110 | 88 | { |
| 89 | + "if": "matrix.host.upload", |
111 | 90 | "name": "linux_arm64: upload bb_remote_asset", |
112 | 91 | "uses": "actions/upload-artifact@v4", |
113 | 92 | "with": { |
|
116 | 95 | } |
117 | 96 | }, |
118 | 97 | { |
119 | | - "name": "darwin_amd64: build and test", |
120 | | - "run": "bazel build --platforms=@rules_go//go/toolchain:darwin_amd64 //..." |
| 98 | + "if": "matrix.host.cross_compile || matrix.host.platform_name == 'darwin_amd64'", |
| 99 | + "name": "darwin_amd64: build${{ matrix.host.platform_name == 'darwin_amd64' && ' and test' || '' }}", |
| 100 | + "run": "bazel ${{ matrix.host.platform_name == 'darwin_amd64' && 'test --test_output=errors' || 'build --platforms=@rules_go//go/toolchain:darwin_amd64 --@bazel_tools//tools/test:incompatible_use_default_test_toolchain=False' }} //..." |
121 | 101 | }, |
122 | 102 | { |
| 103 | + "if": "matrix.host.upload", |
123 | 104 | "name": "darwin_amd64: copy bb_remote_asset", |
124 | 105 | "run": "rm -f bb_remote_asset && bazel run --run_under cp --platforms=@rules_go//go/toolchain:darwin_amd64 //cmd/bb_remote_asset $(pwd)/bb_remote_asset" |
125 | 106 | }, |
126 | 107 | { |
| 108 | + "if": "matrix.host.upload", |
127 | 109 | "name": "darwin_amd64: upload bb_remote_asset", |
128 | 110 | "uses": "actions/upload-artifact@v4", |
129 | 111 | "with": { |
|
132 | 114 | } |
133 | 115 | }, |
134 | 116 | { |
135 | | - "name": "darwin_arm64: build and test", |
136 | | - "run": "bazel build --platforms=@rules_go//go/toolchain:darwin_arm64 //..." |
| 117 | + "if": "matrix.host.cross_compile || matrix.host.platform_name == 'darwin_arm64'", |
| 118 | + "name": "darwin_arm64: build${{ matrix.host.platform_name == 'darwin_arm64' && ' and test' || '' }}", |
| 119 | + "run": "bazel ${{ matrix.host.platform_name == 'darwin_arm64' && 'test --test_output=errors' || 'build --platforms=@rules_go//go/toolchain:darwin_arm64 --@bazel_tools//tools/test:incompatible_use_default_test_toolchain=False' }} //..." |
137 | 120 | }, |
138 | 121 | { |
| 122 | + "if": "matrix.host.upload", |
139 | 123 | "name": "darwin_arm64: copy bb_remote_asset", |
140 | 124 | "run": "rm -f bb_remote_asset && bazel run --run_under cp --platforms=@rules_go//go/toolchain:darwin_arm64 //cmd/bb_remote_asset $(pwd)/bb_remote_asset" |
141 | 125 | }, |
142 | 126 | { |
| 127 | + "if": "matrix.host.upload", |
143 | 128 | "name": "darwin_arm64: upload bb_remote_asset", |
144 | 129 | "uses": "actions/upload-artifact@v4", |
145 | 130 | "with": { |
|
148 | 133 | } |
149 | 134 | }, |
150 | 135 | { |
151 | | - "name": "freebsd_amd64: build and test", |
152 | | - "run": "bazel build --platforms=@rules_go//go/toolchain:freebsd_amd64 //cmd/bb_remote_asset" |
| 136 | + "if": "matrix.host.cross_compile || matrix.host.platform_name == 'freebsd_amd64'", |
| 137 | + "name": "freebsd_amd64: build${{ matrix.host.platform_name == 'freebsd_amd64' && ' and test' || '' }}", |
| 138 | + "run": "bazel ${{ matrix.host.platform_name == 'freebsd_amd64' && 'test --test_output=errors' || 'build --platforms=@rules_go//go/toolchain:freebsd_amd64 --@bazel_tools//tools/test:incompatible_use_default_test_toolchain=False' }} //..." |
153 | 139 | }, |
154 | 140 | { |
| 141 | + "if": "matrix.host.upload", |
155 | 142 | "name": "freebsd_amd64: copy bb_remote_asset", |
156 | 143 | "run": "rm -f bb_remote_asset && bazel run --run_under cp --platforms=@rules_go//go/toolchain:freebsd_amd64 //cmd/bb_remote_asset $(pwd)/bb_remote_asset" |
157 | 144 | }, |
158 | 145 | { |
| 146 | + "if": "matrix.host.upload", |
159 | 147 | "name": "freebsd_amd64: upload bb_remote_asset", |
160 | 148 | "uses": "actions/upload-artifact@v4", |
161 | 149 | "with": { |
162 | 150 | "name": "bb_remote_asset.freebsd_amd64", |
163 | 151 | "path": "bb_remote_asset" |
164 | 152 | } |
165 | 153 | }, |
166 | | - { |
167 | | - "name": "windows_amd64: build and test", |
168 | | - "run": "bazel build --platforms=@rules_go//go/toolchain:windows_amd64 //cmd/bb_remote_asset" |
169 | | - }, |
170 | | - { |
171 | | - "name": "windows_amd64: copy bb_remote_asset", |
172 | | - "run": "rm -f bb_remote_asset.exe && bazel run --run_under cp --platforms=@rules_go//go/toolchain:windows_amd64 //cmd/bb_remote_asset $(pwd)/bb_remote_asset.exe" |
173 | | - }, |
174 | | - { |
175 | | - "name": "windows_amd64: upload bb_remote_asset", |
176 | | - "uses": "actions/upload-artifact@v4", |
177 | | - "with": { |
178 | | - "name": "bb_remote_asset.windows_amd64", |
179 | | - "path": "bb_remote_asset.exe" |
180 | | - } |
181 | | - }, |
182 | 154 | { |
183 | 155 | "env": { |
184 | 156 | "GITHUB_TOKEN": "${{ secrets.GITHUB_TOKEN }}" |
185 | 157 | }, |
| 158 | + "if": "matrix.host.upload", |
186 | 159 | "name": "Install Docker credentials", |
187 | 160 | "run": "echo \"${GITHUB_TOKEN}\" | docker login ghcr.io -u $ --password-stdin" |
188 | 161 | }, |
189 | 162 | { |
| 163 | + "if": "matrix.host.upload", |
190 | 164 | "name": "Push container bb_remote_asset:bb_remote_asset", |
191 | 165 | "run": "bazel run --stamp //cmd/bb_remote_asset:bb_remote_asset_container_push" |
192 | 166 | } |
| 167 | + ], |
| 168 | + "strategy": { |
| 169 | + "matrix": { |
| 170 | + "host": [ |
| 171 | + { |
| 172 | + "bazel_os": "linux", |
| 173 | + "cross_compile": true, |
| 174 | + "os": "ubuntu-latest", |
| 175 | + "platform_name": "linux_amd64", |
| 176 | + "upload": true |
| 177 | + } |
| 178 | + ] |
| 179 | + } |
| 180 | + } |
| 181 | + }, |
| 182 | + "lint": { |
| 183 | + "name": "lint", |
| 184 | + "runs-on": "ubuntu-latest", |
| 185 | + "steps": [ |
| 186 | + { |
| 187 | + "name": "Check out source code", |
| 188 | + "uses": "actions/checkout@v1" |
| 189 | + }, |
| 190 | + { |
| 191 | + "name": "Installing Bazel", |
| 192 | + "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}", |
| 193 | + "shell": "bash" |
| 194 | + }, |
| 195 | + { |
| 196 | + "name": "Reformat", |
| 197 | + "run": "bazel run @com_github_buildbarn_bb_storage//tools:reformat" |
| 198 | + }, |
| 199 | + { |
| 200 | + "name": "Test style conformance", |
| 201 | + "run": "git add . && git diff --exit-code HEAD --" |
| 202 | + }, |
| 203 | + { |
| 204 | + "name": "Golint", |
| 205 | + "run": "bazel run @org_golang_x_lint//golint -- -set_exit_status $(pwd)/..." |
| 206 | + } |
193 | 207 | ] |
194 | 208 | } |
195 | 209 | }, |
196 | | - "name": "master", |
| 210 | + "name": "main", |
197 | 211 | "on": { |
198 | 212 | "push": { |
199 | 213 | "branches": [ |
200 | | - "main", |
201 | | - "master" |
| 214 | + "main" |
202 | 215 | ] |
203 | 216 | } |
204 | 217 | } |
|
0 commit comments