Skip to content

Commit da9e220

Browse files
authored
QPID-8610: add GitHub Actions workflow to build project and run ctest (#34)
Github Actions don't run on the PR, so I am monitoring it on my fork, https://github.com/jiridanek/qpid-cpp/actions/runs/4644235028 Using Focal (`runs-on: ubuntu-20.04`) for now, as it has the old requirements we need. Travis used to run Xenial, that worked even better, without workarounds for swig and ruby. Python 2.7 is required ([QPID-8516](https://issues.apache.org/jira/browse/QPID-8516), [QPID-4982](https://issues.apache.org/jira/browse/QPID-4982), [QPID-8517](https://issues.apache.org/jira/browse/QPID-8517)) Linux environment requires swig3.0 and ruby2.6 to compile and work ([QPID-8606](https://issues.apache.org/jira/browse/QPID-8606), swig/swig#1689) The vcpkg version of Boost requires some changes to how dependencies are linked. What's in the PR now works on both Appveyor and Github Actions. Caching is very important. Both installing boost with vcpkg on Windows and compiling the broker code takes a lot of time without cache. With cache, vcpkg is nearly instantaneous and broker compile takes only a few minutes on Linux, and few more on Windows. When using sccache, make or ninja CMake generators have to be used. MSBuild is not supported for `-DCMAKE_C_COMPILER_LAUNCHER` CMake option. This can be workarounded in the future by the usual trick of renaming `sccache.exe` to `cl.exe`. Tests run very long. I am afraid to run them in parallel as part of this PR. I want to leave that for later. But it is going to be necessary, because the CI just takes way too much time otherwise. Broker tests don't run on Windows and AFAIK they did not run there for a very long time.
1 parent 43d6b96 commit da9e220

File tree

6 files changed

+197
-23
lines changed

6 files changed

+197
-23
lines changed

.github/workflows/build.yml

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
name: Build
2+
3+
on: [ push, pull_request, workflow_dispatch ]
4+
5+
jobs:
6+
build:
7+
runs-on: ${{ matrix.os }}
8+
strategy:
9+
fail-fast: false
10+
matrix:
11+
os: [ ubuntu-20.04, windows-latest ]
12+
buildType: [ RelWithDebInfo ]
13+
include:
14+
- os: ubuntu-20.04
15+
# QPID-8606: we don't support swig 4.0, it produces runtime errors when used
16+
cmake_extra: '-DSWIG_EXECUTABLE="/usr/bin/swig3.0" -DRUBY_EXECUTABLE="/usr/bin/ruby2.6"'
17+
- os: windows-latest
18+
cmake_extra: '-DBUILD_BINDING_DOTNET=OFF -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake'
19+
env:
20+
BuildType: ${{matrix.buildType}}
21+
BuildDir: ${{github.workspace}}/BLD
22+
InstallPrefix: ${{github.workspace}}/INSTALL
23+
PKG_CONFIG_PATH: ${{matrix.pkg_config_path}}
24+
VCPKG_DEFAULT_TRIPLET: x64-windows
25+
VCPKG_BINARY_SOURCES: 'clear;nuget,GitHub,readwrite'
26+
SCCACHE_DIR: ${{github.workspace}}/SCCACHE
27+
28+
steps:
29+
30+
- uses: actions/checkout@v3
31+
32+
- name: Setup python
33+
uses: actions/setup-python@v4
34+
with:
35+
python-version: 2.7
36+
architecture: x64
37+
38+
- name: Setup Developer Command Prompt (on Windows)
39+
uses: ilammy/msvc-dev-cmd@v1
40+
if: runner.os == 'Windows'
41+
with:
42+
arch: x64
43+
44+
# it's weird that it needs qpid-python for tests; one would guess this is built in this repo, but it is not
45+
- name: Install python dependencies
46+
run: |
47+
python -m pip install --upgrade pip
48+
python -m pip install setuptools qpid-python
49+
50+
- name: Install Linux dependencies
51+
if: runner.os == 'Linux'
52+
run: |
53+
# ubuntu packages (https://packages.ubuntu.com/source/focal/qpid-proton) don't carry ProtonConfig.cmake
54+
# the `testing` ppa is less likely to be out-of-date
55+
sudo add-apt-repository ppa:qpid/testing && sudo apt-get update
56+
57+
# https://github.com/swig/swig/issues/1689
58+
# swig3.0 in focal does not work well with ruby2.7
59+
sudo apt-add-repository ppa:brightbox/ruby-ng && sudo apt-get update
60+
61+
sudo apt-get -yq --no-install-suggests --no-install-recommends install \
62+
cmake ninja-build \
63+
libboost-dev libboost-program-options-dev libboost-system-dev libboost-test-dev \
64+
libxqilla-dev libxerces-c-dev \
65+
libibverbs-dev librdmacm-dev \
66+
libdb++-dev libaio-dev \
67+
libqpid-proton11-dev libqpid-proton-core10 libqpid-proton-proactor1 \
68+
swig3.0 python-dev ruby2.6 ruby2.6-dev \
69+
uuid-dev libnss3-dev libnss3-tools libsasl2-dev sasl2-bin \
70+
valgrind
71+
72+
sccache_version=v0.4.1
73+
wget -q https://github.com/mozilla/sccache/releases/download/${sccache_version}/sccache-${sccache_version}-x86_64-unknown-linux-musl.tar.gz
74+
tar -xf sccache-${sccache_version}-x86_64-unknown-linux-musl.tar.gz sccache-${sccache_version}-x86_64-unknown-linux-musl/sccache
75+
sudo mv sccache-${sccache_version}-x86_64-unknown-linux-musl/sccache /usr/bin/sccache
76+
sudo chmod +x /usr/bin/sccache
77+
shell: bash
78+
79+
- name: Cache scoop (on Windows)
80+
uses: actions/cache@v3
81+
if: runner.os == 'Windows'
82+
with:
83+
path: ~\scoop
84+
key: ${{ runner.os }}-scoop-${{ env.OS_VER }}-${{ hashFiles('.github/workflows/build.yml') }}
85+
restore-keys: |
86+
${{ runner.os }}-scoop-${{ env.OS_VER }}-
87+
${{ runner.os }}-scoop-
88+
89+
- name: Cache vcpkg/downloads (on Windows)
90+
uses: actions/cache@v3
91+
if: runner.os == 'Windows'
92+
with:
93+
path: C:\vcpkg\downloads
94+
key: ${{ runner.os }}-vcpkg-download-${{ env.OS_VER }}-${{ hashFiles('.github/workflows/build.yml') }}
95+
restore-keys: |
96+
${{ runner.os }}-vcpkg-download-${{ env.OS_VER }}-
97+
${{ runner.os }}-vcpkg-download-
98+
- name: Cache vcpkg/installed (on Windows)
99+
uses: actions/cache@v3
100+
if: runner.os == 'Windows'
101+
with:
102+
path: C:\vcpkg\installed
103+
key: ${{ runner.os }}-vcpkg-installed-${{ matrix.os }}-${{ hashFiles('.github/workflows/build.yml') }}
104+
restore-keys: |
105+
${{ runner.os }}-vcpkg-installed-${{ matrix.os }}-
106+
${{ runner.os }}-vcpkg-installed-
107+
108+
- name: Cache SCCACHE_DIR
109+
uses: actions/cache@v3
110+
with:
111+
path: "${{ env.SCCACHE_DIR }}"
112+
key: ${{ runner.os }}-sccache-${{ matrix.os }}-${{ github.sha }}
113+
restore-keys: |
114+
${{ runner.os }}-sccache-${{ matrix.os }}-
115+
${{ runner.os }}-sccache-
116+
117+
- name: Install Windows dependencies
118+
if: runner.os == 'Windows'
119+
run: |
120+
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser # Optional: Needed to run a remote script the first time
121+
iex "& {$(irm get.scoop.sh)} -RunAsAdmin"
122+
scoop install sccache
123+
124+
vcpkg install boost-program-options boost-system boost-test boost-date-time boost-thread boost-chrono boost-format boost-ptr-container boost-assign boost-parameter boost-foreach boost-utility
125+
vcpkg integrate install
126+
127+
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#add-a-system-path-add-path
128+
Add-Content ${env:GITHUB_PATH} "${HOME}/scoop/shims"
129+
130+
# work around assumptions in our build scripts about boost libs layout
131+
Copy-Item -Path C:/vcpkg/installed/x64-windows/debug/bin/* -Include *.dll -Destination C:/vcpkg/installed/x64-windows/debug/lib
132+
Get-Item C:/vcpkg/installed/x64-windows/debug/lib/*.dll | Rename-Item -NewName { $_.Name -replace '-vc14.-mt-gd-x64-1_81.dll','-vc140-mt-gd.dll' }
133+
# display results of this hard work
134+
ls C:/vcpkg/installed/x64-windows/debug/bin/
135+
ls C:/vcpkg/installed/x64-windows/debug/lib/
136+
# now do the same for release
137+
Copy-Item -Path C:/vcpkg/installed/x64-windows/bin/* -Include *.dll -Destination C:/vcpkg/installed/x64-windows/lib
138+
Get-Item C:/vcpkg/installed/x64-windows/lib/*.dll | Rename-Item -NewName { $_.Name -replace '-vc14.-mt-x64-1_81.dll','-vc140-mt.dll' }
139+
# display results of this hard work
140+
ls C:/vcpkg/installed/x64-windows/bin/
141+
ls C:/vcpkg/installed/x64-windows/lib/
142+
shell: pwsh
143+
144+
# Windows build should ideally use something like '-G "Visual Studio 16 2019" -A x64',
145+
# but -DCMAKE_C_COMPILER_LAUNCHER is only supported by make and ninja generators
146+
# https://devblogs.microsoft.com/scripting/powertip-line-continuation-in-powershell/
147+
- name: cmake configure
148+
run: |
149+
cmake -S "${{github.workspace}}" -B "${{env.BuildDir}}" -G Ninja `
150+
-DCMAKE_C_COMPILER_LAUNCHER="sccache" -DCMAKE_CXX_COMPILER_LAUNCHER="sccache" `
151+
"-DCMAKE_BUILD_TYPE=${{env.BuildType}}" `
152+
"-DCMAKE_INSTALL_PREFIX=${{env.InstallPrefix}}" `
153+
${{matrix.cmake_extra}}
154+
shell: pwsh
155+
156+
# https://stackoverflow.com/a/46187862/1047788
157+
# https://github.com/jiridanek/qpid-cpp/actions/runs/3314156604/jobs/5473066487#step:12:1472
158+
- name: cmake build/install
159+
run: |
160+
cmake --build "${{env.BuildDir}}" --config ${{env.BuildType}} -- -v
161+
cmake --install "${{env.BuildDir}}" --config ${{env.BuildType}}
162+
shell: pwsh
163+
164+
- id: ctest
165+
name: ctest
166+
working-directory: ${{env.BuildDir}}
167+
run: PYTHONPATH=${InstallPrefix}/lib/python2.7/site-packages ctest -C ${BuildType} -V -T Test --no-compress-output ${{matrix.ctest_extra}}
168+
shell: bash
169+
170+
- name: Upload Test results
171+
if: always() && (steps.ctest.outcome == 'failure' || steps.ctest.outcome == 'success')
172+
uses: actions/upload-artifact@v3
173+
with:
174+
name: Test_Results_${{matrix.os}}_${{matrix.buildType}}
175+
path: ${{env.BuildDir}}/Testing/**/*.xml
176+
177+
- name: Environment
178+
if: always()
179+
run: env -0 | sort -z | tr '\0' '\n'
180+
shell: bash

CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ include (CTest)
6969
configure_file(${CMAKE_SOURCE_DIR}/CTestCustom.cmake ${CMAKE_BINARY_DIR}/CTestCustom.cmake)
7070

7171
if (MSVC)
72-
# Chaxnge warning C4996 from level 1 to level 4. These are real and shouldn't
72+
# Change warning C4996 from level 1 to level 4. These are real and shouldn't
7373
# be completely ignored, but they're pretty well checked out and will throw
7474
# a run-time error if violated.
75-
# "warning C4996: 'std::equal': Function call with parameters that may
76-
# be unsafe..."
77-
add_definitions(/w44996)
75+
# "warning C4996: 'std::equal': Function call with parameters that may be unsafe..."
76+
# https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-3-c4996?view=msvc-140
77+
add_compile_options(/wd4996)
7878
endif (MSVC)
7979

8080
# Overall packaging/install options.

src/CMakeLists.txt

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,7 @@ endif (BUILD_TESTING)
230230
# DLLs that are needed for the Windows package, none are needed for the
231231
# static link case; else drop them into the install. Do this all first, since
232232
# Boost on Windows can use automatic linking to pick up the correct
233-
# Boost libs based on compile-time touching of the headers. Since we don't
234-
# really need to add them to the link lines, set the names to blanks.
233+
# Boost libs based on compile-time touching of the headers.
235234
option(QPID_LINK_BOOST_DYNAMIC "Link with dynamic Boost libs (OFF to link static)" ON)
236235
mark_as_advanced(QPID_LINK_BOOST_DYNAMIC)
237236

@@ -272,12 +271,6 @@ if (MSVC)
272271
COMPONENT ${QPID_COMPONENT_COMMON})
273272
endif (QPID_LINK_BOOST_DYNAMIC)
274273

275-
set(Boost_DATE_TIME_LIBRARY "")
276-
set(Boost_THREAD_LIBRARY "")
277-
set(Boost_PROGRAM_OPTIONS_LIBRARY "")
278-
set(Boost_UNIT_TEST_FRAMEWORK_LIBRARY "")
279-
set(Boost_SYSTEM_LIBRARY "")
280-
set(Boost_CHRONO_LIBRARY "")
281274
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/windows/resources )
282275
endif (MSVC)
283276

@@ -577,7 +570,8 @@ if (BUILD_HA)
577570
target_link_libraries (ha
578571
PRIVATE
579572
qpidtypes qpidcommon qpidbroker qpidmessaging
580-
${Boost_PROGRAM_OPTIONS_LIBRARY})
573+
${Boost_PROGRAM_OPTIONS_LIBRARY}
574+
${Boost_THREAD_LIBRARY})
581575
set_target_properties (ha PROPERTIES
582576
PREFIX "")
583577
install (TARGETS ha
@@ -937,7 +931,8 @@ add_msvc_version (qpidclient library dll)
937931
add_library (qpidclient SHARED ${qpidclient_SOURCES})
938932

939933
target_link_libraries (qpidclient PRIVATE qpidcommon qpidtypes
940-
${ssl_LIBS})
934+
${ssl_LIBS}
935+
${Boost_THREAD_LIBRARY})
941936

942937
set_target_properties (qpidclient PROPERTIES
943938
VERSION ${qpidclient_version}
@@ -1004,7 +999,7 @@ set (qpidmessaging_SOURCES
1004999
add_msvc_version (qpidmessaging library dll)
10051000

10061001
add_library (qpidmessaging SHARED ${qpidmessaging_SOURCES})
1007-
target_link_libraries (qpidmessaging PRIVATE qpidtypes qpidclient qpidcommon ${Proton_Core_LIBRARIES})
1002+
target_link_libraries (qpidmessaging PRIVATE qpidtypes qpidclient qpidcommon ${Proton_Core_LIBRARIES} ${Boost_THREAD_LIBRARY})
10081003
set_target_properties (qpidmessaging PROPERTIES
10091004
LINK_FLAGS "${HIDE_SYMBOL_FLAGS} ${LINK_VERSION_SCRIPT_FLAG}"
10101005
COMPILE_FLAGS "${HIDE_SYMBOL_FLAGS}"
@@ -1141,7 +1136,8 @@ target_link_libraries (qpidbroker
11411136
PRIVATE
11421137
qpidcommon qpidtypes
11431138
"${sasl_LIB}"
1144-
${ssl_server_LIBS})
1139+
${ssl_server_LIBS}
1140+
${Boost_THREAD_LIBRARY})
11451141

11461142
set_target_properties (qpidbroker PROPERTIES
11471143
VERSION ${qpidbroker_version}
@@ -1256,7 +1252,7 @@ endif (NOT WIN32)
12561252

12571253
add_msvc_version (qmf2 library dll)
12581254
add_library (qmf2 SHARED ${qmf2_SOURCES})
1259-
target_link_libraries (qmf2 PRIVATE qpidmessaging qpidtypes qpidclient qpidcommon)
1255+
target_link_libraries (qmf2 PRIVATE qpidmessaging qpidtypes qpidclient qpidcommon ${Boost_THREAD_LIBRARY})
12601256
set_target_properties (qmf2 PROPERTIES
12611257
VERSION ${qmf2_version}
12621258
SOVERSION ${qmf2_version_major})

src/qpid/store/CMakeLists.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ project(qpidc_store)
2121

2222
#set (CMAKE_VERBOSE_MAKEFILE ON) # for debugging
2323

24-
include_directories( ${Boost_INCLUDE_DIR} )
25-
2624
include_directories( ${CMAKE_CURRENT_SOURCE_DIR} )
2725
include_directories( ${CMAKE_HOME_DIRECTORY}/include )
2826

@@ -80,7 +78,7 @@ if (BUILD_MSSQL)
8078
ms-sql/State.cpp
8179
ms-sql/TplRecordset.cpp
8280
ms-sql/VariantHelper.cpp)
83-
target_link_libraries (mssql_store qpidbroker qpidcommon)
81+
target_link_libraries (mssql_store qpidbroker qpidcommon ${Boost_THREAD_LIBRARY})
8482
install (TARGETS mssql_store # RUNTIME
8583
DESTINATION ${QPIDD_MODULE_DIR}
8684
COMPONENT ${QPID_COMPONENT_BROKER})
@@ -109,7 +107,7 @@ if (BUILD_MSCLFS)
109107
ms-sql/State.cpp
110108
ms-sql/VariantHelper.cpp)
111109
include_directories(ms-sql)
112-
target_link_libraries (msclfs_store qpidbroker qpidcommon clfsw32.lib)
110+
target_link_libraries (msclfs_store qpidbroker qpidcommon clfsw32.lib ${Boost_THREAD_LIBRARY})
113111
install (TARGETS msclfs_store # RUNTIME
114112
DESTINATION ${QPIDD_MODULE_DIR}
115113
COMPONENT ${QPID_COMPONENT_BROKER})

src/tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ if (BUILD_TESTING_UNITTESTS)
161161

162162
# Like this to work with cmake 2.4 on Unix
163163
set(qpid_test_boost_libs
164-
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} ${Boost_SYSTEM_LIBRARY})
164+
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_THREAD_LIBRARY})
165165

166166
set(all_unit_tests
167167
AccumulatedAckTest

src/tests/legacystore/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ if (BUILD_TESTING_UNITTESTS)
3232

3333
# Like this to work with cmake 2.4 on Unix
3434
set (qpid_test_boost_libs
35-
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} ${Boost_SYSTEM_LIBRARY})
35+
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_THREAD_LIBRARY})
3636

3737
# Journal tests
3838
MACRO (define_journal_test mainSourceFile)

0 commit comments

Comments
 (0)