Skip to content

Commit

Permalink
(CI) also cache pip (#34)
Browse files Browse the repository at this point in the history
* (CI) also cache pip

* (actions) cache pip
  • Loading branch information
MatthijsBurgh authored Apr 19, 2023
1 parent d0cc74d commit a518c94
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
11 changes: 10 additions & 1 deletion .ci/install.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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'
8 changes: 8 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/}
Expand Down

0 comments on commit a518c94

Please sign in to comment.