diff --git a/.github/actions/bazel-ci-jammy/Dockerfile b/.github/actions/bazel-ci-jammy/Dockerfile index 1975445..12b5e40 100644 --- a/.github/actions/bazel-ci-jammy/Dockerfile +++ b/.github/actions/bazel-ci-jammy/Dockerfile @@ -1,9 +1,6 @@ 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 \ @@ -11,6 +8,9 @@ RUN groupadd -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"] diff --git a/.github/actions/bazel-ci-jammy/run.sh b/.github/actions/bazel-ci-jammy/run.sh index 199bf6a..a1fcd77 100755 --- a/.github/actions/bazel-ci-jammy/run.sh +++ b/.github/actions/bazel-ci-jammy/run.sh @@ -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 @@ -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} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ae8930a..210fa6c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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