mirror of
https://github.com/status-im/nim-raft.git
synced 2025-02-25 19:35:12 +00:00
Test CI
This commit is contained in:
parent
3e48216d93
commit
f5efc25161
109
config.nim
Normal file
109
config.nim
Normal file
@ -0,0 +1,109 @@
|
||||
# Set up paths
|
||||
--noNimblePath
|
||||
when withDir(thisDir(), system.fileExists("nimble.paths")):
|
||||
include "nimble.paths"
|
||||
|
||||
--path:"src"
|
||||
|
||||
# Turn off `libbacktrace`
|
||||
--define:disable_libbacktrace
|
||||
|
||||
# Configuration synced with nwaku's - https://github.com/waku-org/nwaku/blob/master/config.nims
|
||||
# ---------------------------------------------------- nwaku config ----------------------------------------------------
|
||||
if defined(release):
|
||||
switch("nimcache", thisDir() & "/nimcache/release/$projectName")
|
||||
else:
|
||||
switch("nimcache", thisDir() & "/nimcache/debug/$projectName")
|
||||
|
||||
if defined(windows):
|
||||
# disable timestamps in Windows PE headers - https://wiki.debian.org/ReproducibleBuilds/TimestampsInPEBinaries
|
||||
switch("passL", "-Wl,--no-insert-timestamp")
|
||||
# increase stack size
|
||||
switch("passL", "-Wl,--stack,8388608")
|
||||
# https://github.com/nim-lang/Nim/issues/4057
|
||||
--tlsEmulation:off
|
||||
if defined(i386):
|
||||
# set the IMAGE_FILE_LARGE_ADDRESS_AWARE flag so we can use PAE, if enabled, and access more than 2 GiB of RAM
|
||||
switch("passL", "-Wl,--large-address-aware")
|
||||
|
||||
# The dynamic Chronicles output currently prevents us from using colors on Windows
|
||||
# because these require direct manipulations of the stdout File object.
|
||||
switch("define", "chronicles_colors=off")
|
||||
|
||||
# https://github.com/status-im/nimbus-eth2/blob/stable/docs/cpu_features.md#ssse3-supplemental-sse3
|
||||
# suggests that SHA256 hashing with SSSE3 is 20% faster than without SSSE3, so
|
||||
# given its near-ubiquity in the x86 installed base, it renders a distribution
|
||||
# build more viable on an overall broader range of hardware.
|
||||
#
|
||||
if defined(disableMarchNative):
|
||||
if defined(i386) or defined(amd64):
|
||||
if defined(macosx):
|
||||
# macOS Catalina is EOL as of 2022-09
|
||||
# https://support.apple.com/kb/sp833
|
||||
# "macOS Big Sur - Technical Specifications" lists current oldest
|
||||
# supported models: MacBook (2015 or later), MacBook Air (2013 or later),
|
||||
# MacBook Pro (Late 2013 or later), Mac mini (2014 or later), iMac (2014
|
||||
# or later), iMac Pro (2017 or later), Mac Pro (2013 or later).
|
||||
#
|
||||
# These all have Haswell or newer CPUs.
|
||||
#
|
||||
# This ensures AVX2, AES-NI, PCLMUL, BMI1, and BMI2 instruction set support.
|
||||
switch("passC", "-march=haswell -mtune=generic")
|
||||
switch("passL", "-march=haswell -mtune=generic")
|
||||
else:
|
||||
if defined(marchOptimized):
|
||||
# https://github.com/status-im/nimbus-eth2/blob/stable/docs/cpu_features.md#bmi2--adx
|
||||
switch("passC", "-march=broadwell -mtune=generic")
|
||||
switch("passL", "-march=broadwell -mtune=generic")
|
||||
else:
|
||||
switch("passC", "-mssse3")
|
||||
switch("passL", "-mssse3")
|
||||
elif defined(macosx) and defined(arm64):
|
||||
# Apple's Clang can't handle "-march=native" on M1: https://github.com/status-im/nimbus-eth2/issues/2758
|
||||
switch("passC", "-mcpu=apple-m1")
|
||||
switch("passL", "-mcpu=apple-m1")
|
||||
else:
|
||||
switch("passC", "-march=native")
|
||||
switch("passL", "-march=native")
|
||||
if defined(windows):
|
||||
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65782
|
||||
# ("-fno-asynchronous-unwind-tables" breaks Nim's exception raising, sometimes)
|
||||
switch("passC", "-mno-avx512f")
|
||||
switch("passL", "-mno-avx512f")
|
||||
|
||||
|
||||
--threads:on
|
||||
--opt:speed
|
||||
--excessiveStackTrace:on
|
||||
# enable metric collection
|
||||
--define:metrics
|
||||
# for heap-usage-by-instance-type metrics and object base-type strings
|
||||
--define:nimTypeNames
|
||||
|
||||
switch("define", "withoutPCRE")
|
||||
|
||||
# the default open files limit is too low on macOS (512), breaking the
|
||||
# "--debugger:native" build. It can be increased with `ulimit -n 1024`.
|
||||
if not defined(macosx):
|
||||
# add debugging symbols and original files and line numbers
|
||||
--debugger:native
|
||||
--define:nimOldCaseObjects # https://github.com/status-im/nim-confutils/issues/9
|
||||
|
||||
# `switch("warning[CaseTransition]", "off")` fails with "Error: invalid command line option: '--warning[CaseTransition]'"
|
||||
switch("warning", "CaseTransition:off")
|
||||
|
||||
# The compiler doth protest too much, methinks, about all these cases where it can't
|
||||
# do its (N)RVO pass: https://github.com/nim-lang/RFCs/issues/230
|
||||
switch("warning", "ObservableStores:off")
|
||||
|
||||
# Too many false positives for "Warning: method has lock level <unknown>, but another method has 0 [LockLevel]"
|
||||
switch("warning", "LockLevel:off")
|
||||
# ----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
# Discovery configuration
|
||||
switch("define", "discv5_protocol_id=d5waku")
|
||||
|
||||
# Logging configuration
|
||||
--define:chronicles_line_numbers
|
||||
switch("define", "chronicles_log_level=DEBUG")
|
||||
switch("define", "chronicles_runtime_filtering=on")
|
@ -14,7 +14,11 @@ version = "0.0.1"
|
||||
author = "Status Research & Development GmbH"
|
||||
description = "raft consensus in nim"
|
||||
license = "Apache License 2.0"
|
||||
srcDir = "src"
|
||||
installExt = @["nim"]
|
||||
skipDirs = @["tests"]
|
||||
bin = @["raft"]
|
||||
|
||||
|
||||
requires "nim >= 1.6.14"
|
||||
requires "stew >= 0.1.0"
|
||||
@ -26,6 +30,4 @@ requires "chronos >= 3.0.11"
|
||||
requires "nimdbx >= 0.4.1"
|
||||
requires "nimterop >= 0.6.13"
|
||||
|
||||
task test, "Run tests":
|
||||
exec "nim c -r tests/test_consensus_state_machine.nim "
|
||||
|
||||
|
18
raft.nims
Normal file
18
raft.nims
Normal file
@ -0,0 +1,18 @@
|
||||
proc buildLibrary(name: string, srcDir = "./", params = "", `type` = "static") =
|
||||
if not dirExists "build":
|
||||
mkDir "build"
|
||||
# allow something like "nim nimbus --verbosity:0 --hints:off nimbus.nims"
|
||||
var extra_params = params
|
||||
for i in 2..<paramCount():
|
||||
extra_params &= " " & paramStr(i)
|
||||
if `type` == "static":
|
||||
exec "nim c" & " --out:build/" & name & ".a --threads:on --app:staticlib --opt:size --noMain --header " & extra_params & " " & srcDir & name & ".nim"
|
||||
else:
|
||||
exec "nim c" & " --out:build/" & name & ".so --threads:on --app:lib --opt:size --noMain --header " & extra_params & " " & srcDir & name & ".nim"
|
||||
|
||||
|
||||
task build, "Build static lib":
|
||||
buildLibrary "nim-raft", "src/raft/"
|
||||
|
||||
task test, "Run tests":
|
||||
exec "nim c -r tests/test_consensus_state_machine.nim "
|
@ -8,11 +8,11 @@
|
||||
# those terms.
|
||||
|
||||
import unittest2
|
||||
import ../raft/types
|
||||
import ../raft/consensus_state_machine
|
||||
import ../raft/log
|
||||
import ../raft/tracker
|
||||
import ../raft/state
|
||||
import ../src/raft/types
|
||||
import ../src/raft/consensus_state_machine
|
||||
import ../src/raft/log
|
||||
import ../src/raft/tracker
|
||||
import ../src/raft/state
|
||||
import std/[times, sequtils]
|
||||
import uuids
|
||||
import tables
|
||||
|
Loading…
x
Reference in New Issue
Block a user