From 37cc0a0d2fc178c5374e8e20266b81ab5524eaea Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Thu, 17 Oct 2019 16:03:22 +0200
Subject: [PATCH] CI: use our homemade cache for Boost MSYS2 binaries, to avoid
 useless downloads

The cache in ~/tarballs on the runner is shared with the jobs of the main
dynare repository that create the Windows and macOS packages.

Also use better options for wget.
---
 .gitlab-ci.yml | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 35549246..f9009510 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -2,6 +2,7 @@ variables:
   TERM: linux
   MINGW32_BOOST_VERSION: 1.71.0-1
   MINGW64_BOOST_VERSION: 1.71.0-1
+  WGET_OPTIONS: '--no-verbose --no-use-server-timestamps --retry-connrefused --retry-on-host-error'
 
 before_script:
   - 'export REMOTE_PATH=https://www.dynare.org/preprocessor/$CI_COMMIT_SHORT_SHA'
@@ -47,10 +48,10 @@ build_linux_64:
 build_windows_32:
   stage: build
   script:
+    - mkdir -p ~/tarballs
+    - '[[ -f ~/tarballs/mingw-w64-i686-boost-$MINGW32_BOOST_VERSION-any.pkg.tar.xz ]] || wget $WGET_OPTIONS -P ~/tarballs http://repo.msys2.org/mingw/i686/mingw-w64-i686-boost-$MINGW32_BOOST_VERSION-any.pkg.tar.xz'
     - mkdir -p deps
-    - cd deps && wget http://repo.msys2.org/mingw/i686/mingw-w64-i686-boost-$MINGW32_BOOST_VERSION-any.pkg.tar.xz
-    - tar xf mingw-w64-i686-boost-$MINGW32_BOOST_VERSION-any.pkg.tar.xz
-    - rm mingw-w64-i686-boost-$MINGW32_BOOST_VERSION-any.pkg.tar.xz && cd ..
+    - tar xf ~/tarballs/mingw-w64-i686-boost-$MINGW32_BOOST_VERSION-any.pkg.tar.xz --directory deps
     - autoreconf -si
     - './configure --host=i686-w64-mingw32 --with-boost=$(pwd)/deps/mingw32/include LDFLAGS="-static -static-libgcc -static-libstdc++"'
     - make -j$(nproc)
@@ -68,10 +69,10 @@ build_windows_32:
 build_windows_64:
   stage: build
   script:
+    - mkdir -p ~/tarballs
+    - '[[ -f ~/tarballs/mingw-w64-x86_64-boost-$MINGW64_BOOST_VERSION-any.pkg.tar.xz ]] || wget $WGET_OPTIONS -P ~/tarballs http://repo.msys2.org/mingw/x86_64/mingw-w64-x86_64-boost-$MINGW64_BOOST_VERSION-any.pkg.tar.xz'
     - mkdir -p deps
-    - cd deps && wget http://repo.msys2.org/mingw/x86_64/mingw-w64-x86_64-boost-$MINGW64_BOOST_VERSION-any.pkg.tar.xz
-    - tar xf mingw-w64-x86_64-boost-$MINGW64_BOOST_VERSION-any.pkg.tar.xz
-    - rm mingw-w64-x86_64-boost-$MINGW64_BOOST_VERSION-any.pkg.tar.xz && cd ..
+    - tar xf ~/tarballs/mingw-w64-x86_64-boost-$MINGW64_BOOST_VERSION-any.pkg.tar.xz --directory deps
     - autoreconf -si
     - './configure --host=x86_64-w64-mingw32 --with-boost=$(pwd)/deps/mingw64/include LDFLAGS="-static -static-libgcc -static-libstdc++"'
     - make -j$(nproc)
-- 
GitLab