Skip to content

Commit 641098d

Browse files
committed
Adapt workflow for conan.
1 parent 3e37056 commit 641098d

File tree

6 files changed

+183
-230
lines changed

6 files changed

+183
-230
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: build-and-test
2+
on: [ push, workflow_dispatch ]
3+
4+
jobs:
5+
job:
6+
name: ${{ matrix.os }}-${{ github.workflow }}
7+
runs-on: ${{ matrix.os }}
8+
strategy:
9+
fail-fast: false
10+
matrix:
11+
os: [ ubuntu-latest, macos-latest, windows-latest ]
12+
include:
13+
- os: windows-latest
14+
triplet: x64-windows
15+
- os: ubuntu-latest
16+
triplet: x64-linux
17+
- os: macos-latest
18+
triplet: x64-osx
19+
20+
steps:
21+
- uses: actions/checkout@v2
22+
with:
23+
submodules: true
24+
25+
- uses: actions/setup-python@v2
26+
with:
27+
python-version: '3.x' # Version range or exact version of a Python version to use, using SemVer's version range syntax
28+
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
29+
30+
- name: Prepare Docker.
31+
uses: docker-practice/actions-setup-docker@master
32+
33+
- name: Prepare Tools.
34+
run: |
35+
pip install conan
36+
if [ "$RUNNER_OS" != "Windows" ]; then
37+
docker pull crossbario/crossbar
38+
else
39+
echo "Skipping on Windows."
40+
fi
41+
shell: bash
42+
43+
- name: Restore Dependency Cache.
44+
uses: actions/cache@v2
45+
with:
46+
path: |
47+
/home/runner/.conan/data
48+
# 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.
49+
# 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.
50+
# 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).
51+
key: |
52+
${{ hashFiles( 'conanfile.py' ) }}-${{ matrix.triplet }}
53+
54+
# Run CMake to generate Ninja project files, using the vcpkg's toolchain file to resolve and install the dependencies as specified in vcpkg.json.
55+
- name: Build and Test.
56+
run: |
57+
mkdir build
58+
cd build
59+
cmake .. -DCMAKE_BUILD_TYPE=Release
60+
make
61+
if [ "$RUNNER_OS" != "Windows" ]; then
62+
ctest
63+
fi
64+
shell: bash

.github/workflows/hosted-pure-workflow.yml

Lines changed: 0 additions & 94 deletions
This file was deleted.

conanfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from conans import ConanFile, CMake, tools
22

3+
34
class autobahn_cppConan(ConanFile):
45
name = "autobahn-cpp"
56
version = "v20.8.1"
@@ -23,4 +24,3 @@ def package(self):
2324

2425
def package_id(self):
2526
self.info.header_only()
26-

test/auth/auth.cpp

Lines changed: 78 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -31,100 +31,88 @@
3131
#include "test/wamp_test.hpp"
3232
#include <catch2/catch.hpp>
3333

34-
struct Config
35-
{
36-
std::string realm{"realm1"};
37-
std::string uri{"ws://127.0.0.1:8080/ws"};
38-
bool debug{false};
34+
struct Config {
35+
std::string realm{"realm1"};
36+
std::string uri{"ws://127.0.0.1:8080/ws"};
37+
bool debug{false};
3938
};
4039

41-
TEST_CASE_METHOD(wamp_test::fixture<Config>, "wamp.auth.cra")
42-
{
43-
bool joined_realm_with_success = join_realm(
44-
"client1_cra",
45-
wamp_test::Secret("client1_secret"),
46-
[&](Transport& transport, Session& session)
47-
{
48-
auto welcome_details = session.welcome_details();
49-
REQUIRE(welcome_details["authprovider"].as<std::string>() == "static");
50-
REQUIRE(welcome_details["realm"].as<std::string>() == "realm1");
51-
REQUIRE(welcome_details["authid"].as<std::string>() == "client1_cra");
52-
REQUIRE(welcome_details["authrole"].as<std::string>() == "frontend");
53-
});
54-
REQUIRE(true == joined_realm_with_success);
55-
joined_realm_with_success = join_realm(
56-
"client2_cra",
57-
wamp_test::Secret("client2_secret"),
58-
[&](Transport& transport, Session& session)
59-
{
60-
auto welcome_details = session.welcome_details();
61-
REQUIRE(welcome_details["authprovider"].as<std::string>() == "static");
62-
REQUIRE(welcome_details["realm"].as<std::string>() == "realm1");
63-
REQUIRE(welcome_details["authid"].as<std::string>() == "client2_cra");
64-
REQUIRE(welcome_details["authrole"].as<std::string>() == "backend");
65-
});
66-
REQUIRE(true == joined_realm_with_success);
67-
REQUIRE(false == join_realm("client3", wamp_test::Secret("unknown")));
40+
TEST_CASE_METHOD(wamp_test::fixture<Config>, "wamp.auth.cra") {
41+
bool joined_realm_with_success = join_realm(
42+
"client1_cra", wamp_test::Secret("client1_secret"),
43+
[&](Transport &transport, Session &session) {
44+
auto welcome_details = session.welcome_details();
45+
REQUIRE(welcome_details["authprovider"].as<std::string>() == "static");
46+
REQUIRE(welcome_details["realm"].as<std::string>() == "realm1");
47+
REQUIRE(welcome_details["authid"].as<std::string>() == "client1_cra");
48+
REQUIRE(welcome_details["authrole"].as<std::string>() == "frontend");
49+
});
50+
REQUIRE(true == joined_realm_with_success);
51+
joined_realm_with_success = join_realm(
52+
"client2_cra", wamp_test::Secret("client2_secret"),
53+
[&](Transport &transport, Session &session) {
54+
auto welcome_details = session.welcome_details();
55+
REQUIRE(welcome_details["authprovider"].as<std::string>() == "static");
56+
REQUIRE(welcome_details["realm"].as<std::string>() == "realm1");
57+
REQUIRE(welcome_details["authid"].as<std::string>() == "client2_cra");
58+
REQUIRE(welcome_details["authrole"].as<std::string>() == "backend");
59+
});
60+
REQUIRE(true == joined_realm_with_success);
61+
REQUIRE(false == join_realm("client3", wamp_test::Secret("unknown")));
6862
}
6963

70-
TEST_CASE_METHOD(wamp_test::fixture<Config>, "wamp.auth.ticket")
71-
{
72-
bool joined_realm_with_success = join_realm(
73-
"client1",
74-
wamp_test::Ticket("client1_ticket"),
75-
[&](Transport& transport, Session& session)
76-
{
77-
auto welcome_details = session.welcome_details();
78-
REQUIRE(welcome_details["authprovider"].as<std::string>() == "static");
79-
REQUIRE(welcome_details["realm"].as<std::string>() == "realm1");
80-
REQUIRE(welcome_details["authid"].as<std::string>() == "client1");
81-
REQUIRE(welcome_details["authrole"].as<std::string>() == "frontend");
82-
});
83-
REQUIRE(true == joined_realm_with_success);
84-
joined_realm_with_success = join_realm(
85-
"client2",
86-
wamp_test::Ticket("client2_ticket"),
87-
[&](Transport& transport, Session& session)
88-
{
89-
auto welcome_details = session.welcome_details();
90-
REQUIRE(welcome_details["authprovider"].as<std::string>() == "static");
91-
REQUIRE(welcome_details["realm"].as<std::string>() == "realm1");
92-
REQUIRE(welcome_details["authid"].as<std::string>() == "client2");
93-
REQUIRE(welcome_details["authrole"].as<std::string>() == "backend");
94-
});
95-
REQUIRE(true == joined_realm_with_success);
96-
REQUIRE(false == join_realm("client3", wamp_test::Ticket("unknown")));
64+
TEST_CASE_METHOD(wamp_test::fixture<Config>, "wamp.auth.ticket") {
65+
bool joined_realm_with_success = join_realm(
66+
"client1", wamp_test::Ticket("client1_ticket"),
67+
[&](Transport &transport, Session &session) {
68+
auto welcome_details = session.welcome_details();
69+
REQUIRE(welcome_details["authprovider"].as<std::string>() == "static");
70+
REQUIRE(welcome_details["realm"].as<std::string>() == "realm1");
71+
REQUIRE(welcome_details["authid"].as<std::string>() == "client1");
72+
REQUIRE(welcome_details["authrole"].as<std::string>() == "frontend");
73+
});
74+
REQUIRE(true == joined_realm_with_success);
75+
joined_realm_with_success = join_realm(
76+
"client2", wamp_test::Ticket("client2_ticket"),
77+
[&](Transport &transport, Session &session) {
78+
auto welcome_details = session.welcome_details();
79+
REQUIRE(welcome_details["authprovider"].as<std::string>() == "static");
80+
REQUIRE(welcome_details["realm"].as<std::string>() == "realm1");
81+
REQUIRE(welcome_details["authid"].as<std::string>() == "client2");
82+
REQUIRE(welcome_details["authrole"].as<std::string>() == "backend");
83+
});
84+
REQUIRE(true == joined_realm_with_success);
85+
REQUIRE(false == join_realm("client3", wamp_test::Ticket("unknown")));
9786
}
9887

99-
TEST_CASE_METHOD(wamp_test::fixture<Config>, "wamp.auth.cryptosign")
100-
{
101-
bool joined_realm_with_success = join_realm(
102-
"3b6a27bcceb6a42d62a3a8d02a6f0d73653215771de243a63ac048a18b59da29",
103-
wamp_test::Cryptosign(Botan::secure_vector<uint8_t>(32, 0)),
104-
[&](Transport& transport, Session& session)
105-
{
106-
auto welcome_details = session.welcome_details();
107-
REQUIRE(welcome_details["authprovider"].as<std::string>() == "static");
108-
REQUIRE(welcome_details["realm"].as<std::string>() == "realm1");
109-
REQUIRE(
110-
welcome_details["authid"].as<std::string>()
111-
== "3b6a27bcceb6a42d62a3a8d02a6f0d73653215771de243a63ac048a18b59da29");
112-
REQUIRE(welcome_details["authrole"].as<std::string>() == "frontend");
113-
});
114-
REQUIRE(true == joined_realm_with_success);
115-
joined_realm_with_success = join_realm(
116-
"8a88e3dd7409f195fd52db2d3cba5d72ca6709bf1d94121bf3748801b40f6f5c",
117-
wamp_test::Cryptosign(Botan::secure_vector<uint8_t>(32, 1)),
118-
[&](Transport& transport, Session& session)
119-
{
120-
auto welcome_details = session.welcome_details();
121-
REQUIRE(welcome_details["authprovider"].as<std::string>() == "static");
122-
REQUIRE(welcome_details["realm"].as<std::string>() == "realm1");
123-
REQUIRE(
124-
welcome_details["authid"].as<std::string>()
125-
== "8a88e3dd7409f195fd52db2d3cba5d72ca6709bf1d94121bf3748801b40f6f5c");
126-
REQUIRE(welcome_details["authrole"].as<std::string>() == "backend");
127-
});
128-
REQUIRE(true == joined_realm_with_success);
129-
REQUIRE(false == join_realm("unknown", wamp_test::Cryptosign(Botan::secure_vector<uint8_t>(32, 3))));
88+
TEST_CASE_METHOD(wamp_test::fixture<Config>, "wamp.auth.cryptosign") {
89+
bool joined_realm_with_success = join_realm(
90+
"3b6a27bcceb6a42d62a3a8d02a6f0d73653215771de243a63ac048a18b59da29",
91+
wamp_test::Cryptosign(Botan::secure_vector<uint8_t>(32, 0)),
92+
[&](Transport &transport, Session &session) {
93+
auto welcome_details = session.welcome_details();
94+
REQUIRE(welcome_details["authprovider"].as<std::string>() == "static");
95+
REQUIRE(welcome_details["realm"].as<std::string>() == "realm1");
96+
REQUIRE(
97+
welcome_details["authid"].as<std::string>() ==
98+
"3b6a27bcceb6a42d62a3a8d02a6f0d73653215771de243a63ac048a18b59da29");
99+
REQUIRE(welcome_details["authrole"].as<std::string>() == "frontend");
100+
});
101+
REQUIRE(true == joined_realm_with_success);
102+
joined_realm_with_success = join_realm(
103+
"8a88e3dd7409f195fd52db2d3cba5d72ca6709bf1d94121bf3748801b40f6f5c",
104+
wamp_test::Cryptosign(Botan::secure_vector<uint8_t>(32, 1)),
105+
[&](Transport &transport, Session &session) {
106+
auto welcome_details = session.welcome_details();
107+
REQUIRE(welcome_details["authprovider"].as<std::string>() == "static");
108+
REQUIRE(welcome_details["realm"].as<std::string>() == "realm1");
109+
REQUIRE(
110+
welcome_details["authid"].as<std::string>() ==
111+
"8a88e3dd7409f195fd52db2d3cba5d72ca6709bf1d94121bf3748801b40f6f5c");
112+
REQUIRE(welcome_details["authrole"].as<std::string>() == "backend");
113+
});
114+
REQUIRE(true == joined_realm_with_success);
115+
REQUIRE(false ==
116+
join_realm("unknown", wamp_test::Cryptosign(
117+
Botan::secure_vector<uint8_t>(32, 3))));
130118
}

test/calls/calls.cpp

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,25 @@
3131
#include "test/wamp_test.hpp"
3232
#include <catch2/catch.hpp>
3333

34-
struct Config
35-
{
36-
std::string realm{"realm1"};
37-
std::string uri{"ws://127.0.0.1:8080/ws"};
38-
bool debug{false};
34+
struct Config {
35+
std::string realm{"realm1"};
36+
std::string uri{"ws://127.0.0.1:8080/ws"};
37+
bool debug{false};
3938
};
4039

41-
TEST_CASE_METHOD(wamp_test::fixture<Config>, "wamp.calls.simple")
42-
{
43-
bool joined_realm_with_success = join_realm(
44-
"client1",
45-
wamp_test::Ticket("ticket"),
46-
[&](Transport& transport, Session& session)
47-
{
48-
REQUIRE(3 == call<int>("com.example.add2", std::tuple<int, int>(1, 2)).get());
49-
REQUIRE(5 == call<int>("com.example.add2", std::tuple<int, int>(2, 3)).get());
50-
REQUIRE(!call<int>("com.example.unknown", std::tuple<int, int, int>(3, 4, 5)).has_value());
51-
});
52-
REQUIRE(true == joined_realm_with_success);
40+
TEST_CASE_METHOD(wamp_test::fixture<Config>, "wamp.calls.simple") {
41+
bool joined_realm_with_success = join_realm(
42+
"client1", wamp_test::Ticket("ticket"),
43+
[&](Transport &transport, Session &session) {
44+
REQUIRE(
45+
3 ==
46+
call<int>("com.example.add2", std::tuple<int, int>(1, 2)).get());
47+
REQUIRE(
48+
5 ==
49+
call<int>("com.example.add2", std::tuple<int, int>(2, 3)).get());
50+
REQUIRE(!call<int>("com.example.unknown",
51+
std::tuple<int, int, int>(3, 4, 5))
52+
.has_value());
53+
});
54+
REQUIRE(true == joined_realm_with_success);
5355
}

0 commit comments

Comments
 (0)