Skip to content

Commit

Permalink
ci: reworked windows builds
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiud committed Nov 9, 2021
1 parent 3369666 commit 5e04926
Show file tree
Hide file tree
Showing 9 changed files with 194 additions and 134 deletions.
252 changes: 147 additions & 105 deletions .github/workflows/windows-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,114 +3,156 @@ name: Windows
on: [push, pull_request]

jobs:
build:
# available environments: https://github.com/actions/virtual-environments
name: ${{matrix.config.name}} ${{matrix.build_type}}
runs-on: ${{matrix.config.os}}
build-msvc:
name: ${{matrix.msvc}}-${{matrix.arch}}-C++${{matrix.std}}-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.extra}}
runs-on: ${{matrix.os}}
defaults:
run:
shell: powershell
strategy:
fail-fast: false
matrix:
config:
- {
name: "VS-15-2017-win64-C++11",
os: windows-2016,
generator: "Visual Studio 15 2017",
std: 11,
test_target: RUN_TESTS,
}
- {
name: "VS-16-2019-win64-C++98",
os: windows-2019,
generator: "Visual Studio 16 2019",
std: 98,
test_target: RUN_TESTS,
}
- {
name: "VS-16-2019-win64-C++11",
os: windows-2019,
generator: "Visual Studio 16 2019",
std: 11,
test_target: RUN_TESTS,
}
- {
name: "VS-16-2019-win64-C++17",
os: windows-2019,
generator: "Visual Studio 16 2019",
std: 17,
test_target: RUN_TESTS,
}
- {
name: "VS-16-2019-win64-C++20",
os: windows-2019,
generator: "Visual Studio 16 2019",
std: 20,
test_target: RUN_TESTS,
}
- {
name: "MinGW-C++98",
os: windows-latest,
generator: "MinGW Makefiles",
std: 98,
test_target: test,
}
- {
name: "MinGW-C++11",
os: windows-latest,
generator: "MinGW Makefiles",
std: 11,
test_target: test,
}
- {
name: "MinGW-C++14",
os: windows-latest,
generator: "MinGW Makefiles",
std: 14,
test_target: test,
}
- {
name: "MinGW-C++17",
os: windows-latest,
generator: "MinGW Makefiles",
std: 17,
test_target: test,
}
- {
name: "MinGW-C++20",
os: windows-latest,
generator: "MinGW Makefiles",
std: 20,
test_target: test,
}
build_type: [Debug] #, Release]
ARCH: ["x64"]
std: [98, 11, 14, 17, 20]
msvc: [VS-15-2017, VS-16-2019, VS-17-2022]
build_type: [Debug, Release]
lib: [shared, static]
arch: [Win32, x64]
extra: [no-custom-prefix, custom-prefix]
include:
- msvc: VS-15-2017
os: windows-2016
generator: 'Visual Studio 15 2017'
- msvc: VS-16-2019
os: windows-2019
generator: 'Visual Studio 16 2019'
- msvc: VS-17-2022
os: windows-2022
generator: 'Visual Studio 17 2022'

steps:
- uses: actions/checkout@v2

# Visual Studio build steps
- name: Configure build MSVC
if: ${{ startswith(matrix.config.name, 'VS-') }}
shell: powershell
run: cmake -S . -B ${{runner.workspace}}/build_${{matrix.config.name}}_${{matrix.build_type}} -G "${{matrix.config.generator}}" -A "${{matrix.ARCH}}" -DCMAKE_CXX_STANDARD=${{matrix.config.std}} -DCMAKE_CXX_STANDARD_REQUIRED=ON -DCMAKE_CXX_EXTENSIONS=OFF
- name: Build MSVC
if: ${{ startswith(matrix.config.name, 'VS-') }}
shell: powershell
run: cmake --build ${{runner.workspace}}/build_${{matrix.config.name}}_${{matrix.build_type}} --config ${{matrix.build_type}}

# MinGW build steps
- name: Configure build MinGW
if: ${{ startswith(matrix.config.name, 'MinGW-') }}
shell: powershell
env:
CXXFLAGS: -Wall -Wextra -Wpedantic -Wsign-conversion -Wtautological-compare -Werror -Wno-error=variadic-macros -Wno-error=long-long
run: cmake -S . -B ${{runner.workspace}}/build_${{matrix.config.name}}_${{matrix.build_type}} -G "${{matrix.config.generator}}" -DCMAKE_CXX_STANDARD=${{matrix.config.std}} -DCMAKE_CXX_EXTENSIONS=OFF -DCMAKE_CXX_STANDARD_REQUIRED=ON -DCMAKE_BUILD_TYPE=${{matrix.build_type}}
- name: Build MinGW
if: ${{ startswith(matrix.config.name, 'MinGW-') }}
shell: powershell
run: cmake --build ${{runner.workspace}}/build_${{matrix.config.name}}_${{matrix.build_type}}

- name: Run tests
shell: powershell
env:
- uses: actions/checkout@v2

- name: Configure
run: |
cmake -S . -B build_${{matrix.build_type}} `
-A ${{matrix.arch}} `
-DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} `
-DCMAKE_CXX_EXTENSIONS=OFF `
-DCMAKE_CXX_STANDARD=${{matrix.std}} `
-DCMAKE_CXX_STANDARD_REQUIRED=ON `
-DCMAKE_INSTALL_PREFIX:PATH=./install `
-DWITH_CUSTOM_PREFIX=${{matrix.extra == 'custom-prefix'}} `
-G "${{matrix.generator}}"
- name: Build
run: cmake --build build_${{matrix.build_type}} `
--config ${{matrix.build_type}}

- name: Test
env:
CTEST_OUTPUT_ON_FAILURE: 1
run: |
cmake --build build_${{matrix.build_type}}/ `
--config ${{matrix.build_type}} `
--target RUN_TESTS
- name: Install
run: |
cmake --build build_${{matrix.build_type}}/ `
--config ${{matrix.build_type}} `
--target install
build-mingw:
name: ${{matrix.sys}}-${{matrix.env}}-C++${{matrix.std}}-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.extra}}
runs-on: windows-latest
defaults:
run:
shell: msys2 {0}
strategy:
fail-fast: false
matrix:
std: [98, 11, 14, 17, 20]
build_type: [Debug, Release]
sys: [mingw32, mingw64]
lib: [shared, static]
extra: [no-custom-prefix, custom-prefix]
include:
- sys: mingw32
env: i686
- sys: mingw64
env: x86_64

steps:
- uses: actions/checkout@v2
- uses: msys2/setup-msys2@v2
with:
msystem: ${{matrix.sys}}
install: >-
lcov
mingw-w64-${{matrix.env}}-cmake
mingw-w64-${{matrix.env}}-gcc
mingw-w64-${{matrix.env}}-gtest
mingw-w64-${{matrix.env}}-libunwind
mingw-w64-${{matrix.env}}-ninja
- name: Configure
env:
CXXFLAGS: -Wall -Wextra -Wpedantic -Wsign-conversion -Wtautological-compare -Werror -Wno-error=variadic-macros -Wno-error=long-long
run: |
if [[ ${{matrix.build_type}} == "Debug" ]]; then
export CXXFLAGS="--coverage ${CXXFLAGS}"
fi
cmake -S . -B build_${{matrix.build_type}}/ \
-DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} \
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
-DCMAKE_CXX_EXTENSIONS=OFF \
-DCMAKE_CXX_STANDARD=${{matrix.std}} \
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
-DCMAKE_INSTALL_PREFIX:PATH=./install \
-DWITH_CUSTOM_PREFIX=${{matrix.extra == 'custom-prefix'}} \
-G Ninja
- name: Build
run: |
cmake --build build_${{matrix.build_type}}/ --config ${{matrix.build_type}}
- name: Test
env:
CTEST_OUTPUT_ON_FAILURE: 1
run: cmake --build ${{runner.workspace}}/build_${{matrix.config.name}}_${{matrix.build_type}} --target ${{matrix.config.test_target}}
run: |
cmake --build build_${{matrix.build_type}}/ --config ${{matrix.build_type}} \
--target test
- name: Install
run: |
cmake --build build_${{matrix.build_type}}/ \
--config ${{matrix.build_type}} \
--target install
- name: Generate Coverage
if: ${{ startswith(matrix.build_type, 'Debug') }}
run: |
lcov --directory . --capture --output-file coverage.info
lcov --remove coverage.info \
'*/install/include/*' \
'*/src/*_unittest.cc' \
'*/src/googletest.h' \
'*/src/mock-log.h' \
'/usr/*' \
--output-file coverage.info
for file in src/glog/*.h.in; do
name=$(basename ${file})
name_we=${name%.h.in}
sed -i "s|build_${{matrix.build_type}}/glog/${name_we}.h\$|${file}|g" coverage.info
done
lcov --list coverage.info
- name: Upload Coverage to Coveralls
if: ${{ startswith(matrix.build_type, 'Debug') }}
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./coverage.info
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,7 @@ if (BUILD_TESTING)

add_test (NAME cmake_package_config_build COMMAND
${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/test_package_config/working_config
--config $<CONFIG>
)

add_test (NAME cmake_package_config_cleanup COMMAND ${CMAKE_COMMAND} -E
Expand Down
2 changes: 1 addition & 1 deletion src/glog/logging.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ struct LogMessageTime {
const time_t& timestamp() const { return ts; }
const int& sec() const { return time_struct.tm_sec; }
const int32_t& usec() const { return usecs; }
const int& min() const { return time_struct.tm_min; }
const int& (min)() const { return time_struct.tm_min; }
const int& hour() const { return time_struct.tm_hour; }
const int& day() const { return time_struct.tm_mday; }
const int& month() const { return time_struct.tm_mon; }
Expand Down
4 changes: 2 additions & 2 deletions src/googletest.h
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ class Thread {
handle_ = CreateThread(NULL,
0,
&Thread::InvokeThreadW,
(LPVOID)this,
this,
0,
&th_);
CHECK(handle_) << "CreateThread";
Expand Down Expand Up @@ -594,7 +594,7 @@ class Thread {
}

#if defined(GLOG_OS_WINDOWS) && !defined(GLOG_OS_CYGWIN)
static DWORD InvokeThreadW(void* self) {
static DWORD __stdcall InvokeThreadW(LPVOID self) {
InvokeThread(self);
return 0;
}
Expand Down
14 changes: 7 additions & 7 deletions src/logging_custom_prefix_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1246,7 +1246,7 @@ TEST(DVLog, Basic) {
// We are expecting that nothing is logged.
EXPECT_CALL(log, Log(_, _, _)).Times(0);
#else
EXPECT_CALL(log, Log(INFO, __FILE__, "debug log"));
EXPECT_CALL(log, Log(GLOG_INFO, __FILE__, "debug log"));
#endif

FLAGS_v = 1;
Expand All @@ -1267,13 +1267,13 @@ TEST(LogAtLevel, Basic) {
ScopedMockLog log;

// The function version outputs "logging.h" as a file name.
EXPECT_CALL(log, Log(WARNING, StrNe(__FILE__), "function version"));
EXPECT_CALL(log, Log(INFO, __FILE__, "macro version"));
EXPECT_CALL(log, Log(GLOG_WARNING, StrNe(__FILE__), "function version"));
EXPECT_CALL(log, Log(GLOG_INFO, __FILE__, "macro version"));

int severity = WARNING;
int severity = GLOG_WARNING;
LogAtLevel(severity, "function version");

severity = INFO;
severity = GLOG_INFO;
// We can use the macro version as a C++ stream.
LOG_AT_LEVEL(severity) << "macro" << ' ' << "version";
}
Expand All @@ -1294,9 +1294,9 @@ TEST(TestExitOnDFatal, ToBeOrNotToBe) {
// downgraded to ERROR if not debugging.
const LogSeverity severity =
#ifdef NDEBUG
ERROR;
GLOG_ERROR;
#else
FATAL;
GLOG_FATAL;
#endif
EXPECT_CALL(log, Log(severity, __FILE__, "This should not be fatal"));
LOG(DFATAL) << "This should not be fatal";
Expand Down
14 changes: 7 additions & 7 deletions src/logging_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1334,7 +1334,7 @@ TEST(DVLog, Basic) {
// We are expecting that nothing is logged.
EXPECT_CALL(log, Log(_, _, _)).Times(0);
#else
EXPECT_CALL(log, Log(INFO, __FILE__, "debug log"));
EXPECT_CALL(log, Log(GLOG_INFO, __FILE__, "debug log"));
#endif

FLAGS_v = 1;
Expand All @@ -1355,13 +1355,13 @@ TEST(LogAtLevel, Basic) {
ScopedMockLog log;

// The function version outputs "logging.h" as a file name.
EXPECT_CALL(log, Log(WARNING, StrNe(__FILE__), "function version"));
EXPECT_CALL(log, Log(INFO, __FILE__, "macro version"));
EXPECT_CALL(log, Log(GLOG_WARNING, StrNe(__FILE__), "function version"));
EXPECT_CALL(log, Log(GLOG_INFO, __FILE__, "macro version"));

int severity = WARNING;
int severity = GLOG_WARNING;
LogAtLevel(severity, "function version");

severity = INFO;
severity = GLOG_INFO;
// We can use the macro version as a C++ stream.
LOG_AT_LEVEL(severity) << "macro" << ' ' << "version";
}
Expand All @@ -1382,9 +1382,9 @@ TEST(TestExitOnDFatal, ToBeOrNotToBe) {
// downgraded to ERROR if not debugging.
const LogSeverity severity =
#ifdef NDEBUG
ERROR;
GLOG_ERROR;
#else
FATAL;
GLOG_FATAL;
#endif
EXPECT_CALL(log, Log(severity, __FILE__, "This should not be fatal"));
LOG(DFATAL) << "This should not be fatal";
Expand Down
Loading

0 comments on commit 5e04926

Please sign in to comment.