diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7d1ee3b85..fce089085 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -96,6 +96,32 @@ jobs: # --- Code update --- - name: "Check out code" uses: actions/checkout@v2 + # --- Cache based on Conan version and ExternalProjects cmake source + - name: Get Conan version + id: get-conan-version + run: | + docker-compose run --rm faabric conan --version 2>/tmp/conan-ver-log | tee /tmp/conan-ver + grep 'Conan version' /tmp/conan-ver || exit 1 + echo "::set-output name=conan-version::$(grep 'Conan version' /tmp/conan-ver | tr -d '[:alpha:] ')" + shell: bash + env: + FAASM_BUILD_MOUNT: /build/faasm + CONAN_CACHE_MOUNT_SOURCE: ~/.conan/ + - name: Get Conan Version - Show Log + if: always() + run: cat /tmp/conan-ver-log + - name: Hash ExternalProjects + id: hash-external + run: | + echo "::set-output name=hash-external::$(sha256sum cmake/ExternalProjects.cmake | cut '-d ' -f 1)" + shell: bash + - uses: actions/cache@v2 + with: + path: '~/.conan' + key: ${{ runner.os }}-${{ steps.get-conan-version.outputs.conan-version }}-${{ steps.hash-external.outputs.hash-external }} + restore-keys: | + ${{ runner.os }}-${{ steps.get-conan-version.outputs.conan-version }}- + ${{ runner.os }}- # --- Build and test --- - name: "Build distributed tests" run: ./dist-test/build.sh diff --git a/dist-test/build.sh b/dist-test/build.sh index bad5ebf85..724e4f5eb 100755 --- a/dist-test/build.sh +++ b/dist-test/build.sh @@ -5,6 +5,10 @@ set -e export PROJ_ROOT=$(dirname $(dirname $(readlink -f $0))) pushd ${PROJ_ROOT} >> /dev/null +export CONAN_CACHE_MOUNT_SOURCE=$HOME/.conan/ +# Ensure the cache directory exists before starting the containers +mkdir -p ${CONAN_CACHE_MOUNT_SOURCE} + # Run the build docker-compose \ run \ diff --git a/dist-test/run.sh b/dist-test/run.sh index 1676ff52e..9f3f596c3 100755 --- a/dist-test/run.sh +++ b/dist-test/run.sh @@ -3,6 +3,7 @@ export PROJ_ROOT=$(dirname $(dirname $(readlink -f $0))) pushd ${PROJ_ROOT} >> /dev/null +export CONAN_CACHE_MOUNT_SOURCE=$HOME/.conan/ RETURN_VAL=0 # Run the test server in the background diff --git a/docker-compose.yml b/docker-compose.yml index fdd6900c4..c9840afac 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,7 +11,7 @@ services: - /usr/bin/docker:/usr/bin/docker - ./:/code/faabric - ./build:/build/faabric - - ./conan-cache/:/root/.conan + - ${CONAN_CACHE_MOUNT_SOURCE:-./conan-cache/}:/root/.conan working_dir: /code/faabric stdin_open: true tty: true