|
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 | { |
| 8 | + "name": "Check out source code", |
| 9 | + "uses": "actions/checkout@v1" |
| 10 | + }, |
| 11 | + { |
| 12 | + "if": "matrix.host.platform_name == 'linux_amd64'", |
7 | 13 | "name": "Installing grpcurl", |
8 | 14 | "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" |
9 | 15 | }, |
10 | 16 | { |
| 17 | + "if": "matrix.host.platform_name == 'linux_amd64'", |
11 | 18 | "name": "Install k3d", |
12 | 19 | "run": "curl -s https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash" |
13 | 20 | }, |
14 | 21 | { |
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" |
17 | 25 | }, |
18 | 26 | { |
19 | 27 | "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" |
21 | 30 | }, |
22 | 31 | { |
| 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", |
23 | 43 | "name": "Gazelle", |
24 | | - "run": "bazel run //:gazelle" |
| 44 | + "run": "rm -f $(find . -name '*.pb.go' | sed -e 's/[^/]*$/BUILD.bazel/') && bazel run //:gazelle" |
25 | 45 | }, |
26 | 46 | { |
| 47 | + "if": "matrix.host.lint", |
27 | 48 | "name": "Buildifier", |
28 | | - "run": "bazel run //:buildifier.check" |
| 49 | + "run": "bazel run @com_github_bazelbuild_buildtools//:buildifier" |
29 | 50 | }, |
30 | 51 | { |
| 52 | + "if": "matrix.host.lint", |
31 | 53 | "name": "Gofmt", |
32 | 54 | "run": "bazel run @cc_mvdan_gofumpt//:gofumpt -- -w -extra $(pwd)" |
33 | 55 | }, |
34 | 56 | { |
| 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", |
35 | 63 | "name": "GitHub workflows", |
36 | 64 | "run": "bazel build //tools/github_workflows && cp bazel-bin/tools/github_workflows/*.yaml .github/workflows" |
37 | 65 | }, |
38 | 66 | { |
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" |
41 | 70 | }, |
42 | 71 | { |
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" |
45 | 75 | }, |
46 | 76 | { |
| 77 | + "if": "matrix.host.lint", |
47 | 78 | "name": "Test style conformance", |
48 | | - "run": "git diff --exit-code HEAD --" |
| 79 | + "run": "git add . && git diff --exit-code HEAD --" |
49 | 80 | }, |
50 | 81 | { |
| 82 | + "if": "matrix.host.lint", |
51 | 83 | "name": "Golint", |
52 | 84 | "run": "bazel run @org_golang_x_lint//golint -- -set_exit_status $(pwd)/..." |
53 | 85 | }, |
54 | 86 | { |
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 //..." |
57 | 90 | }, |
58 | 91 | { |
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 //..." |
61 | 95 | }, |
62 | 96 | { |
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 //..." |
65 | 100 | }, |
66 | 101 | { |
| 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", |
67 | 128 | "name": "bazel mod integrity", |
68 | 129 | "run": "bazel mod graph || true" |
69 | 130 | }, |
70 | 131 | { |
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" |
73 | 135 | }, |
74 | 136 | { |
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" |
77 | 140 | }, |
78 | 141 | { |
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 --" |
81 | 145 | }, |
82 | 146 | { |
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" |
85 | 151 | }, |
86 | 152 | { |
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'" |
89 | 156 | }, |
90 | 157 | { |
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" |
93 | 161 | }, |
94 | 162 | { |
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" |
97 | 166 | }, |
98 | 167 | { |
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" |
101 | 174 | } |
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 | + } |
103 | 198 | } |
104 | 199 | }, |
105 | 200 | "name": "master", |
106 | 201 | "on": { |
107 | 202 | "push": { |
108 | 203 | "branches": [ |
| 204 | + "main", |
109 | 205 | "master" |
110 | 206 | ] |
111 | 207 | } |
|
0 commit comments