Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ci,docker): save RUN --mount=type=cache ccache on GitHub Actions cache #4854

Merged
merged 7 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions .github/actions/docker-build-and-push/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ inputs:
runs:
using: composite
steps:
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Install jq and vcstool
run: |
sudo apt-get -y update
Expand Down Expand Up @@ -59,7 +56,7 @@ runs:

- name: Docker meta for prebuilt
id: meta-prebuilt
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/${{ inputs.bake-target }}
tags: ${{ steps.set-docker-tags.outputs.tags }}
Expand All @@ -70,7 +67,7 @@ runs:

- name: Docker meta for devel
id: meta-devel
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/${{ inputs.bake-target }}
tags: ${{ steps.set-docker-tags.outputs.tags }}
Expand All @@ -82,7 +79,7 @@ runs:
- name: Docker meta for runtime
if: ${{ github.event_name == 'workflow_dispatch' }} || ${{ (github.event_name == 'push' && github.ref_type == 'tag') }}
id: meta-runtime
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/${{ inputs.bake-target }}
tags: ${{ steps.set-docker-tags.outputs.tags }}
Expand All @@ -101,7 +98,7 @@ runs:

- name: Build and Push to GitHub Container Registry
if: ${{ github.event_name == 'push' || github.event_name == 'schedule' || ( github.event_name == 'workflow_dispatch' && github.event.inputs.artifacts-destination == 'registry') }}
uses: docker/bake-action@v3
uses: docker/bake-action@v4
with:
push: ${{ inputs.allow-push == 'true' }}
files: |
Expand All @@ -115,7 +112,7 @@ runs:

- name: Build only
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.artifacts-destination == 'tarball' }}
uses: docker/bake-action@v3
uses: docker/bake-action@v4
with:
push: false
files: |
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/build-main-self-hosted.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ jobs:
- name: Check out repository
uses: actions/checkout@v4

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Set git config
uses: autowarefoundation/autoware-github-actions/set-git-config@v1
with:
Expand All @@ -54,6 +57,25 @@ jobs:
- name: Free disk space
uses: ./.github/actions/free-disk-space

- name: Cache
uses: actions/cache@v3
id: cache
with:
path: |
root-ccache
key: cache-${{ matrix.platform }}-${{ matrix.name }}-${{ hashFiles('autoware.repos') }}
restore-keys: |
cache-${{ matrix.platform }}-${{ matrix.name }}-
cache-${{ matrix.platform }}-
- name: inject cache into docker
uses: reproducible-containers/buildkit-cache-dance@v3.1.0
with:
cache-map: |
{
"root-ccache": "/root/.ccache"
}
skip-extraction: ${{ steps.cache.outputs.cache-hit }}

- name: Build 'Autoware'
uses: ./.github/actions/docker-build-and-push
with:
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/build-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ jobs:
- name: Check out repository
uses: actions/checkout@v4

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Set git config
uses: autowarefoundation/autoware-github-actions/set-git-config@v1
with:
Expand All @@ -49,6 +52,25 @@ jobs:
- name: Free disk space
uses: ./.github/actions/free-disk-space

- name: Cache
uses: actions/cache@v3
id: cache
with:
path: |
root-ccache
key: cache-${{ matrix.platform }}-${{ matrix.name }}-${{ hashFiles('autoware.repos') }}
restore-keys: |
cache-${{ matrix.platform }}-${{ matrix.name }}-
cache-${{ matrix.platform }}-
- name: inject cache into docker
uses: reproducible-containers/buildkit-cache-dance@v3.1.0
with:
cache-map: |
{
"root-ccache": "/root/.ccache"
}
skip-extraction: ${{ steps.cache.outputs.cache-hit }}

- name: Build 'Autoware'
uses: ./.github/actions/docker-build-and-push
with:
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/docker-build-and-push-main-self-hosted.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ jobs:
- name: Check out repository
uses: actions/checkout@v4

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Set git config
uses: autowarefoundation/autoware-github-actions/set-git-config@v1
with:
Expand All @@ -66,6 +69,25 @@ jobs:
- name: Free disk space
uses: ./.github/actions/free-disk-space

- name: Cache
uses: actions/cache@v3
id: cache
with:
path: |
root-ccache
key: cache-${{ matrix.platform }}-${{ matrix.name }}-${{ hashFiles('autoware.repos') }}
restore-keys: |
cache-${{ matrix.platform }}-${{ matrix.name }}-
cache-${{ matrix.platform }}-
- name: inject cache into docker
uses: reproducible-containers/buildkit-cache-dance@v3.1.0
with:
cache-map: |
{
"root-ccache": "/root/.ccache"
}
skip-extraction: ${{ steps.cache.outputs.cache-hit }}

- name: Build 'Autoware'
uses: ./.github/actions/docker-build-and-push
with:
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/docker-build-and-push-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ jobs:
- name: Check out repository
uses: actions/checkout@v4

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Set git config
uses: autowarefoundation/autoware-github-actions/set-git-config@v1
with:
Expand All @@ -61,6 +64,25 @@ jobs:
- name: Free disk space
uses: ./.github/actions/free-disk-space

- name: Cache
uses: actions/cache@v3
id: cache
with:
path: |
root-ccache
key: cache-${{ matrix.platform }}-${{ matrix.name }}-${{ hashFiles('autoware.repos') }}
restore-keys: |
cache-${{ matrix.platform }}-${{ matrix.name }}-
cache-${{ matrix.platform }}-
- name: inject cache into docker
uses: reproducible-containers/buildkit-cache-dance@v3.1.0
with:
cache-map: |
{
"root-ccache": "/root/.ccache"
}
skip-extraction: ${{ steps.cache.outputs.cache-hit }}

- name: Build 'Autoware'
uses: ./.github/actions/docker-build-and-push
with:
Expand Down
8 changes: 3 additions & 5 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ARG ROS_DISTRO
ARG SETUP_ARGS
ENV CCACHE_DIR="/var/tmp/ccache"
ENV CC="/usr/lib/ccache/gcc"
ENV CXX="/usr/lib/ccache/g++"

# cspell: ignore libcu libnv
# Set up development environment
Expand All @@ -90,13 +88,13 @@ RUN --mount=type=ssh \
COPY --from=src-imported /autoware/src /autoware/src
RUN --mount=type=cache,target=${CCACHE_DIR} \
source /opt/ros/"$ROS_DISTRO"/setup.bash \
&& du -sh ${CCACHE_DIR} && ccache -s \
&& colcon build --cmake-args \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
" -Wno-dev" \
" --no-warn-unused-cli" \
--mixin release compile-commands ccache \
&& du -sh ${CCACHE_DIR} && ccache -s \
&& find /autoware/install -type d -exec chmod 777 {} \; \
&& chmod -R 777 /var/tmp/ccache \
&& rm -rf /autoware/build /autoware/src

CMD ["/bin/bash"]
Expand Down
Loading