Skip to content

Commit 3960e3a

Browse files
committed
Add CI, and fix what building with clang turned up
Six configurations: gcc and clang on Linux, clang on macOS, MSVC and clang-cl on Windows, and a MinGW job that builds but does not run tests, since Boost.Test for MinGW is its own undertaking and what is worth knowing there is that the Windows sources compile against something that is not Microsoft. A last job covers the option combinations that have broken quietly before: exceptions off, RTTI off, static, and Release. Only a push to main starts it. Work happens on dev, and spending six runners on every commit along the way is not what they are for. workflow_dispatch stays, since that is how a run is repeated without inventing a commit. The library is built shared in the matrix. That is the arrangement the cross module tests are about, a plugin and a host sharing one copy of stdcorelib, and a static build takes the other branch through them. The run steps name the test binary rather than trusting the build. Boost missing makes the test CMakeLists warn and return, which leaves a green build with nothing built at all, and that is the one failure a CI must not sleep through. Building the whole tree with clang-cl found a second thing it rejects and the other two accept. test_console.cpp has using directives for both stdc and stdc::console, and both of those now have a namespace called detail, so a bare using detail::attributes names two different things. Clang is right, and neither MSVC nor gcc says a word. It became reachable when enable_if_not_array_view moved into stdc::detail an hour ago: console.h includes str.h includes array_view.h. Verified as far as these machines go: MSVC, clang-cl and MinGW all build on Windows, MSVC and clang-cl both run 190 tests green, and the library builds clean on an arm64 mac, popen_darwin.mm included. The runner side of the Windows jobs is what the first run is for.
1 parent 0c72b4c commit 3960e3a

2 files changed

Lines changed: 173 additions & 5 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
name: CI
2+
3+
# Work happens on dev and lands on main, so main is the only branch worth spending runners on.
4+
# workflow_dispatch stays because it is manual, which is how a run is repeated without a push.
5+
on:
6+
push:
7+
branches: [ main ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
# The library is built shared here rather than static, because that is the arrangement the
12+
# cross module tests are about: a plugin and a host that share one copy of stdcorelib. A static
13+
# build gives each of them a copy and those tests check the other branch.
14+
test:
15+
name: ${{ matrix.name }}
16+
runs-on: ${{ matrix.os }}
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
include:
21+
- name: linux gcc
22+
os: ubuntu-latest
23+
cxx: g++
24+
- name: linux clang
25+
os: ubuntu-latest
26+
cxx: clang++
27+
- name: macos clang
28+
os: macos-latest
29+
cxx: clang++
30+
- name: windows msvc
31+
os: windows-latest
32+
toolset: v143
33+
- name: windows clang-cl
34+
os: windows-latest
35+
toolset: ClangCL
36+
37+
steps:
38+
- uses: actions/checkout@v4
39+
40+
- name: Install Boost.Test (Linux)
41+
if: runner.os == 'Linux'
42+
run: |
43+
sudo apt-get update
44+
sudo apt-get install -y libboost-test-dev ninja-build
45+
46+
- name: Install Boost.Test (macOS)
47+
if: runner.os == 'macOS'
48+
run: brew install boost ninja
49+
50+
# vcpkg is already on the Windows image. Building boost-test from source is the slow step
51+
# here, which is what the cache is for.
52+
- name: Cache vcpkg
53+
if: runner.os == 'Windows'
54+
uses: actions/cache@v4
55+
with:
56+
# Where the image puts vcpkg. Spelled out rather than taken from
57+
# VCPKG_INSTALLATION_ROOT, which is a runner variable and not one a with: block can
58+
# be relied on to see.
59+
path: C:\vcpkg\installed
60+
key: vcpkg-boost-test-x64-windows-v1
61+
62+
- name: Install Boost.Test (Windows)
63+
if: runner.os == 'Windows'
64+
run: vcpkg install boost-test:x64-windows
65+
66+
- name: Configure (Unix)
67+
if: runner.os != 'Windows'
68+
env:
69+
CXX: ${{ matrix.cxx }}
70+
run: >
71+
cmake -G Ninja -S . -B build
72+
-DCMAKE_BUILD_TYPE=Debug
73+
-DSTDC_BUILD_SHARED=ON
74+
-DSTDC_BUILD_TESTS=ON
75+
76+
- name: Configure (Windows)
77+
if: runner.os == 'Windows'
78+
run: >
79+
cmake -G "Visual Studio 17 2022" -A x64 -T ${{ matrix.toolset }} -S . -B build
80+
-DSTDC_BUILD_SHARED=ON
81+
-DSTDC_BUILD_TESTS=ON
82+
-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake
83+
84+
- name: Build
85+
run: cmake --build build --config Debug
86+
87+
# Boost missing makes the test CMakeLists warn and return, which leaves the build green with
88+
# nothing built. Naming the binary is what turns that into a failure.
89+
- name: Run tests (Unix)
90+
if: runner.os != 'Windows'
91+
run: ./build/bin/test_auto
92+
93+
# The Visual Studio generator is multi config, so the binary lands under a config directory.
94+
# The debug postfix the CMakeLists sets reaches the libraries, not this.
95+
- name: Run tests (Windows)
96+
if: runner.os == 'Windows'
97+
run: ./build/bin/Debug/test_auto.exe
98+
99+
# MinGW builds the library but does not run the tests: Boost.Test for MinGW is its own
100+
# undertaking, and what is worth knowing here is that the Windows sources compile and link
101+
# against something other than the Microsoft toolchain.
102+
build-mingw:
103+
name: windows mingw
104+
runs-on: windows-latest
105+
steps:
106+
- uses: actions/checkout@v4
107+
108+
- uses: msys2/setup-msys2@v2
109+
with:
110+
msystem: MINGW64
111+
update: false
112+
install: >-
113+
mingw-w64-x86_64-gcc
114+
mingw-w64-x86_64-cmake
115+
mingw-w64-x86_64-ninja
116+
117+
- name: Build shared
118+
shell: msys2 {0}
119+
run: |
120+
cmake -G Ninja -S . -B build -DCMAKE_BUILD_TYPE=Debug -DSTDC_BUILD_SHARED=ON
121+
cmake --build build
122+
123+
- name: Build static
124+
shell: msys2 {0}
125+
run: |
126+
cmake -G Ninja -S . -B build-static -DCMAKE_BUILD_TYPE=Debug -DSTDC_BUILD_STATIC=ON
127+
cmake --build build-static
128+
129+
# The option combinations that have broken before without anybody noticing. Exceptions off
130+
# stopped compiling once and was found by hand months later, so it is a build here.
131+
options:
132+
name: build options
133+
runs-on: ubuntu-latest
134+
steps:
135+
- uses: actions/checkout@v4
136+
137+
- run: |
138+
sudo apt-get update
139+
sudo apt-get install -y libboost-test-dev ninja-build
140+
141+
- name: Exceptions off
142+
run: |
143+
cmake -G Ninja -S . -B build-noexcept -DCMAKE_BUILD_TYPE=Debug \
144+
-DSTDC_ENABLE_EXCEPTIONS=OFF -DSTDC_BUILD_TESTS=OFF
145+
cmake --build build-noexcept
146+
147+
- name: RTTI off
148+
env:
149+
CXXFLAGS: -fno-rtti
150+
run: |
151+
cmake -G Ninja -S . -B build-nortti -DCMAKE_BUILD_TYPE=Debug -DSTDC_BUILD_TESTS=OFF
152+
cmake --build build-nortti
153+
154+
# Static is the arrangement where a plugin and its host each get their own copy of the
155+
# type table, which the tests have a branch for.
156+
- name: Static, with tests
157+
run: |
158+
cmake -G Ninja -S . -B build-static -DCMAKE_BUILD_TYPE=Debug \
159+
-DSTDC_BUILD_STATIC=ON -DSTDC_BUILD_TESTS=ON
160+
cmake --build build-static
161+
./build-static/bin/test_auto
162+
163+
- name: Release
164+
run: |
165+
cmake -G Ninja -S . -B build-release -DCMAKE_BUILD_TYPE=Release \
166+
-DSTDC_BUILD_SHARED=ON -DSTDC_BUILD_TESTS=ON
167+
cmake --build build-release
168+
./build-release/bin/test_auto

‎tests/auto/test_console.cpp‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,8 @@ BOOST_AUTO_TEST_CASE(test_forced_vt_emits_escapes) {
308308
// The escape builder itself, exhaustively. This is the part that cannot be reached through a
309309
// FILE at all without a terminal.
310310
BOOST_AUTO_TEST_CASE(test_sgr_sequence) {
311-
using detail::attributes;
312-
using detail::sgr_sequence;
311+
using console::detail::attributes;
312+
using console::detail::sgr_sequence;
313313

314314
const attributes none;
315315

@@ -366,8 +366,8 @@ BOOST_AUTO_TEST_CASE(test_sgr_sequence) {
366366
}
367367

368368
BOOST_AUTO_TEST_CASE(test_sgr_reset_sequence) {
369-
using detail::attributes;
370-
using detail::sgr_reset_sequence;
369+
using console::detail::attributes;
370+
using console::detail::sgr_reset_sequence;
371371

372372
// already at the defaults
373373
BOOST_CHECK_EQUAL(sgr_reset_sequence(attributes{}), "");
@@ -384,7 +384,7 @@ BOOST_AUTO_TEST_CASE(test_sgr_reset_sequence) {
384384
}
385385

386386
BOOST_AUTO_TEST_CASE(test_attributes_compare) {
387-
using detail::attributes;
387+
using console::detail::attributes;
388388

389389
BOOST_CHECK(attributes{} == attributes({nostyle, nocolor, nocolor}));
390390
BOOST_CHECK(attributes({bold, red, blue}) == attributes({bold, red, blue}));

0 commit comments

Comments
 (0)