Skip to content

Commit b28d03d

Browse files
Mizuxcopybara-github
authored andcommitted
Update CI workflows
* Add CMake and Bazel workflows to get badges * Add MacOS (amd64 and M1) and Windows jobs * bazel: Add C++14, c++17 and c++20 flavours * bazel: Add `-c opt` and `-c dbg` variants * cmake(linux): Test Unix Makefile and Ninja Build generators * cmake(macOS): Test XCode and Makefile generators * cmake(windows): Test MSVC (VC 2022) generator * import ubuntu-build.yml from pybind11_protobuf PiperOrigin-RevId: 715743424
1 parent 2420efd commit b28d03d

11 files changed

+679
-24
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: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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.8'},
22+
{version: '3.9'},
23+
{version: '3.10'},
24+
{version: '3.11'},
25+
{version: '3.12'},
26+
]
27+
exclude:
28+
# only test `-c dbg` build with C++17 and Python{3.11,3.12}
29+
- cpp: {version: 14}
30+
bazel: {compilation_mode: dbg}
31+
- cpp: {version: 20}
32+
bazel: {compilation_mode: dbg}
33+
- python: {version: '3.8'}
34+
bazel: {compilation_mode: dbg}
35+
- python: {version: '3.9'}
36+
bazel: {compilation_mode: dbg}
37+
- python: {version: '3.10'}
38+
bazel: {compilation_mode: dbg}
39+
fail-fast: false
40+
name: Linux•Bazel(${{ matrix.bazel.compilation_mode }})•C++${{ matrix.cpp.version }}•Python${{ matrix.python.version }}
41+
runs-on: ubuntu-latest
42+
steps:
43+
- uses: actions/checkout@v4
44+
- name: Check Java
45+
run: java -version
46+
- name: Setup Python
47+
uses: actions/setup-python@v5
48+
with:
49+
python-version: ${{ matrix.python.version }}
50+
- name: Check Python
51+
run: |
52+
python --version
53+
python -m platform
54+
- uses: bazel-contrib/[email protected]
55+
with:
56+
bazelisk-cache: true
57+
disk-cache: ${{ github.workflow }}
58+
repository-cache: true
59+
- name: Check Bazel
60+
run: bazel version
61+
- name: Build
62+
run: >
63+
bazel build
64+
-c ${{ matrix.bazel.compilation_mode }}
65+
--cxxopt=${{ matrix.cpp.flags }} --host_cxxopt=${{ matrix.cpp.flags }}
66+
--subcommands=pretty_print
67+
--enable_bzlmod
68+
//...
69+
- name: Test
70+
run: >
71+
bazel test
72+
-c ${{ matrix.bazel.compilation_mode }}
73+
--cxxopt=${{ matrix.cpp.flags }} --host_cxxopt=${{ matrix.cpp.flags }}
74+
--subcommands=pretty_print
75+
--enable_bzlmod
76+
//...
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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.8'},
13+
{version: '3.9'},
14+
{version: '3.10'},
15+
{version: '3.11'},
16+
{version: '3.12'},
17+
#{version: '3.13'},
18+
]
19+
cmake: [
20+
{generator: "Unix Makefiles", config: "Release"},
21+
{generator: "Ninja", config: "Release"},
22+
#{generator: "Ninja Multi-Config", config: "Release"},
23+
]
24+
fail-fast: false
25+
name: Linux•CMake(${{ matrix.cmake.generator }})•Python${{ matrix.python.version }}
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v4
29+
- name: Setup Python
30+
uses: actions/setup-python@v5
31+
with:
32+
python-version: ${{ matrix.python.version }}
33+
- name: Check Python
34+
run: |
35+
python --version
36+
python -m platform
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: Install Ninja
40+
run: |
41+
sudo apt-get update
42+
sudo apt-get install ninja-build
43+
- name: Check CMake
44+
run: cmake --version
45+
- name: Configure
46+
run: >
47+
cmake -S. -Bbuild
48+
-G "${{ matrix.cmake.generator }}"
49+
-DCMAKE_BUILD_TYPE="${{ matrix.cmake.config }}"
50+
-DCMAKE_INSTALL_PREFIX=install
51+
- name: Build
52+
run: >
53+
cmake --build build
54+
--config ${{ matrix.cmake.config }}
55+
--target all
56+
-v -j2
57+
- name: Test
58+
run: >
59+
CTEST_OUTPUT_ON_FAILURE=1
60+
cmake --build build
61+
--config ${{ matrix.cmake.config }}
62+
--target test
63+
-v
64+
- name: Install
65+
run: >
66+
cmake --build build
67+
--config ${{ matrix.cmake.config }}
68+
--target install
69+
-v
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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.8'},
22+
#{version: '3.9'},
23+
#{version: '3.10'},
24+
{version: '3.11'},
25+
{version: '3.12'},
26+
]
27+
exclude:
28+
# only test `-c dbg` build with C++17 and Python{3.11,3.12}
29+
- cpp: {version: 14}
30+
bazel: {compilation_mode: dbg}
31+
- cpp: {version: 20}
32+
bazel: {compilation_mode: dbg}
33+
- python: {version: '3.8'}
34+
bazel: {compilation_mode: dbg}
35+
- python: {version: '3.9'}
36+
bazel: {compilation_mode: dbg}
37+
- python: {version: '3.10'}
38+
bazel: {compilation_mode: dbg}
39+
fail-fast: false
40+
name: MacOS•Bazel(${{ matrix.bazel.compilation_mode }})•C++${{ matrix.cpp.version }}•Python${{ matrix.python.version }}
41+
runs-on: macos-13 # last macos intel based runner
42+
steps:
43+
- uses: actions/checkout@v4
44+
- name: Set Java to OpenJDK 17 (Temurin)
45+
uses: actions/setup-java@v3
46+
with:
47+
distribution: 'temurin'
48+
java-version: '17'
49+
- name: Setup Python
50+
uses: actions/setup-python@v5
51+
with:
52+
python-version: ${{ matrix.python.version }}
53+
- name: Check Python
54+
run: |
55+
python --version
56+
python -m platform
57+
- name: Check Bazel
58+
run: bazel version
59+
- name: Change Python in MODULE.bazel
60+
run: |
61+
sed -i '' -e 's/\(DEFAULT_PYTHON =\) "3.[0-9]*"/\1 "${{ matrix.python.version }}"/g' MODULE.bazel
62+
cat MODULE.bazel
63+
- name: Build
64+
run: >
65+
bazel build
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+
- name: Test
72+
run: >
73+
bazel test
74+
-c ${{ matrix.bazel.compilation_mode }}
75+
--cxxopt=${{ matrix.cpp.flags }} --host_cxxopt=${{ matrix.cpp.flags }}
76+
--subcommands=pretty_print
77+
--enable_bzlmod
78+
//...
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 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.8'},
13+
{version: '3.9'},
14+
{version: '3.10'},
15+
{version: '3.11'},
16+
{version: '3.12'},
17+
#{version: '3.13'},
18+
]
19+
cmake: [
20+
{generator: "Xcode", config: Release, build_target: ALL_BUILD, test_target: RUN_TESTS, install_target: install},
21+
{generator: "Unix Makefiles", config: Release, build_target: all, test_target: test, install_target: install},
22+
]
23+
fail-fast: false
24+
name: MacOS•CMake(${{ matrix.cmake.generator }})•Python${{ matrix.python.version }}
25+
runs-on: macos-13 # last macos intel based runner
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: Update Path
33+
run: |
34+
echo "$HOME/Library/Python/${{ matrix.python.version }}/bin" >> $GITHUB_PATH
35+
echo "$HOME/.local/bin" >> $GITHUB_PATH
36+
- name: Check Python
37+
run: python --version
38+
- name: Install Python requirements
39+
run: python -m pip install --upgrade -r $(python -c 'import sys; print("./pybind11_abseil/requirements/requirements_lock_%d_%d.txt" % (sys.version_info[:2]))')
40+
- name: Check CMake
41+
run: cmake --version
42+
- name: Configure
43+
run: >
44+
cmake -S. -Bbuild
45+
-G "${{ matrix.cmake.generator }}"
46+
-DCMAKE_BUILD_TYPE=${{ matrix.cmake.config }}
47+
-DCMAKE_INSTALL_PREFIX=install
48+
- name: Build
49+
run: >
50+
cmake --build build
51+
--config ${{ matrix.cmake.config }}
52+
--target ${{ matrix.cmake.build_target }}
53+
-v -j2
54+
- name: Test
55+
run: >
56+
CTEST_OUTPUT_ON_FAILURE=1
57+
cmake --build build
58+
--config ${{ matrix.cmake.config }}
59+
--target ${{ matrix.cmake.test_target }}
60+
-v
61+
- name: Install
62+
run: >
63+
cmake --build build
64+
--config ${{ matrix.cmake.config }}
65+
--target ${{ matrix.cmake.install_target }}
66+
-v

0 commit comments

Comments
 (0)