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
# 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 -j2 ARCH_OVERRIDE=%PLATFORM% nimbus
- mingw32-make -j2 ARCH_OVERRIDE=%PLATFORM% V=0 nimbus
test_script:
- build\nimbus.exe --help
- mingw32-make -j2 ARCH_OVERRIDE=%PLATFORM% test
- mingw32-make -j2 ARCH_OVERRIDE=%PLATFORM% V=0 test test-reproducibility
deploy: off

View File

@ -34,7 +34,7 @@ install:
script:
- set -e # fail fast
- make -j${NPROC} nimbus
- make -j${NPROC} V=0 nimbus
- ./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
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 \
status-im/nim-eth \
@ -77,12 +83,12 @@ all: premix persist debug dumper hunter nimbus
# debugging tools
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"
#- a phony target, because teaching `make` how to do conditional recompilation of Nim projects is too complicated
nimbus: | build deps
./nimble.sh nimbus && \
$(ENV_SCRIPT) nim nimbus $(NIM_PARAMS) nimbus.nims && \
echo -e "\nThe binary is in './build/nimbus'.\n"
# dir
@ -108,7 +114,16 @@ $(NIMBLE_DIR): | $(NIM_BINARY)
# builds and runs all tests
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
clean:
@ -154,7 +169,7 @@ ntags:
#- actually binaries, but have them as phony targets to force rebuilds
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:
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)
- 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
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"
exec "$@"

View File

@ -18,14 +18,12 @@ done
# "nim" seems to only run custom NimScript files if they have a "nims" extension
NIMS="${F%.nimble}.nims"
ln -s "$F" "$NIMS"
# delete the temporary symlink on script exit
cleanup() {
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
$(dirname $0)/env.sh nim "$1" "$NIMS"
$(dirname $0)/env.sh nim "$@" "$NIMS"

View File

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

1
nimbus.nims Symbolic link
View File

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