very simple reproducibility test

Additional changes:
- Makefile verbosity control
- nimble.sh can now run in parallel on the same *.nimble file
- nimble.sh no longer used in the Makefile, in favour of a nimbus.nims
  symlink that eliminates race risks in parallel jobs
- nimbus.nimble takes extra params in the command line, with the caveat
  that they also apply to nim
- setCommand() replaced with exec(), to avoid splitting param strings
This commit is contained in:
Ștefan Talpalaru 2019-02-16 22:23:17 +01:00 committed by zah
parent 944d489c19
commit da79a7e996
8 changed files with 44 additions and 22 deletions

View File

@ -25,11 +25,11 @@ build_script:
- git submodule update --init --recursive --depth 10 - git submodule update --init --recursive --depth 10
# the 32-bit build is done on a 64-bit image, so we need to override the architecture # the 32-bit build is done on a 64-bit image, so we need to override the architecture
- mingw32-make ARCH_OVERRIDE=%PLATFORM% fetch-dlls - mingw32-make ARCH_OVERRIDE=%PLATFORM% fetch-dlls
- mingw32-make -j2 ARCH_OVERRIDE=%PLATFORM% nimbus - mingw32-make -j2 ARCH_OVERRIDE=%PLATFORM% V=0 nimbus
test_script: test_script:
- build\nimbus.exe --help - build\nimbus.exe --help
- mingw32-make -j2 ARCH_OVERRIDE=%PLATFORM% test - mingw32-make -j2 ARCH_OVERRIDE=%PLATFORM% V=0 test test-reproducibility
deploy: off deploy: off

View File

@ -34,7 +34,7 @@ install:
script: script:
- set -e # fail fast - set -e # fail fast
- make -j${NPROC} nimbus - make -j${NPROC} V=0 nimbus
- ./build/nimbus --help - ./build/nimbus --help
- make -j${NPROC} test - make -j${NPROC} V=0 test test-reproducibility

View File

@ -66,6 +66,12 @@ BUILD_NIM := cd $(NIM_DIR) && \
} && \ } && \
sh build_all.sh sh build_all.sh
NIM_BINARY := $(NIM_DIR)/bin/nim$(EXE_SUFFIX) NIM_BINARY := $(NIM_DIR)/bin/nim$(EXE_SUFFIX)
# verbosity level
V := 1
NIM_PARAMS := --verbosity:$(V)
ifeq ($(V), 0)
NIM_PARAMS := $(NIM_PARAMS) --hints:off --warnings:off
endif
OpenSystemsLab/tempfile.nim \ OpenSystemsLab/tempfile.nim \
status-im/nim-eth \ status-im/nim-eth \
@ -77,12 +83,12 @@ all: premix persist debug dumper hunter nimbus
# debugging tools # debugging tools
premix persist debug dumper hunter: | build deps premix persist debug dumper hunter: | build deps
$(ENV_SCRIPT) nim c -o:build/$@ premix/$@.nim && \ $(ENV_SCRIPT) nim c $(NIM_PARAMS) -o:build/$@ premix/$@.nim && \
echo -e "\nThe binary is in './build/$@'.\n" echo -e "\nThe binary is in './build/$@'.\n"
#- a phony target, because teaching `make` how to do conditional recompilation of Nim projects is too complicated #- a phony target, because teaching `make` how to do conditional recompilation of Nim projects is too complicated
nimbus: | build deps nimbus: | build deps
./nimble.sh nimbus && \ $(ENV_SCRIPT) nim nimbus $(NIM_PARAMS) nimbus.nims && \
echo -e "\nThe binary is in './build/nimbus'.\n" echo -e "\nThe binary is in './build/nimbus'.\n"
# dir # dir
@ -108,7 +114,16 @@ $(NIMBLE_DIR): | $(NIM_BINARY)
# builds and runs all tests # builds and runs all tests
test: | build deps test: | build deps
./nimble.sh test $(ENV_SCRIPT) nim test $(NIM_PARAMS) nimbus.nims
# primitive reproducibility test
test-reproducibility:
+ [ -e build/nimbus ] || $(MAKE) V=0 nimbus; \
MD5SUM1=$$(md5sum build/nimbus | cut -d ' ' -f 1); \
$(MAKE) V=0 nimbus; \
MD5SUM2=$$(md5sum build/nimbus | cut -d ' ' -f 1); \
[ "$$MD5SUM1" = "$$MD5SUM2" ] && echo "Success: identical binaries." || \
{ echo "Failure: the binary changed between builds."; exit 1; }
# usual cleaning # usual cleaning
clean: clean:
@ -154,7 +169,7 @@ ntags:
#- actually binaries, but have them as phony targets to force rebuilds #- actually binaries, but have them as phony targets to force rebuilds
beacon_node validator_keygen: | build deps beacon_node validator_keygen: | build deps
$(ENV_SCRIPT) nim c -o:build/$@ $(REPOS_DIR)/nim-beacon-chain/beacon_chain/$@.nim $(ENV_SCRIPT) nim c $(NIM_PARAMS) -o:build/$@ $(REPOS_DIR)/nim-beacon-chain/beacon_chain/$@.nim
clean_eth2_network_simulation_files: clean_eth2_network_simulation_files:
rm -rf $(REPOS_DIR)/nim-beacon-chain/tests/simulation/data rm -rf $(REPOS_DIR)/nim-beacon-chain/tests/simulation/data

View File

@ -101,6 +101,13 @@ You can now follow those instructions in the previous section by replacing `make
- the Premix debugging tools are [documented separately](premix/readme.md) - the Premix debugging tools are [documented separately](premix/readme.md)
- you can control the Makefile's verbosity with the V variable (defaults to 1):
```bash
make V=0 # quiet
make V=2 test # more verbose than usual
```
#### Git submodule workflow #### Git submodule workflow
Working on a dependency: Working on a dependency:

1
env.sh
View File

@ -13,3 +13,4 @@ export NIMBLE_DIR="${abs_path}/vendor/.nimble"
export BUILD_OUTPUTS_DIR="${abs_path}/build" export BUILD_OUTPUTS_DIR="${abs_path}/build"
exec "$@" exec "$@"

View File

@ -18,14 +18,12 @@ done
# "nim" seems to only run custom NimScript files if they have a "nims" extension # "nim" seems to only run custom NimScript files if they have a "nims" extension
NIMS="${F%.nimble}.nims" NIMS="${F%.nimble}.nims"
ln -s "$F" "$NIMS"
# delete the temporary symlink on script exit # delete the temporary symlink on script exit
cleanup() { cleanup() {
rm -rf "$NIMS" rm -rf "$NIMS"
} }
trap cleanup EXIT [ -e "$NIMS" ] || { ln -s "$F" "$NIMS"; trap cleanup EXIT; }
# can't have an "exec" here or the EXIT pseudo-signal won't be triggered # can't have an "exec" here or the EXIT pseudo-signal won't be triggered
$(dirname $0)/env.sh nim "$1" "$NIMS" $(dirname $0)/env.sh nim "$@" "$NIMS"

View File

@ -19,19 +19,20 @@ requires "nim >= 0.19",
"eth", "eth",
"std_shims" "std_shims"
proc buildBinary(name: string, srcDir = ".", lang = "c") = proc buildBinary(name: string, srcDir = "./", params = "", lang = "c") =
if not dirExists "build": mkDir "build" if not dirExists "build":
switch("out", ("./build/" & name)) mkDir "build"
setCommand lang, srcDir & name & ".nim" # allow something like "nim nimbus --verbosity:0 --hints:off nimbus.nims"
var extra_params = params
for i in 2..<paramCount():
extra_params &= " " & paramStr(i)
exec "nim " & lang & " --out:./build/" & name & " " & extra_params & " " & srcDir & name & ".nim"
proc test(name: string, lang = "c") = proc test(name: string, lang = "c") =
switch("define", "chronicles_log_level=ERROR") buildBinary name, "tests/", "-r -d:chronicles_log_level=ERROR"
--run
buildBinary name, "tests/"
task test, "Run tests": task test, "Run tests":
# debugging tools don't yet have tests # debugging tools don't have tests yet, but they should be compilable
# but they should be compilable
for binary in [ for binary in [
"premix/premix", "premix/premix",
"premix/persist", "premix/persist",
@ -43,7 +44,6 @@ task test, "Run tests":
]: ]:
exec "nim c --verbosity:0 --hints:off --warnings:off " & binary exec "nim c --verbosity:0 --hints:off --warnings:off " & binary
rmFile binary rmFile binary
# executed last, no matter where you place it, because of "setCommand"
test "all_tests" test "all_tests"
task nimbus, "Build Nimbus": task nimbus, "Build Nimbus":

1
nimbus.nims Symbolic link
View File

@ -0,0 +1 @@
nimbus.nimble