From a0066abf953e07ab6f2d17399b7f607bade60aa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C8=98tefan=20Talpalaru?= Date: Sun, 9 Jun 2019 16:48:29 +0200 Subject: [PATCH] CI: cache the Nim compiler binaries between builds --- .appveyor.yml | 4 ++++ .travis.yml | 5 +++-- Makefile | 11 ++++++++--- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 58e8dfe2b..3e05fd5c4 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -3,6 +3,9 @@ version: '{build}' # use an image with recent Mingw-w64 versions available on both architectures: https://www.appveyor.com/docs/windows-images-software/#mingw-msys-cygwin image: Visual Studio 2015 +cache: + - NimBinaries + matrix: # We always want 32-bit and 64-bit compilation fast_finish: false @@ -22,6 +25,7 @@ install: build_script: - cd C:\projects\%APPVEYOR_PROJECT_SLUG% # the 32-bit build is done on a 64-bit image, so we need to override the architecture + - mingw32-make -j2 ARCH_OVERRIDE=%PLATFORM% CI_CACHE=NimBinaries update - mingw32-make -j2 ARCH_OVERRIDE=%PLATFORM% fetch-dlls - dir C:\mingw-w64 diff --git a/.travis.yml b/.travis.yml index bb506864a..9828e5489 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,10 @@ -language: c # or other C/C++ variants +language: c # https://docs.travis-ci.com/user/caching/ cache: directories: - rocksdb + - vendor/Nim/bin git: # when multiple CI builds are queued, the tested commit needs to be in the last X commits cloned with "--depth X" @@ -23,7 +24,7 @@ matrix: install: # build our own rocksdb to test with a fixed version that we think works - - "export ROCKSDBVER=5.14.2" + - export ROCKSDBVER=5.14.2 - "[ -f rocksdb/rocksdb-$ROCKSDBVER/Makefile ] || { rm -rf rocksdb ; mkdir -p rocksdb; cd rocksdb; wget https://github.com/facebook/rocksdb/archive/v$ROCKSDBVER.tar.gz && tar xvf v$ROCKSDBVER.tar.gz; cd ..; }" - cd rocksdb/rocksdb-$ROCKSDBVER - "[ -f util/build_version.cc ] || { make util/build_version.cc ; }" # use cached version if possible diff --git a/Makefile b/Makefile index 15396ff66..ac77b8c79 100644 --- a/Makefile +++ b/Makefile @@ -71,7 +71,7 @@ BUILD_NIM := echo -e $(BUILD_MSG) "Nim compiler" && \ sed 's/koch tools/koch --stable tools/' build_all.sh > build_all_custom.sh; \ sh build_all_custom.sh $(HANDLE_OUTPUT); \ rm build_all_custom.sh; \ - } + } && cd ../.. NIM_BINARY := $(NIM_DIR)/bin/nim$(EXE_SUFFIX) # md5sum - macOS is a special case ifeq ($(shell uname), Darwin) @@ -79,6 +79,8 @@ ifeq ($(shell uname), Darwin) else MD5SUM := md5sum endif +# AppVeyor cache of $(NIM_DIR)/bin that doesn't get unpacked after all submodules have been checked out, like on Travis +CI_CACHE := # debugging tools + testing tools TOOLS := premix persist debug dumper hunter regress tracerTestGen persistBlockTestGen @@ -188,14 +190,17 @@ build-nim: | deps + $(BUILD_NIM) #- initialises and updates the Git submodules +#- manages the AppVeyor cache of Nim compiler binaries #- deletes the ".nimble" dir to force the execution of the "deps" target #- deletes and recreates "nimbus.nims" which on Windows is a copy instead of a proper symlink #- allows parallel building with the '+' prefix -#- rebuilds the Nim compiler after the corresponding submodule is updated +#- rebuilds the Nim compiler after the corresponding submodule is updated (keep in mind that Git doesn't preserve file timestamps) $(NIM_BINARY) update: | sanity-checks git submodule update --init --recursive + [[ -n "$(CI_CACHE)" && -d "$(CI_CACHE)" ]] && cp -a "$(CI_CACHE)"/* $(NIM_DIR)/bin/ || true rm -rf $(NIMBLE_DIR) nimbus.nims && $(MAKE) nimbus.nims - + [[ -e $(NIM_BINARY) && $(NIM_BINARY) -nt $(NIM_DIR)/lib/system.nim ]] || { $(BUILD_NIM); } + + [[ -e $(NIM_BINARY) && $$(stat -c%Z $(NIM_BINARY)) -gt $$(git log --pretty=format:%cd -n 1 --date=unix -- vendor/Nim) ]] || \ + { $(BUILD_NIM); [[ -n "$(CI_CACHE)" ]] && rm -rf "$(CI_CACHE)" && mkdir $(CI_CACHE) && cp -a $(NIM_DIR)/bin/* "$(CI_CACHE)"/ || true; } # don't use this target, or you risk updating dependency repos that are not ready to be used in Nimbus update-remote: