Skip to content

Commit b89e1e5

Browse files
Mizuxcopybara-github
authored andcommitted
Deep CI rework with few fix
## CI * Add few more CI workflows * Add CMake and Bazel workflows to get badges * Add MacOS (amd64 and M1) and Windows (amd64) jobs * Add C++ 14, 17 and 20 setup bor bazel jobs ## Code * Fix C++14 build: * using `absl::optional` and `absl::variant` (#184) * use of `absl::string_view` (fix cl/715199813 #185 regression) * Add pybind_abseil deps for tests/ note: Protobuf v29 (as well as abseil-cpp 20240722) still support C++14 and will drop it in v30 * Fix Windows MSVC compilation ## Dependencies * Bump protobuf to v29.2 everywhere * previously: 23.1 (bazel module), 25.3 (bazel workspace), 23.3 (cmake) ## Bazel * bazelrc: Fix windows (MSVC) default build flags * bazelrc: support user configuration override * Fix the workspace mode when using bazel 8 ## CMake * declare `pybind_extension` as `MODULE` to fix macOS XCode build jobs * fix Python3 usage note: on manylinux images, Python Libraries are NOT available, only headers since python native modules are loaded by the python interpreter and must not be linked to python. ref: https://peps.python.org/pep-0513/#libpythonx-y-so-1 PiperOrigin-RevId: 716347968
1 parent 324672e commit b89e1e5

34 files changed

+1085
-323
lines changed

.bazelignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build

.bazelrc

+8-3
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@ common --announce_rc
44
# Enable verbose failures for testing only.
55
build --verbose_failures
66

7-
# Compiler options.
8-
build --cxxopt=-std=c++17
9-
build --host_cxxopt=-std=c++17
7+
# Abseil requires C++14 at minimum.
8+
build --enable_platform_specific_config
9+
build:linux --cxxopt=-std=c++17 --host_cxxopt=-std=c++17
10+
build:macos --cxxopt=-std=c++17 --host_cxxopt=-std=c++17
11+
build:windows --cxxopt=/std:c++17 --host_cxxopt=/std:c++17
1012

1113
# Enable logging error output.
1214
test --test_output=errors
1315
test --test_summary=detailed
16+
17+
# https://bazel.build/configure/best-practices#bazelrc-file
18+
try-import %workspace%/user.bazelrc
+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# ref: https://github.com/actions/runner-images
2+
name: amd64 Linux Bazel
3+
4+
on: [push, pull_request, workflow_dispatch]
5+
6+
# Building using the github runner environement directly.
7+
jobs:
8+
native:
9+
strategy:
10+
matrix:
11+
bazel: [
12+
{compilation_mode: opt},
13+
{compilation_mode: dbg},
14+
]
15+
cpp: [
16+
{version: 14, flags: "-std=c++14"},
17+
{version: 17, flags: "-std=c++17"},
18+
{version: 20, flags: "-std=c++20"},
19+
]
20+
python: [
21+
#{version: '3.11'},
22+
{version: '3.12'},
23+
]
24+
exclude:
25+
# only test `-c dbg` build with C++17
26+
- cpp: {version: 14}
27+
bazel: {compilation_mode: dbg}
28+
- cpp: {version: 20}
29+
bazel: {compilation_mode: dbg}
30+
fail-fast: false
31+
name: Linux•Bazel(${{ matrix.bazel.compilation_mode }})•C++${{ matrix.cpp.version }}•Python${{ matrix.python.version }}
32+
runs-on: ubuntu-latest
33+
steps:
34+
- uses: actions/checkout@v4
35+
- name: Check Java
36+
run: java -version
37+
- name: Setup Python
38+
uses: actions/setup-python@v5
39+
with:
40+
python-version: ${{ matrix.python.version }}
41+
- name: Check Python
42+
run: |
43+
python --version
44+
python -m platform
45+
- uses: bazel-contrib/[email protected]
46+
with:
47+
bazelisk-cache: true
48+
disk-cache: ${{ github.workflow }}
49+
repository-cache: true
50+
- name: Check Bazel
51+
run: bazel version
52+
- name: Build
53+
run: >
54+
bazel build
55+
-c ${{ matrix.bazel.compilation_mode }}
56+
--cxxopt=${{ matrix.cpp.flags }} --host_cxxopt=${{ matrix.cpp.flags }}
57+
--subcommands=pretty_print
58+
--enable_bzlmod
59+
//...
60+
- name: Test
61+
run: >
62+
bazel test
63+
-c ${{ matrix.bazel.compilation_mode }}
64+
--cxxopt=${{ matrix.cpp.flags }} --host_cxxopt=${{ matrix.cpp.flags }}
65+
--subcommands=pretty_print
66+
--enable_bzlmod
67+
//...
68+
69+
amd64_linux_bazel:
70+
runs-on: ubuntu-latest
71+
needs: native
72+
steps:
73+
- uses: actions/checkout@v4
+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# ref: https://github.com/actions/runner-images
2+
name: amd64 Linux CMake
3+
4+
on: [push, pull_request, workflow_dispatch]
5+
6+
# Building using the github runner environement directly.
7+
jobs:
8+
native:
9+
strategy:
10+
matrix:
11+
python: [
12+
{version: '3.9'},
13+
{version: '3.10'},
14+
{version: '3.11'},
15+
{version: '3.12'},
16+
#{version: '3.13'},
17+
]
18+
cmake: [
19+
{generator: "Unix Makefiles", config: "Release"},
20+
{generator: "Ninja", config: "Release"},
21+
#{generator: "Ninja Multi-Config", config: "Release"},
22+
]
23+
fail-fast: false
24+
name: Linux•CMake(${{ matrix.cmake.generator }})•Python${{ matrix.python.version }}
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v4
28+
- name: Setup Python
29+
uses: actions/setup-python@v5
30+
with:
31+
python-version: ${{ matrix.python.version }}
32+
- name: Check Python
33+
run: |
34+
python --version
35+
python -m platform
36+
- name: Install Python requirements
37+
run: python -m pip install --upgrade -r $(python -c 'import sys; print("./pybind11_protobuf/requirements/requirements_lock_%d_%d.txt" % (sys.version_info[:2]))')
38+
- name: Install Ninja
39+
run: |
40+
sudo apt-get update
41+
sudo apt-get install ninja-build
42+
- name: Check CMake
43+
run: cmake --version
44+
- name: Configure
45+
run: >
46+
cmake -S. -Bbuild
47+
-G "${{ matrix.cmake.generator }}"
48+
-DCMAKE_BUILD_TYPE=${{ matrix.cmake.config }}
49+
-DCMAKE_INSTALL_PREFIX=install
50+
- name: Build
51+
run: >
52+
cmake --build build
53+
--config ${{ matrix.cmake.config }}
54+
--target all
55+
-v -j2
56+
- name: Test
57+
run: >
58+
CTEST_OUTPUT_ON_FAILURE=1
59+
cmake --build build
60+
--config ${{ matrix.cmake.config }}
61+
--target test
62+
-v
63+
- name: Install
64+
run: >
65+
cmake --build build
66+
--config ${{ matrix.cmake.config }}
67+
--target install
68+
-v
69+
70+
amd64_linux_cmake:
71+
runs-on: ubuntu-latest
72+
needs: native
73+
steps:
74+
- uses: actions/checkout@v4
+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# ref: https://github.com/actions/runner-images
2+
name: amd64 MacOS Bazel
3+
4+
on: [push, pull_request, workflow_dispatch]
5+
6+
# Building using the github runner environement directly.
7+
jobs:
8+
native:
9+
strategy:
10+
matrix:
11+
bazel: [
12+
{compilation_mode: opt},
13+
{compilation_mode: dbg},
14+
]
15+
cpp: [
16+
#{version: 14, flags: "-std=c++14"},
17+
{version: 17, flags: "-std=c++17"},
18+
#{version: 20, flags: "-std=c++20"},
19+
]
20+
python: [
21+
#{version: '3.11'},
22+
{version: '3.12'},
23+
]
24+
exclude:
25+
# only test `-c dbg` build with C++17
26+
- cpp: {version: 14}
27+
bazel: {compilation_mode: dbg}
28+
- cpp: {version: 20}
29+
bazel: {compilation_mode: dbg}
30+
fail-fast: false
31+
name: MacOS•Bazel(${{ matrix.bazel.compilation_mode }})•C++${{ matrix.cpp.version }}•Python${{ matrix.python.version }}
32+
runs-on: macos-13 # last macos intel based runner
33+
steps:
34+
- uses: actions/checkout@v4
35+
- name: Set Java to OpenJDK 17 (Temurin)
36+
uses: actions/setup-java@v3
37+
with:
38+
distribution: 'temurin'
39+
java-version: '17'
40+
- name: Setup Python
41+
uses: actions/setup-python@v5
42+
with:
43+
python-version: ${{ matrix.python.version }}
44+
- name: Check Python
45+
run: |
46+
python --version
47+
python -m platform
48+
- name: Check Bazel
49+
run: bazel version
50+
- name: Change Python in MODULE.bazel
51+
run: |
52+
sed -i '' -e 's/\(DEFAULT_PYTHON =\) "3.[0-9]*"/\1 "${{ matrix.python.version }}"/g' MODULE.bazel
53+
cat MODULE.bazel
54+
- name: Build
55+
run: >
56+
bazel build
57+
-c ${{ matrix.bazel.compilation_mode }}
58+
--cxxopt=${{ matrix.cpp.flags }} --host_cxxopt=${{ matrix.cpp.flags }}
59+
--subcommands=pretty_print
60+
--enable_bzlmod
61+
//...
62+
- name: Test
63+
run: >
64+
bazel test
65+
-c ${{ matrix.bazel.compilation_mode }}
66+
--cxxopt=${{ matrix.cpp.flags }} --host_cxxopt=${{ matrix.cpp.flags }}
67+
--subcommands=pretty_print
68+
--enable_bzlmod
69+
//...
70+
71+
amd64_macos_bazel:
72+
runs-on: ubuntu-latest
73+
needs: native
74+
steps:
75+
- uses: actions/checkout@v4
+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# ref: https://github.com/actions/runner-images
2+
name: amd64 MacOS CMake
3+
4+
on: [push, pull_request, workflow_dispatch]
5+
6+
# Building using the github runner environement directly.
7+
jobs:
8+
native:
9+
strategy:
10+
matrix:
11+
python: [
12+
{version: '3.9'},
13+
{version: '3.10'},
14+
{version: '3.11'},
15+
{version: '3.12'},
16+
#{version: '3.13'},
17+
]
18+
cmake: [
19+
#{generator: "Xcode", config: Release, build_target: ALL_BUILD, test_target: RUN_TESTS, install_target: install},
20+
{generator: "Unix Makefiles", config: Release, build_target: all, test_target: test, install_target: install},
21+
]
22+
fail-fast: false
23+
name: MacOS•CMake(${{ matrix.cmake.generator }})•Python${{ matrix.python.version }}
24+
runs-on: macos-13 # last macos intel based runner
25+
steps:
26+
- uses: actions/checkout@v4
27+
- name: Setup Python
28+
uses: actions/setup-python@v5
29+
with:
30+
python-version: ${{ matrix.python.version }}
31+
- name: Update Path
32+
run: |
33+
echo "$HOME/Library/Python/${{ matrix.python.version }}/bin" >> $GITHUB_PATH
34+
echo "$HOME/.local/bin" >> $GITHUB_PATH
35+
- name: Check Python
36+
run: python --version
37+
- name: Install Python requirements
38+
run: python -m pip install --upgrade -r $(python -c 'import sys; print("./pybind11_protobuf/requirements/requirements_lock_%d_%d.txt" % (sys.version_info[:2]))')
39+
- name: Check CMake
40+
run: cmake --version
41+
- name: Configure
42+
run: >
43+
cmake -S. -Bbuild
44+
-G "${{ matrix.cmake.generator }}"
45+
-DCMAKE_BUILD_TYPE=${{ matrix.cmake.config }}
46+
-DCMAKE_INSTALL_PREFIX=install
47+
- name: Build
48+
run: >
49+
cmake --build build
50+
--config ${{ matrix.cmake.config }}
51+
--target ${{ matrix.cmake.build_target }}
52+
-v -j2
53+
- name: Test
54+
run: >
55+
CTEST_OUTPUT_ON_FAILURE=1
56+
cmake --build build
57+
--config ${{ matrix.cmake.config }}
58+
--target ${{ matrix.cmake.test_target }}
59+
-v
60+
- name: Install
61+
run: >
62+
cmake --build build
63+
--config ${{ matrix.cmake.config }}
64+
--target ${{ matrix.cmake.install_target }}
65+
-v
66+
67+
amd64_macos_cmake:
68+
runs-on: ubuntu-latest
69+
needs: native
70+
steps:
71+
- uses: actions/checkout@v4
+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# ref: https://github.com/actions/runner-images
2+
name: amd64 Windows Bazel
3+
4+
on: [push, pull_request, workflow_dispatch]
5+
6+
# Building using the github runner environement directly.
7+
jobs:
8+
native:
9+
strategy:
10+
matrix:
11+
runner: [
12+
windows-2022,
13+
#windows-2019,
14+
]
15+
bazel: [
16+
{compilation_mode: opt},
17+
{compilation_mode: dbg},
18+
]
19+
cpp: [
20+
#{version: 14, flags: "/std:c++14"},
21+
{version: 17, flags: "/std:c++17"},
22+
#{version: 20, flags: "/std:c++20"},
23+
]
24+
python: [
25+
#{version: '3.11'},
26+
{version: '3.12'},
27+
]
28+
exclude:
29+
- runner: windows-2019
30+
cpp: {version: 20}
31+
# only test -c dbg with VS 2022 version 17 to save compute time
32+
- runner: windows-2019
33+
bazel: {compilation_mode: dbg}
34+
- cpp: {version: 14}
35+
bazel: {compilation_mode: dbg}
36+
- cpp: {version: 20}
37+
bazel: {compilation_mode: dbg}
38+
fail-fast: false # Don't cancel all jobs if one fails.
39+
name: ${{ matrix.runner }}•Bazel(${{ matrix.bazel.compilation_mode }})•C++${{ matrix.cpp.version }}•Python${{ matrix.python.version }}
40+
runs-on: ${{ matrix.runner }}
41+
steps:
42+
- uses: actions/checkout@v4
43+
- name: Setup Python
44+
uses: actions/setup-python@v5
45+
with:
46+
python-version: ${{ matrix.python.version }}
47+
- name: Check Python
48+
run: |
49+
python --version
50+
python -m platform
51+
- name: Install Bazel
52+
run: choco install bazel
53+
- name: Check Bazel
54+
run: bazel version
55+
- name: Build
56+
run: >
57+
bazel build
58+
-c ${{ matrix.bazel.compilation_mode }}
59+
--cxxopt=${{ matrix.cpp.flags }} --host_cxxopt=${{ matrix.cpp.flags }}
60+
--subcommands=pretty_print
61+
--enable_bzlmod
62+
//...
63+
- name: Test
64+
run: >
65+
bazel test
66+
-c ${{ matrix.bazel.compilation_mode }}
67+
--cxxopt=${{ matrix.cpp.flags }} --host_cxxopt=${{ matrix.cpp.flags }}
68+
--subcommands=pretty_print
69+
--enable_bzlmod
70+
//...
71+
72+
amd64_windows_bazel:
73+
runs-on: ubuntu-latest
74+
needs: native
75+
steps:
76+
- uses: actions/checkout@v4

0 commit comments

Comments
 (0)