Skip to content

Commit

Permalink
Cache based on contents
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Carroll <[email protected]>
  • Loading branch information
mjcarroll committed Feb 10, 2023
1 parent f5e76b5 commit 6751ba0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 23 deletions.
6 changes: 3 additions & 3 deletions .github/actions/bazel-ci-jammy/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
FROM ghcr.io/gazebo-tooling/gz-ubuntu:garden-jammy
ARG UID=1000

COPY ["run.sh", "/run.sh"]
COPY ["entrypoint.sh", "/entrypoint.sh"]

# Add a runner user and group to match github actions
# Additionally, use passwordless sudo
RUN groupadd -g 121 runner \
&& useradd -mr -d /home/runner -u 1001 -g 121 runner \
&& usermod -aG sudo runner \
&& echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

COPY ["run.sh", "/run.sh"]
COPY ["entrypoint.sh", "/entrypoint.sh"]

USER runner

ENTRYPOINT ["/entrypoint.sh"]
22 changes: 3 additions & 19 deletions .github/actions/bazel-ci-jammy/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,13 @@ set -e
BAZEL_ARGS=$1
WORKSPACE=~/gz
BAZEL_CACHE=$GITHUB_WORKSPACE/bazel_cache
BAZEL=~/.cache/bazelisk-linux-amd64
BAZEL=$BAZEL_CACHE/bazelisk-linux-amd64

echo ::group::Install tools: apt
sudo apt update 2>&1
sudo apt -y install \
build-essential \
cppcheck \
curl \
git \
gnupg \
lsb-release \
python3-pip \
wget

cd "$GITHUB_WORKSPACE"
SYSTEM_VERSION=`lsb_release -cs`
SOURCE_DEPENDENCIES="`pwd`/.github/ci/dependencies.yaml"
SOURCE_DEPENDENCIES_VERSIONED="`pwd`/.github/ci-$SYSTEM_VERSION/dependencies.yaml"
echo ::endgroup::

echo ::group::Install tools: pip
pip3 install -U pip vcstool colcon-common-extensions
echo ::endgroup::
cd "$GITHUB_WORKSPACE"

# Restore cache
if [ ! -d "$BAZEL_CACHE" ]; then
Expand All @@ -38,7 +22,7 @@ rm -rf ~/.cache
ln -sf ${BAZEL_CACHE} ~/.cache

# Install baselisk if it is not already installed
if [ ! -f "${BAZEL}" ]; then
if [ ! -f ${BAZEL} ]; then
wget https://github.com/bazelbuild/bazelisk/releases/download/v1.16.0/bazelisk-linux-amd64 -O ${BAZEL}
fi
chmod +x ${BAZEL}
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ jobs:
with:
path: |
${{ github.workspace }}/bazel_cache
key: ${{ runner.os }}-${{ env.cache-name }}
key: cache-bazel-${{ hashFiles('example/bazel.repos') }}
restore-keys: |
cache-bazel-
- name: Compile and test
uses: ./.github/actions/bazel-ci-jammy
Expand Down

0 comments on commit 6751ba0

Please sign in to comment.