Hello,

I've figured out how to use CI caches.
if that will work for some time, I'll do the same for SSL libs.

Ilya
From b3cb40d6dbe29ef5bda448ff83ef1a8be0a23f84 Mon Sep 17 00:00:00 2001
From: Ilya Shipitsin <[email protected]>
Date: Thu, 13 Jan 2022 11:36:28 +0500
Subject: [PATCH] CI: github actions: use cache for OpenTracing

this caches OpenTracing libs between builds, should save couple of minutes
for each build.
---
 .github/matrix.py           |  8 ++++----
 .github/workflows/vtest.yml | 26 ++++++++++++++++++++++++--
 scripts/build-ot.sh         | 34 ----------------------------------
 3 files changed, 28 insertions(+), 40 deletions(-)
 delete mode 100755 scripts/build-ot.sh

diff --git a/.github/matrix.py b/.github/matrix.py
index 34a78ace4..3c34eaf90 100755
--- a/.github/matrix.py
+++ b/.github/matrix.py
@@ -74,8 +74,8 @@ for CC in ["gcc", "clang"]:
             "FLAGS": [
                 "USE_ZLIB=1",
                 "USE_OT=1",
-                "OT_INC=${HOME}/opt/include",
-                "OT_LIB=${HOME}/opt/lib",
+                "OT_INC=${HOME}/opt-ot/include",
+                "OT_LIB=${HOME}/opt-ot/lib",
                 "OT_RUNPATH=1",
                 "USE_PCRE=1",
                 "USE_PCRE_JIT=1",
@@ -150,8 +150,8 @@ matrix.append(
         + [
             "USE_ZLIB=1",
             "USE_OT=1",
-            "OT_INC=${HOME}/opt/include",
-            "OT_LIB=${HOME}/opt/lib",
+            "OT_INC=${HOME}/opt-ot/include",
+            "OT_LIB=${HOME}/opt-ot/lib",
             "OT_RUNPATH=1",
             "USE_PCRE=1",
             "USE_PCRE_JIT=1",
diff --git a/.github/workflows/vtest.yml b/.github/workflows/vtest.yml
index 421384b46..d24c3fffa 100644
--- a/.github/workflows/vtest.yml
+++ b/.github/workflows/vtest.yml
@@ -42,10 +42,18 @@ jobs:
       TMPDIR: /tmp
       # Force ASAN output into asan.log to make the output more readable.
       ASAN_OPTIONS: log_path=asan.log
+      OT_CPP_VERSION: 1.5.0
     steps:
     - uses: actions/checkout@v2
       with:
         fetch-depth: 100
+    - name: Cache OpenTracing
+      if: ${{ contains(matrix.FLAGS, 'USE_OT=1') }}
+      id: cache_ot
+      uses: actions/cache@v2
+      with:
+        path: '~/opt-ot/'
+        key: ot-${{ matrix.CC }}-${{ env.OT_CPP_VERSION }}-${{ contains(matrix.name, 'ASAN') }}
     - name: Install apt dependencies
       if: ${{ startsWith(matrix.os, 'ubuntu-') }}
       run: |
@@ -68,8 +76,22 @@ jobs:
       if: ${{ matrix.ssl && matrix.ssl != 'stock' }}
       run: env ${{ matrix.ssl }} scripts/build-ssl.sh
     - name: Install OpenTracing libs
-      if: ${{ contains(matrix.FLAGS, 'USE_OT=1') }}
-      run: scripts/build-ot.sh
+      if: ${{ contains(matrix.FLAGS, 'USE_OT=1') && steps.cache_ot.outputs.cache-hit != 'true'  }}
+      run: |
+        wget https://github.com/opentracing/opentracing-cpp/archive/v${OT_CPP_VERSION}.tar.gz
+        tar xf v${OT_CPP_VERSION}.tar.gz
+        cd opentracing-cpp-${OT_CPP_VERSION}
+        mkdir build
+        cd build
+        cmake -DCMAKE_INSTALL_PREFIX=${HOME}/opt-ot -DBUILD_STATIC_LIBS=OFF -DBUILD_MOCKTRACER=OFF -DBUILD_TESTING=OFF ..
+        make -j$(nproc)
+        make install
+        git clone https://github.com/haproxytech/opentracing-c-wrapper.git
+        cd opentracing-c-wrapper
+        ./scripts/bootstrap
+        ./configure --prefix=${HOME}/opt-ot --with-opentracing=${HOME}/opt-ot
+        make -j$(nproc)
+        make install
     - name: Build WURFL
       if: ${{ contains(matrix.FLAGS, 'USE_WURFL=1') }}
       run: make -C addons/wurfl/dummy
diff --git a/scripts/build-ot.sh b/scripts/build-ot.sh
deleted file mode 100755
index 1c296b64b..000000000
--- a/scripts/build-ot.sh
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/bin/bash
-
-#
-# OT helper. script built from documentation: https://github.com/haproxytech/opentracing-c-wrapper
-#
-
-set -e
-
-export OT_CPP_VERSION=1.5.0
-
-if [ ! -f "download-cache/v${OT_CPP_VERSION}.tar.gz" ]; then
-    wget -P download-cache/ \
-        "https://github.com/opentracing/opentracing-cpp/archive/v${OT_CPP_VERSION}.tar.gz";
-fi
-
-if [ "$(cat ${HOME}/opt/.ot-cpp-version)" != "${OT_CPP_VERSION}" ]; then
-    tar xf download-cache/v${OT_CPP_VERSION}.tar.gz
-    cd opentracing-cpp-${OT_CPP_VERSION}
-    mkdir build
-    cd build
-    cmake -DCMAKE_INSTALL_PREFIX=${HOME}/opt -DBUILD_STATIC_LIBS=OFF -DBUILD_MOCKTRACER=OFF -DBUILD_TESTING=OFF ..
-    make -j$(nproc)
-    make install
-    echo "${OT_CPP_VERSION}" > "${HOME}/opt/.ot-cpp-version"
-fi
-
-git clone https://github.com/haproxytech/opentracing-c-wrapper.git
-cd opentracing-c-wrapper
- ./scripts/bootstrap
- ./configure --prefix=${HOME}/opt --with-opentracing=${HOME}/opt
- make -j$(nproc)
- make install
-
-
-- 
2.34.1

Reply via email to