From a518c94c42aca78e3078f7bd29a86af2adb40bce Mon Sep 17 00:00:00 2001 From: Matthijs van der Burgh Date: Wed, 19 Apr 2023 11:42:13 +0200 Subject: [PATCH] (CI) also cache pip (#34) * (CI) also cache pip * (actions) cache pip --- .ci/install.bash | 11 ++++++++++- .github/workflows/main.yml | 8 ++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/.ci/install.bash b/.ci/install.bash index c855e3bd25a3..a9ed79d3a808 100755 --- a/.ci/install.bash +++ b/.ci/install.bash @@ -74,13 +74,19 @@ DOCKER_HOME=$(docker run --name tue-env --rm "${IMAGE_NAME}:${BRANCH_TAG}" bash # Make sure the ~/.ccache folder exists mkdir -p "$HOME"/.ccache +# Make sure the ~/.cache/pip folder exists +mkdir -p "$HOME"/.cache/pip + # Run the docker image along with setting new environment variables # shellcheck disable=SC2086 -docker run --detach --interactive --tty -e CI="true" -e BRANCH="${BRANCH}" --name tue-env --mount type=bind,source=${HOME}/.ccache,target=${DOCKER_HOME}/.ccache ${DOCKER_MOUNT_KNOWN_HOSTS_ARGS} "${IMAGE_NAME}:${BRANCH_TAG}" +docker run --detach --interactive --tty -e CI="true" -e BRANCH="${BRANCH}" --name tue-env --mount type=bind,source=${HOME}/.ccache,target=${DOCKER_HOME}/.ccache --mount type=bind,source=$HOME/.cache/pip,target=$DOCKER_HOME/.cache/pip ${DOCKER_MOUNT_KNOWN_HOSTS_ARGS} "${IMAGE_NAME}:${BRANCH_TAG}" # Own the ~/.ccache folder for permissions docker exec -t tue-env bash -c "sudo chown 1000:1000 -R ~/.ccache" +# Own the ~/.cache/pip folder for permissions +docker exec -t tue-env bash -c 'sudo chown "${USER}":"${USER}" -R ~/.cache/pip' + if [ "$MERGE_KNOWN_HOSTS" == "true" ] then docker exec -t tue-env bash -c "sudo chown 1000:1000 /tmp/known_hosts_extra && ~/.tue/ci/ssh-merge-known_hosts.py ~/.ssh/known_hosts /tmp/known_hosts_extra --output ~/.ssh/known_hosts" @@ -125,3 +131,6 @@ then echo -e '\e[35m\e[1mcatkin config --workspace ${TUE_SYSTEM_DIR} --no-skiplist\e[0m' docker exec -t tue-env bash -c 'source ~/.bashrc; catkin config --workspace ${TUE_SYSTEM_DIR} --no-skiplist' # Clear skiplist fi + +# Allow everyone to read ~/.cache/pip folder for caching inside CI pipelines +docker exec -t tue-env bash -c 'sudo chmod -R a+r ~/.cache/pip' diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9cb5b4efff59..926dda51f411 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -29,6 +29,14 @@ jobs: key: ${{ runner.os }}-ccache-${{ steps.get-date.outputs.date }} restore-keys: | ${{ runner.os }}-ccache- + - name: Cache pip + uses: actions/cache@v3 + with: + path: | + ~/.cache/pip + key: ${{ runner.os }}-pip-${{ steps.get-date.outputs.date }} + restore-keys: | + ${{ runner.os }}-pip- - name: Install run: | GITHUB_REF=${GITHUB_REF#refs/heads/}