Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test environment (using vcpkg) #234

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 0 additions & 88 deletions .github/workflows/ci-linux.yaml

This file was deleted.

50 changes: 0 additions & 50 deletions .github/workflows/ci-windows.yaml

This file was deleted.

94 changes: 94 additions & 0 deletions .github/workflows/hosted-pure-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Copyright (c) 2021 Luca Cappa
# Released under the term specified in file LICENSE.txt
# SPDX short identifier: MIT

# A "pure" GitHub workflow using CMake, Ninja and vcpkg to build a C/C++ codebase.
# It leverages both CMakePresets.json and vcpkg.json to have consistent build locallly
# and on continuous integration servers (aka build agents).
# It is called "pure workflow" because it is an example which minimizes the usage of
# custom GitHub actions, but leverages directly the tools that could be easily run on
# your development machines (i.e. CMake, vcpkg, Ninja) to ensure a perfectly identical
# and reproducible build locally (on your development machine) and remotely (on build agents).
name: hosted-pure-workflow
on: [ push, workflow_dispatch ]

jobs:
job:
name: ${{ matrix.os }}-${{ github.workflow }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
include:
- os: windows-latest
triplet: x64-windows
- os: ubuntu-latest
triplet: x64-linux
- os: macos-latest
triplet: x64-osx
env:
# Indicates the location of the vcpkg as a Git submodule of the project repository.
VCPKG_ROOT: ${{ github.workspace }}/vcpkg
# Tells vcpkg where binary packages are stored.
VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}/vcpkg/bincache

steps:
- uses: actions/checkout@v2
with:
submodules: true

- name: "Create directory '${{ env.VCPKG_DEFAULT_BINARY_CACHE }}'"
run: mkdir -p $VCPKG_DEFAULT_BINARY_CACHE
shell: bash

# Setup the build machine with the most recent versions of CMake and Ninja. Both are cached if not already: on subsequent runs both will be quickly restored from GitHub cache service.
- uses: lukka/get-cmake@latest

- uses: docker-practice/actions-setup-docker@master
- run: |
if [ "$RUNNER_OS" != "Windows" ]; then
docker pull crossbario/crossbar
else
echo "Skipping on Windows."
fi
shell: bash
# Restore both vcpkg and its artifacts from the GitHub cache service.
- name: Restore Dependency Cache.
uses: actions/cache@v2
with:
# The first path is the location of vcpkg: it contains the vcpkg executable and data files, as long as the
# built package archives (aka binary cache) which are located by VCPKG_DEFAULT_BINARY_CACHE env var.
# The other paths starting with '!' are exclusions: they contain termporary files generated during the build of the installed packages.
path: |
${{ env.VCPKG_ROOT }}
!${{ env.VCPKG_ROOT }}/buildtrees
!${{ env.VCPKG_ROOT }}/packages
!${{ env.VCPKG_ROOT }}/downloads
!${{ env.VCPKG_ROOT }}/installed
# The key is composed in a way that it gets properly invalidated: this must happen whenever vcpkg's Git commit id changes, or the list of packages changes. In this case a cache miss must happen and a new entry with a new key with be pushed to GitHub the cache service.
# The key includes: hash of the vcpkg.json file, the hash of the vcpkg Git commit id, and the used vcpkg's triplet. The vcpkg's commit id would suffice, but computing an hash out it does not harm.
# Note: given a key, the cache content is immutable. If a cache entry has been created improperly, in order the recreate the right content the key must be changed as well, and it must be brand new (i.e. not existing already).
key: |
${{ hashFiles( 'vcpkg.json' ) }}-${{ hashFiles( '.git/modules/vcpkg/HEAD' )}}-${{ matrix.triplet }}
# On Windows runners, let's ensure to have the Developer Command Prompt environment setup correctly. As used here the Developer Command Prompt created is targeting x64 and using the default the Windows SDK.
- uses: ilammy/msvc-dev-cmd@v1

# Run CMake to generate Ninja project files, using the vcpkg's toolchain file to resolve and install the dependencies as specified in vcpkg.json.
- name: Install Dependencies.
run: |
cmake --preset ninja-multi-vcpkg

# Build the whole project with Ninja (which is spawn by CMake). Debug configuration.
- name: Build.
run: |
cmake --build --preset ninja-multi-vcpkg-debug
# Test the whole project with CTest.
- name: Run Tests.
run: |
if [ "$RUNNER_OS" != "Windows" ]; then
ctest --preset ninja-multi-vcpkg-debug
else
echo "Skipping on Windows."
fi
shell: bash
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "vcpkg"]
path = vcpkg
url = https://github.com/microsoft/vcpkg
25 changes: 19 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.21)

set(vcpkg "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")
if (NOT CMAKE_TOOLCHAIN_FILE AND EXISTS "${vcpkg}")
set(CMAKE_TOOLCHAIN_FILE "${vcpkg}"
CACHE FILEPATH "CMake toolchain file")
message(STATUS "vcpkg toolchain found: ${CMAKE_TOOLCHAIN_FILE}")
endif ()

project(autobahn-cpp)

set(CMAKE_CXX_STANDARD 20)

option(AUTOBAHN_BUILD_EXAMPLES "Build examples" ON)
option(AUTOBAHN_BUILD_EXAMPLES_BOTAN "Build Botan cryptosign example" OFF)
option(AUTOBAHN_USE_LIBCXX "Use libc++ instead of libstdc++ when building with Clang" ON)
option(AUTOBAHN_TESTS "Test" ON)

include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Includes/CMakeLists.txt)

if(AUTOBAHN_BUILD_EXAMPLES)
if (AUTOBAHN_BUILD_EXAMPLES)
add_subdirectory(examples)
endif(AUTOBAHN_BUILD_EXAMPLES)
endif (AUTOBAHN_BUILD_EXAMPLES)

if (AUTOBAHN_TESTS)
include(CTest)
add_subdirectory(test)
endif()

51 changes: 51 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"version": 3,
"cmakeMinimumRequired": {
"major": 3,
"minor": 21,
"patch": 0
},
"configurePresets": [
{
"name": "ninja-multi-vcpkg",
"displayName": "Ninja Multi-Config",
"description": "Configure with vcpkg toolchain and generate Ninja project files for all configurations",
"binaryDir": "${sourceDir}/builds/${presetName}",
"generator": "Ninja Multi-Config",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": {
"type": "FILEPATH",
"value": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
}
}
}
],
"buildPresets": [
{
"name": "ninja-multi-vcpkg-debug",
"configurePreset": "ninja-multi-vcpkg",
"displayName": "Build ninja-multi-vcpkg-debug",
"description": "Build ninja-multi-vcpkg Debug configuration",
"configuration": "Debug"
},
{
"name": "ninja-multi-vcpkg-release",
"configurePreset": "ninja-multi-vcpkg",
"displayName": "Build ninja-multi-vcpkg-release",
"description": "Build ninja-multi-vcpkg Release configuration",
"configuration": "RelWithDebInfo"
}
],
"testPresets": [
{
"name": "ninja-multi-vcpkg-debug",
"configurePreset": "ninja-multi-vcpkg",
"configuration": "Debug"
},
{
"name": "ninja-multi-vcpkg-release",
"configurePreset": "ninja-multi-vcpkg",
"configuration": "RelWithDebInfo"
}
]
}
8 changes: 1 addition & 7 deletions autobahn/wamp_auth_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,7 @@ inline std::string compute_wcs(
HMAC_Final(&hmac, hash, &len);
HMAC_CTX_cleanup(&hmac);
#else
HMAC_CTX *hmac = HMAC_CTX_new();
if (!hmac)
return "";
HMAC_Init_ex(hmac, key.data(), (int) key.length(), EVP_sha256(), NULL);
HMAC_Update(hmac, ( unsigned char* ) challenge.data(), challenge.length());
HMAC_Final(hmac, hash, &len);
HMAC_CTX_free(hmac);
HMAC(EVP_sha256(), key.data(), static_cast<int>(key.length()), reinterpret_cast<const unsigned char *>(challenge.data()), challenge.length(), hash, &len);
#endif

std::string str_out;
Expand Down
Loading