Skip to content

Commit 8d1c9eb

Browse files
committed
build: update bazel build. This commit has follow changes:
- support bazel module (WORKSPACE has bee deprecated sinc v8.0.1) - converage check action update to v4 - llvm install action update to v2 - llvm version select 11, 16, 17
1 parent 033a654 commit 8d1c9eb

File tree

7 files changed

+65
-24
lines changed

7 files changed

+65
-24
lines changed

.github/workflows/clang-format-check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- 'example'
1414
- 'fuzz'
1515
steps:
16-
- uses: actions/checkout@v3
16+
- uses: actions/checkout@v4
1717
- name: Run clang-format style check.
1818
uses: jidicula/[email protected]
1919
with:

.github/workflows/test_coverage.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,16 @@ jobs:
1313

1414
steps:
1515
- name: Checkout codebase
16-
uses: actions/checkout@v3
16+
uses: actions/checkout@v4
1717

1818
- name: Setup bazel
19-
uses: jwlawson/actions-setup-bazel@v1
19+
uses: jwlawson/actions-setup-bazel@v2
2020
with:
2121
bazel-version: "latest"
2222

2323
- name: Setup GCC
24-
uses: Dup4/actions-setup-gcc@v1
25-
with:
26-
version: ${{ env.GCC_VERSION }}
27-
24+
run: |
25+
sudo apt-get install -y gcc-12 g++-12
2826
- name: Install lcov
2927
run: |
3028
sudo apt install lcov
@@ -35,15 +33,15 @@ jobs:
3533
genhtml --output bazel-coverage-html ./coverage.dat
3634
3735
- name: upload coverage artifact
38-
uses: actions/upload-artifact@v3
36+
uses: actions/upload-artifact@v4
3937
with:
4038
name: coverage
4139
path: |
4240
bazel-coverage-html
4341
coverage.dat
4442
4543
- name: Upload coverage to CodeCov
46-
uses: codecov/codecov-action@v3
44+
uses: codecov/codecov-action@v4
4745
with:
4846
files: coverage.dat
4947
verbose: true

.github/workflows/test_x86.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
strategy:
88
fail-fast: false
99
matrix:
10-
llvm_version: ['11', '13.0.0', '15']
10+
llvm_version: ['11', '16.0.4', '17']
1111
tool: ['cmake', 'bazel']
1212
arch: [westmere, haswell]
1313
exclude:
@@ -18,16 +18,16 @@ jobs:
1818
CXX: clang++
1919

2020
steps:
21-
- uses: actions/checkout@v3
21+
- uses: actions/checkout@v4
2222

2323
- name: Install LLVM and Clang
24-
uses: KyleMayes/install-llvm-action@v1
24+
uses: KyleMayes/install-llvm-action@v2
2525
with:
2626
version: ${{ matrix.llvm_version }}
2727

2828
- name: Setup bazel
2929
if: matrix.tool == 'bazel'
30-
uses: jwlawson/actions-setup-bazel@v1
30+
uses: jwlawson/actions-setup-bazel@v2
3131
with:
3232
bazel-version: "latest"
3333

@@ -70,15 +70,15 @@ jobs:
7070
CXX: g++-${{ matrix.gcc_version}}
7171

7272
steps:
73-
- uses: actions/checkout@v3
73+
- uses: actions/checkout@v4
7474

7575
- name: Install GCC
7676
run: |
7777
sudo apt-get install -y gcc-${{ matrix.gcc_version }} g++-${{ matrix.gcc_version }}
7878
7979
- name: Setup bazel
8080
if: matrix.tool == 'bazel'
81-
uses: jwlawson/actions-setup-bazel@v1
81+
uses: jwlawson/actions-setup-bazel@v2
8282
with:
8383
bazel-version: "latest"
8484

BUILD.bazel

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ cc_test(
122122
]),
123123
deps = [
124124
":string_view",
125-
"@gtest//:gtest_main",
125+
"@googletest//:gtest_main",
126126
],
127127
data = glob([ "testdata/*.json"]),
128128
linkopts = [ '-lstdc++fs', '-fstack-protector-all',] +\
@@ -155,14 +155,13 @@ cc_test(
155155
cc_test(
156156
name = "unittest-clang",
157157
srcs = glob([
158-
"tests/*.h",
159158
"tests/*.cpp",
160159
"include/sonic/*",
161160
"include/sonic/**/*",
162161
]),
163162
deps = [
164163
":string_view",
165-
"@gtest//:gtest_main",
164+
"@googletest//:gtest_main",
166165
],
167166
data = glob([ "testdata/*.json"]),
168167
linkopts = sanitize_copts + [
@@ -179,14 +178,13 @@ cc_test(
179178
cc_test(
180179
name = "unittest-arm",
181180
srcs = glob([
182-
"tests/*.h",
183181
"tests/*.cpp",
184182
"include/sonic/*",
185183
"include/sonic/**/*",
186184
]),
187185
deps = [
188186
":string_view",
189-
"@gtest//:gtest_main",
187+
"@googletest//:gtest_main",
190188
],
191189
data = glob([ "testdata/*.json"]),
192190
linkopts = sanitize_copts + [
@@ -203,14 +201,13 @@ cc_test(
203201
cc_test(
204202
name = "unittest-sse",
205203
srcs = glob([
206-
"tests/*.h",
207204
"tests/*.cpp",
208205
"include/sonic/*",
209206
"include/sonic/**/*",
210207
]),
211208
deps = [
212209
":string_view",
213-
"@gtest//:gtest_main",
210+
"@googletest//:gtest_main",
214211
],
215212
data = glob([ "testdata/*.json"]),
216213
linkopts = sanitize_copts + [
@@ -229,11 +226,10 @@ cc_test(
229226
name = "unittest-gcc-coverage",
230227
srcs = glob([
231228
"tests/*.cpp",
232-
"tests/*.h",
233229
]),
234230
deps = [
235231
":sonic-cpp",
236-
"@gtest//:gtest_main",
232+
"@googletest//:gtest_main",
237233
],
238234
data = glob([
239235
"testdata/*.json",

MODULE.bazel

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
###############################################################################
2+
# Bazel now uses Bzlmod by default to manage external dependencies.
3+
# Please consider migrating your external dependencies from WORKSPACE to MODULE.bazel.
4+
#
5+
# For more details, please check https://github.com/bazelbuild/bazel/issues/18958
6+
###############################################################################
7+
bazel_dep(name = "bazel_skylib", version = "1.7.1")
8+
bazel_dep(name = "google_benchmark", version = "1.9.1")
9+
bazel_dep(name = "googletest", version = "1.16.0")
10+
11+
new_git_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository")
12+
git_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
13+
14+
new_git_repository(
15+
name = "rapidjson",
16+
branch = "master",
17+
build_file = "//:bazel/rapidjson.BUILD",
18+
remote = "https://github.com/Tencent/rapidjson.git",
19+
)
20+
21+
new_git_repository(
22+
name = "cJSON",
23+
branch = "master",
24+
build_file = "//:bazel/cJSON.BUILD",
25+
remote = "https://github.com/DaveGamble/cJSON.git",
26+
)
27+
28+
new_git_repository(
29+
name = "simdjson",
30+
branch = "master",
31+
build_file = "//:bazel/simdjson.BUILD",
32+
remote = "https://github.com/simdjson/simdjson.git",
33+
)
34+
35+
new_git_repository(
36+
name = "yyjson",
37+
branch = "master",
38+
build_file = "//:bazel/yyjson.BUILD",
39+
remote = "https://github.com/ibireme/yyjson.git",
40+
)
41+
42+
git_repository(
43+
name = "jsoncpp",
44+
branch = "master",
45+
remote = "https://github.com/open-source-parsers/jsoncpp",
46+
)
File renamed without changes.

tests/document_test.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include <dirent.h>
1818

19+
#include <algorithm>
1920
#include <fstream>
2021
#include <iostream>
2122
#include <map>

0 commit comments

Comments
 (0)