Skip to content

Commit 37e5e09

Browse files
Mizuxcopybara-github
authored andcommitted
Update CI workflows
* Split CMake and Bazel workflows to get independent badges * Split MacOS (amd64 and M1) and Windows (amd64) and Linux (amd64) jobs * import ubuntu-build.yml from pybind11_protobuf ## Bazel * Add C++14, c++17 and c++20 flavours * Add `-c opt` and `-c dbg` variants * only test against the default python3.11 ## CMake * Test Python 3.9, 3.10. 3.11, 3.12 * cmake(linux): Test Unix Makefile and Ninja Build generators * cmake(macOS): Test XCode and Makefile generators * cmake(windows): Test MSVC (VC 2022) generator PiperOrigin-RevId: 715743424
1 parent 2420efd commit 37e5e09

12 files changed

+652
-31
lines changed

.github/workflows/actions.yml

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,14 @@
1+
# ref: https://github.com/actions/runner-images
12
name: build_and_test
23

34
# Controls when the action will run.
4-
on:
5-
# Triggers the workflow on push or pull request events but only for the master branch
6-
push:
7-
branches: [ master ]
8-
pull_request:
9-
branches: [ master ]
10-
# Allows you to run this workflow manually from the Actions tab
11-
workflow_dispatch:
5+
on: [push, pull_request, workflow_dispatch]
126

137
env:
148
PIP_BREAK_SYSTEM_PACKAGES: 1
159

1610
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1711
jobs:
18-
1912
unix:
2013
strategy:
2114
fail-fast: false
@@ -30,28 +23,21 @@ jobs:
3023
steps:
3124
- name: Show env
3225
run: env
33-
3426
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
35-
- uses: actions/checkout@v3
27+
- uses: actions/checkout@v4
3628

37-
- name: Install bazel
29+
- name: Setup bazel
3830
if: matrix.build_tool == 'bazel'
39-
# Install Bazel, see https://docs.bazel.build/versions/master/install-ubuntu.html#step-1-install-required-packages
40-
run: |
41-
sudo apt install curl gnupg
42-
curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor > bazel.gpg
43-
sudo mv bazel.gpg /etc/apt/trusted.gpg.d/
44-
echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
45-
sudo apt update && sudo apt install bazel -y
31+
uses: bazel-contrib/[email protected]
32+
with:
33+
bazelisk-cache: true
34+
disk-cache: ${{ github.workflow }}
35+
repository-cache: true
4636

4737
- name: Show bazel version
4838
if: matrix.build_tool == 'bazel'
4939
run: bazel --version
5040

51-
- name: Update cmake
52-
if: matrix.build_tool == 'cmake'
53-
uses: jwlawson/[email protected]
54-
5541
- name: Show cmake version
5642
if: matrix.build_tool == 'cmake'
5743
run: cmake --version
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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+
]
23+
exclude:
24+
# only test `-c dbg` build with C++17
25+
- cpp: {version: 14}
26+
bazel: {compilation_mode: dbg}
27+
- cpp: {version: 20}
28+
bazel: {compilation_mode: dbg}
29+
fail-fast: false
30+
name: Linux•Bazel(${{ matrix.bazel.compilation_mode }})•C++${{ matrix.cpp.version }}•Python${{ matrix.python.version }}
31+
runs-on: ubuntu-latest
32+
steps:
33+
- uses: actions/checkout@v4
34+
- name: Check Java
35+
run: java -version
36+
- name: Setup Python
37+
uses: actions/setup-python@v5
38+
with:
39+
python-version: ${{ matrix.python.version }}
40+
- name: Check Python
41+
run: |
42+
python --version
43+
python -m platform
44+
- uses: bazel-contrib/[email protected]
45+
with:
46+
bazelisk-cache: true
47+
disk-cache: ${{ github.workflow }}
48+
repository-cache: true
49+
- name: Check Bazel
50+
run: bazel version
51+
- name: Build
52+
run: >
53+
bazel build
54+
-c ${{ matrix.bazel.compilation_mode }}
55+
--cxxopt=${{ matrix.cpp.flags }} --host_cxxopt=${{ matrix.cpp.flags }}
56+
--subcommands=pretty_print
57+
--enable_bzlmod
58+
//...
59+
- name: Test
60+
run: >
61+
bazel test
62+
-c ${{ matrix.bazel.compilation_mode }}
63+
--cxxopt=${{ matrix.cpp.flags }} --host_cxxopt=${{ matrix.cpp.flags }}
64+
--subcommands=pretty_print
65+
--enable_bzlmod
66+
//...
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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_abseil/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
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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+
]
23+
exclude:
24+
# only test `-c dbg` build with C++17
25+
- cpp: {version: 14}
26+
bazel: {compilation_mode: dbg}
27+
- cpp: {version: 20}
28+
bazel: {compilation_mode: dbg}
29+
fail-fast: false
30+
name: MacOS•Bazel(${{ matrix.bazel.compilation_mode }})•C++${{ matrix.cpp.version }}•Python${{ matrix.python.version }}
31+
runs-on: macos-13 # last macos intel based runner
32+
steps:
33+
- uses: actions/checkout@v4
34+
- name: Set Java to OpenJDK 17 (Temurin)
35+
uses: actions/setup-java@v3
36+
with:
37+
distribution: 'temurin'
38+
java-version: '17'
39+
- name: Setup Python
40+
uses: actions/setup-python@v5
41+
with:
42+
python-version: ${{ matrix.python.version }}
43+
- name: Check Python
44+
run: |
45+
python --version
46+
python -m platform
47+
- name: Check Bazel
48+
run: bazel version
49+
- name: Change Python in MODULE.bazel
50+
run: |
51+
sed -i '' -e 's/\(DEFAULT_PYTHON =\) "3.[0-9]*"/\1 "${{ matrix.python.version }}"/g' MODULE.bazel
52+
cat MODULE.bazel
53+
- name: Build
54+
run: >
55+
bazel build
56+
-c ${{ matrix.bazel.compilation_mode }}
57+
--cxxopt=${{ matrix.cpp.flags }} --host_cxxopt=${{ matrix.cpp.flags }}
58+
--subcommands=pretty_print
59+
--enable_bzlmod
60+
//...
61+
- name: Test
62+
run: >
63+
bazel test
64+
-c ${{ matrix.bazel.compilation_mode }}
65+
--cxxopt=${{ matrix.cpp.flags }} --host_cxxopt=${{ matrix.cpp.flags }}
66+
--subcommands=pretty_print
67+
--enable_bzlmod
68+
//...
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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_abseil/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
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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: [windows-2022, windows-2019]
12+
bazel: [
13+
{compilation_mode: opt},
14+
{compilation_mode: dbg},
15+
]
16+
cpp: [
17+
{version: 14, flags: "/std:c++14"},
18+
{version: 17, flags: "/std:c++17"},
19+
{version: 20, flags: "/std:c++20"},
20+
]
21+
python: [
22+
{version: '3.11'},
23+
]
24+
exclude:
25+
- runner: windows-2019
26+
cpp: {version: 20}
27+
# only test -c dbg with VS 2022 version 17 to save compute time
28+
- runner: windows-2019
29+
bazel: {compilation_mode: dbg}
30+
- cpp: {version: 14}
31+
bazel: {compilation_mode: dbg}
32+
- cpp: {version: 20}
33+
bazel: {compilation_mode: dbg}
34+
fail-fast: false # Don't cancel all jobs if one fails.
35+
name: ${{ matrix.runner }}•Bazel(${{ matrix.bazel.compilation_mode }})•C++${{ matrix.cpp.version }}•Python${{ matrix.python.version }}
36+
runs-on: ${{ matrix.runner }}
37+
steps:
38+
- uses: actions/checkout@v4
39+
- name: Setup Python
40+
uses: actions/setup-python@v5
41+
with:
42+
python-version: ${{ matrix.python.version }}
43+
- name: Check Python
44+
run: |
45+
python --version
46+
python -m platform
47+
- name: Install Bazel
48+
run: choco install bazel
49+
- name: Check Bazel
50+
run: bazel version
51+
- name: Build
52+
run: >
53+
bazel build
54+
-c ${{ matrix.bazel.compilation_mode }}
55+
--cxxopt=${{ matrix.cpp.flags }} --host_cxxopt=${{ matrix.cpp.flags }}
56+
--subcommands=pretty_print
57+
--enable_bzlmod
58+
//...
59+
- name: Test
60+
run: >
61+
bazel test
62+
-c ${{ matrix.bazel.compilation_mode }}
63+
--cxxopt=${{ matrix.cpp.flags }} --host_cxxopt=${{ matrix.cpp.flags }}
64+
--subcommands=pretty_print
65+
--enable_bzlmod
66+
//...

0 commit comments

Comments
 (0)