Skip to content

Commit 99d52a3

Browse files
committed
ci: add github actions jobs to test gcc and libc++
1 parent 5049b81 commit 99d52a3

File tree

8 files changed

+59
-25
lines changed

8 files changed

+59
-25
lines changed

.github/workflows/ci.yml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,22 @@ jobs:
88
build:
99
runs-on: ubuntu-latest
1010

11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
config: [gcc-libstdc++, clang-libc++]
15+
16+
name: build • ${{ matrix.config }}
17+
1118
steps:
12-
- uses: actions/checkout@v4
19+
- uses: actions/checkout@v4
1320

14-
- name: Install Nix
15-
uses: cachix/install-nix-action@v31 # 2025-05-27, from https://github.com/cachix/install-nix-action/tags
16-
with:
17-
nix_path: nixpkgs=channel:nixos-25.05 # latest release
21+
- name: Install Nix
22+
uses: cachix/install-nix-action@v31 # 2025-05-27, from https://github.com/cachix/install-nix-action/tags
23+
with:
24+
nix_path: nixpkgs=channel:nixos-25.05 # latest release
1825

19-
- name: Configure, build, test
20-
run: |
21-
nix-shell --pure --run "ci/scripts/configure.sh"
22-
nix-shell --pure --run "ci/scripts/build.sh"
23-
nix-shell --pure --run "ci/scripts/test.sh"
26+
- name: Run CI script
27+
env:
28+
CI_CONFIG: ci/configs/${{ matrix.config }}.sh
29+
run: ci/run.sh

ci/configs/clang-libc++.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
NIX_ARGS=(
2+
--arg libcxx true
3+
)
4+
CMAKE_ARGS=(
5+
-DCMAKE_BUILD_TYPE=Debug
6+
-DCMAKE_CXX_COMPILER=clang++
7+
-DCMAKE_CXX_STANDARD_LIBRARY=libc++
8+
-DCMAKE_CXX_FLAGS="-Werror -Wall -Wextra -Wpedantic -Wthread-safety-analysis -Wno-unused-parameter"
9+
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
10+
-DMP_ENABLE_CLANG_TIDY=ON
11+
-DMP_ENABLE_IWYU=ON
12+
)

ci/configs/gcc-libstdc++.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
CMAKE_ARGS=(
2+
-DCMAKE_BUILD_TYPE=Debug
3+
-DCMAKE_CXX_FLAGS="-Werror -Wall -Wextra -Wpedantic -Wno-unused-parameter"
4+
)

ci/run.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
set -euxo pipefail
3+
4+
[ "${CI_CONFIG+x}" ] && source "$CI_CONFIG"
5+
6+
for stage in configure build test; do
7+
nix-shell --pure --keep CI_CONFIG "${NIX_ARGS[@]+"${NIX_ARGS[@]}"}" --run ci/scripts/${stage}.sh shell.nix
8+
done

ci/scripts/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env bash
2-
set -euo pipefail
2+
set -euxo pipefail
33

44
cmake --build build -t all tests mpexamples -- -k 0

ci/scripts/configure.sh

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
#!/usr/bin/env bash
2-
set -euo pipefail
2+
set -euxo pipefail
33

4-
cmake -B build -G Ninja \
5-
-DCMAKE_BUILD_TYPE=Debug \
6-
-DCMAKE_CXX_COMPILER=clang++ \
7-
-DCMAKE_CXX_FLAGS="-Wall -Wextra -Wpedantic -Wthread-safety-analysis -Wno-unused-parameter" \
8-
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
9-
-DMP_ENABLE_CLANG_TIDY=ON \
10-
-DMP_ENABLE_IWYU=ON
4+
[ "${CI_CONFIG+x}" ] && source "$CI_CONFIG"
5+
6+
cmake -B build -G Ninja "${CMAKE_ARGS[@]+"${CMAKE_ARGS[@]}"}"

ci/scripts/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env bash
2-
set -euo pipefail
2+
set -euxo pipefail
33

44
ctest --test-dir build --output-on-failure

shell.nix

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
1-
{ pkgs ? import <nixpkgs> {} }:
1+
{ pkgs ? import <nixpkgs> {}
2+
, libcxx ? false # Whether to use libc++ toolchain and libraries instead of libstdc++
3+
}:
24

3-
pkgs.mkShell {
4-
buildInputs = with pkgs; [
5+
let
6+
lib = pkgs.lib;
7+
llvm = pkgs.llvmPackages_20;
8+
mkShell = pkgs.mkShell.override (lib.optionalAttrs libcxx { stdenv = llvm.libcxxStdenv; });
9+
capnproto = pkgs.capnproto.override (lib.optionalAttrs libcxx { clangStdenv = llvm.libcxxStdenv; });
10+
in mkShell {
11+
buildInputs = [
512
capnproto
13+
llvm.libcxx
614
];
715
nativeBuildInputs = with pkgs; [
816
cmake
917
include-what-you-use
10-
llvmPackages_20.clang
11-
llvmPackages_20.clang-tools
18+
llvm.clang
19+
llvm.clang-tools
1220
ninja
1321
];
1422
}

0 commit comments

Comments
 (0)