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

Convert to drone-ci #36

Draft
wants to merge 4 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
194 changes: 194 additions & 0 deletions .drone.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
local default_deps_base = [
'libgmp-dev',
'libsecp256k1-dev',
'nlohmann-json3-dev',
'libcurl4-openssl-dev',
];

local default_deps = ['g++'] + default_deps_base;
local docker_base = 'registry.oxen.rocks/';

local submodule_commands = [
'git fetch --tags',
'git submodule update --init --recursive --depth=1 --jobs=4',
];
local submodules = {
name: 'submodules',
image: 'drone/git',
commands: submodule_commands,
};

local apt_get_quiet = 'apt-get -o=Dpkg::Use-Pty=0 -q';

local kitware_repo(distro) = [
'eatmydata ' + apt_get_quiet + ' install -y curl ca-certificates',
'curl -sSL https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - >/usr/share/keyrings/kitware-archive-keyring.gpg',
'echo "deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ ' + distro + ' main" >/etc/apt/sources.list.d/kitware.list',
'eatmydata ' + apt_get_quiet + ' update',
];

local debian_backports(distro, pkgs) = [
'echo deb http://deb.debian.org/debian ' + distro + '-backports main >>/etc/apt/sources.list.d/backports.list',
'eatmydata ' + apt_get_quiet + ' update',
'eatmydata ' + apt_get_quiet + ' install -y ' + std.join(' ', std.map(function(p) p + '/' + distro + '-backports', pkgs)),
];

local generic_build(jobs, build_type, lto, werror, cmake_extra, build_tests, run_tests)
= [
'mkdir build',
'cd build',
'cmake .. -DCMAKE_COLOR_DIAGNOSTICS=ON -DCMAKE_BUILD_TYPE=' + build_type + ' ' +
'-Dethyl_WARNINGS_AS_ERRORS=' + (if werror then 'ON ' else 'OFF ') +
'-Dethyl_ENABLE_LTO=' + (if lto then 'ON ' else 'OFF ') +
'-Dethyl_ENABLE_UNIT_TESTING=' + (if build_tests then 'ON ' else 'OFF ') +
cmake_extra,
'make -j' + jobs + ' VERBOSE=1',
'cd ..',
]
+ (if run_tests then [
'cd build/test',
'./basic_tests --success --colour-mode ansi',
'./ethereum_client_tests --success --colour-mode ansi',
'cd ..',
] else []);

local anvil() = {
name: 'anvil',
image: 'ghcr.io/foundry-rs/foundry:latest',
pull: 'always',
commands: ['anvil --host 0.0.0.0'],
};


// Regular build on a debian-like system:
local debian_pipeline(name,
image,
arch='amd64',
deps=default_deps,
extra_setup=[],
build_type='Release',
lto=false,
werror=true,
cmake_extra='',
extra_cmds=[],
jobs=6,
build_tests=true,
run_tests=true,
allow_fail=false) = {
kind: 'pipeline',
type: 'docker',
name: name,
platform: { arch: arch },
services: (if run_tests then [anvil()] else []),
steps: [
submodules,
{
name: 'build',
image: image,
pull: 'always',
[if allow_fail then 'failure']: 'ignore',
environment: { SSH_KEY: { from_secret: 'SSH_KEY' }, ETH_RPC: 'anvil:8545' },
commands: [
'echo "Building on ${DRONE_STAGE_MACHINE}"',
'echo "man-db man-db/auto-update boolean false" | debconf-set-selections',
apt_get_quiet + ' update',
apt_get_quiet + ' install -y eatmydata',
] + extra_setup
+ [
'eatmydata ' + apt_get_quiet + ' dist-upgrade -y',
'eatmydata ' + apt_get_quiet + ' install --no-install-recommends -y cmake pkg-config ccache ' + std.join(' ', deps),
]
+ generic_build(jobs, build_type, lto, werror, cmake_extra, build_tests, run_tests)
+ extra_cmds,
},
],
};

local clang(version) = debian_pipeline(
'Debian sid/clang-' + version,
docker_base + 'debian-sid-clang',
deps=['clang-' + version] + default_deps_base,
cmake_extra='-DCMAKE_C_COMPILER=clang-' + version + ' -DCMAKE_CXX_COMPILER=clang++-' + version + ' '
);

local full_llvm(version) = debian_pipeline(
'Debian sid/llvm-' + version,
docker_base + 'debian-sid-clang',
deps=['clang-' + version, ' lld-' + version, ' libc++-' + version + '-dev', 'libc++abi-' + version + '-dev']
+ default_deps_base,
cmake_extra='-DCMAKE_C_COMPILER=clang-' + version +
' -DCMAKE_CXX_COMPILER=clang++-' + version +
' -DCMAKE_CXX_FLAGS=-stdlib=libc++ ' +
std.join(' ', [
'-DCMAKE_' + type + '_LINKER_FLAGS=-fuse-ld=lld-' + version
for type in ['EXE', 'MODULE', 'SHARED']
]) +
' -DOXEN_LOGGING_FORCE_SUBMODULES=ON'
);

// Macos build
local mac_builder(name,
build_type='Release',
arch='amd64',
werror=true,
lto=true,
cmake_extra='',
extra_cmds=[],
jobs=6,
build_tests=true,
run_tests=false,
allow_fail=false) = {
kind: 'pipeline',
type: 'exec',
name: name,
platform: { os: 'darwin', arch: arch },
steps: [
{ name: 'submodules', commands: submodule_commands },
{
name: 'build',
environment: { SSH_KEY: { from_secret: 'SSH_KEY' } },
commands: [
'echo "Building on ${DRONE_STAGE_MACHINE}"',
// If you don't do this then the C compiler doesn't have an include path containing
// basic system headers. WTF apple:
'export SDKROOT="$(xcrun --sdk macosx --show-sdk-path)"',
]
+ generic_build(jobs, build_type, lto, werror, cmake_extra, build_tests, run_tests)
+ extra_cmds,
},
],
};


[
// Various debian builds
debian_pipeline('Debian sid', docker_base + 'debian-sid'),
debian_pipeline('Debian sid/Debug', docker_base + 'debian-sid', build_type='Debug'),
clang(19),
// Not currently working because llvm-19 doesn't support char_traits<std::byte> or
// char_traits<unsigned char>, but oxenc expects them to exist:
//full_llvm(19),
full_llvm(18),
clang(16),
full_llvm(16),
debian_pipeline('Debian testing (i386)', docker_base + 'debian-testing/i386'),
debian_pipeline('Debian 12 bookworm', docker_base + 'debian-bookworm'),
debian_pipeline('Debian 11 bullseye', docker_base + 'debian-bullseye', extra_setup=debian_backports('bullseye', ['cmake'])),
debian_pipeline('Ubuntu latest', docker_base + 'ubuntu-rolling'),
debian_pipeline('Ubuntu 24.04 noble', docker_base + 'ubuntu-noble'),
debian_pipeline('Ubuntu 22.04 jammy', docker_base + 'ubuntu-jammy', werror=false),
debian_pipeline('Ubuntu 20.04 focal', docker_base + 'ubuntu-focal', deps=['g++-10'] + default_deps, extra_setup=kitware_repo('focal'), cmake_extra='-DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10'),

// ARM builds (ARM64 and armhf)
// run_tests=off on these for now because there isn't an arm64 foundry docker image yet (see
// https://github.com/foundry-rs/foundry/discussions/7278)
debian_pipeline('Debian sid (ARM64)', docker_base + 'debian-sid', arch='arm64', jobs=4, run_tests=false),
debian_pipeline('Debian stable/Debug (ARM64)', docker_base + 'debian-stable', arch='arm64', jobs=4, build_type='Debug', run_tests=false),
debian_pipeline('Debian stable (armhf)', docker_base + 'debian-stable/arm32v7', arch='arm64', jobs=4, run_tests=false),

// Macos builds:
mac_builder('macOS (Release, ARM)', arch='arm64'),
mac_builder('macOS (Debug, ARM)', arch='arm64', build_type='Debug'),
mac_builder('macOS (Release, Intel)'),
mac_builder('macOS (Debug, Intel)', build_type='Debug'),
]
49 changes: 0 additions & 49 deletions .github/workflows/ci.yml

This file was deleted.

12 changes: 7 additions & 5 deletions cmake/CompilerWarnings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@ function(set_project_warnings project_name)
# (ie printf)
)

if (${PROJECT_NAME}_WARNINGS_AS_ERRORS)
set(CLANG_WARNINGS ${CLANG_WARNINGS} -Werror)
set(MSVC_WARNINGS ${MSVC_WARNINGS} /WX)
endif()

set(GCC_WARNINGS
${CLANG_WARNINGS}
-Wmisleading-indentation # warn if indentation implies blocks where blocks
Expand All @@ -74,6 +69,13 @@ function(set_project_warnings project_name)
-Wuseless-cast # warn if you perform a cast to the same type
)

if (${PROJECT_NAME}_WARNINGS_AS_ERRORS)
set(CLANG_WARNINGS ${CLANG_WARNINGS} -Werror)
set(MSVC_WARNINGS ${MSVC_WARNINGS} /WX)
set(GCC_WARNINGS ${GCC_WARNINGS} -Werror -Wno-error=maybe-uninitialized)
endif()


if(MSVC)
set(PROJECT_WARNINGS ${MSVC_WARNINGS})
elseif(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")
Expand Down
12 changes: 0 additions & 12 deletions cmake/rlpvalue-001-infint-missing-limits-h.patch

This file was deleted.

3 changes: 2 additions & 1 deletion src/provider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
#include <chrono>
#include <thread>

#include <cpr/cpr.h>
#pragma GCC diagnostic push
#ifndef __clang__
#pragma GCC diagnostic ignored "-Wuseless-cast"
#pragma GCC diagnostic ignored "-Wconversion"
#endif
#include <nlohmann/json.hpp>
#include <cpr/cpr.h>
#pragma GCC diagnostic pop

#include <oxen/log.hpp>
Expand Down
6 changes: 3 additions & 3 deletions src/transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ std::vector<unsigned char> Transaction::serialize() const {

std::string serializedBytes = rlp_serialize(arr);
std::vector<unsigned char> result;
result.reserve(1 /*header*/ + serializedBytes.size());
result.push_back(0x02);
result.insert(result.end(), serializedBytes.begin(), serializedBytes.end());
result.resize(1 /*header*/ + serializedBytes.size());
result[0] = 0x02;
std::memcpy(result.data() + 1, serializedBytes.data(), serializedBytes.size());
return result;
}

Expand Down
11 changes: 0 additions & 11 deletions test/src/basic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,6 @@ unsigned int Factorial( unsigned int number ) {

int add(int a, int b) { return a + b; }

int64_t request() {
cpr::Response r = cpr::Get(cpr::Url{"https://api.github.com/repos/whoshuu/cpr/contributors"},
cpr::Authentication{"user", "pass", cpr::AuthMode::BASIC},
cpr::Parameters{{"anon", "true"}, {"key", "value"}});
return r.status_code;
}

int ecdsa() {
/* Instead of signing the message directly, we must sign a 32-byte hash.
* Here the message is "Hello, world!" and the hash function was SHA-256.
Expand Down Expand Up @@ -165,10 +158,6 @@ TEST_CASE( "Add", "[basic]" ) {
REQUIRE( add(1,2) == 3 );
}

TEST_CASE( "Request", "[basic]" ) {
REQUIRE( request() == 200 );
}

TEST_CASE( "ECDSA", "[basic]" ) {
REQUIRE( ecdsa() == 0 );
}
Expand Down
16 changes: 12 additions & 4 deletions test/src/ethereum_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,17 @@ inline constexpr std::string_view ANVIL_ADDRESS = "0xf39Fd6e51aad88F6F4ce6aB8827
inline constexpr auto ANVIL_PRIVATE_KEY = "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"_hex_u;
Signer signer;

std::string ethRPC() {
static auto* eth_rpc = std::getenv("ETH_RPC");
if (eth_rpc && strlen(eth_rpc))
return eth_rpc;
return "127.0.0.1:8545"s;
}

int main(int argc, char *argv[]) {
signer.provider->addClient("Client", "127.0.0.1:8545");
std::cout << "Note to run these tests, ensure that a local Ethereum development network is running at 127.0.0.1:8545" << "\n";
auto rpc = ethRPC();
signer.provider->addClient("Client", rpc);
std::cout << "Note to run these tests, ensure that a local Ethereum development network is running at " << rpc << "\n";
int result = Catch::Session().run(argc, argv);
return result;
}
Expand Down Expand Up @@ -121,7 +129,7 @@ TEST_CASE( "Does a self transfer on network using signer to populate", "[transac
TEST_CASE("Test multiple clients", "[provider]") {
auto provider = Provider::make_provider();
provider->setTimeout(std::chrono::milliseconds(1000));
provider->addClient("Client", "127.0.0.1:8545");
provider->addClient("Bad Client", "127.0.0.1:8546"); // Add non-existent client
provider->addClient("Client", ethRPC());
provider->addClient("Bad Client", "127.3.4.5:12345"); // Add non-existent client
CHECK(provider->connectToNetwork());
}