Skip to content
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
47 changes: 43 additions & 4 deletions .github/workflows/build-docker-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,68 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Docker Buildx
id: setup-buildx
uses: docker/setup-buildx-action@v3

- uses: actions/cache@v4
id: ccache-archive
with:
path: docker-output/build/ccache
path: ccache-archive
key: ${{ matrix.target }}-${{ github.ref }}-${{ github.sha }}
restore-keys: |
${{ matrix.target }}-${{ github.ref }}
${{ matrix.target }}-

- name: Inject ccache
uses: reproducible-containers/buildkit-cache-dance@v3
with:
builder: ${{ steps.setup-buildx.outputs.name }}
cache-map: |
{
"ccache-archive": {
"target": "/build/ccache",
"id": "${{ matrix.target }}"
}
}
skip-extraction: ${{ steps.ccache-archive.outputs.cache-hit }}
Comment on lines +55 to +66
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍
BTW buildkit-cache-dance is a great name for this action 😁


- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}

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

- name: Build
uses: docker/bake-action@v6
with:
source: .
targets: ${{ matrix.target }}
files: docker-bake.hcl
push: ${{ github.ref == 'refs/heads/develop' }}
set: |
*.args.CACHE_ID=${{ matrix.target }}
env:
GIT_BRANCH: ${{ github.head_ref || github.ref_name }}

- name: Retrieve build artifacts
if: ${{ matrix.target == 'vt-build-amd64-ubuntu-22-04-gcc-11-cpp' }}
run: |
# We rely on the persistence of data on cache mounts with identical IDs and builders.
# This allows us to copy build artifacts from the "bake" step and use the Codecov action within the GitHub environment.

echo "
FROM ubuntu:latest
RUN --mount=type=cache,id=BUILD-${{ matrix.target }},target=/build/vt \
mkdir -p /vt \
&& cp -p -R /build/vt/. /vt/ || true
" >> tmp_dockerfile

docker buildx build --builder ${{ steps.setup-buildx.outputs.name }} -f tmp_dockerfile --output type=local,dest=build .

- name: Upload coverage
if: ${{ matrix.target == 'vt-build-amd64-ubuntu-22-04-gcc-11-cpp' }}
uses: codecov/codecov-action@v5
with:
files: build/vt/coverage.info
token: ${{ secrets.CODECOV_TOKEN }}
14 changes: 5 additions & 9 deletions ci/docker/vt.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,14 @@ ARG VT_UNITY_BUILD_ENABLED
ARG VT_WERROR_ENABLED
ARG VT_ZOLTAN_ENABLED

RUN --mount=target=/vt \
<<EOF
if [ -d vt/docker-output/build/ccache ]; then
cp -r vt/docker-output/build/ccache /build
ccache -c
ccache -s
fi
EOF
ARG IMAGE
ARG CACHE_ID=${IMAGE}

ENV GIT_BRANCH=${GIT_BRANCH}

RUN --mount=target=/vt,rw \
RUN --mount=type=cache,id=${CACHE_ID},target=/build/ccache \
--mount=type=cache,id=BUILD-${CACHE_ID},target=/build/vt \
--mount=target=/vt,rw \
if [ "${VT_TEST_SPACK}" = "1" ]; then \
apt update -y -q && apt install -y -q libssl-dev unzip && \
/vt/ci/test_spack_package.sh; \
Expand Down
3 changes: 0 additions & 3 deletions ci/test_cpp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ then
lcov --capture --directory . --output-file coverage.info
lcov --remove coverage.info '/usr/*' --output-file coverage.info
lcov --list coverage.info
pushd "$VT"
bash <(curl -s https://codecov.io/bash) -f "${VT_BUILD}/coverage.info" || echo "Codecov did not collect coverage reports"
popd
fi

if test "${VT_CI_TEST_LB_SCHEMA:-0}" -eq 1
Expand Down
20 changes: 1 addition & 19 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -174,32 +174,14 @@ target "vt-build" {
target = "build"
context = "."
dockerfile = "ci/docker/vt.dockerfile"
output = [
{
type = "local"
dest = "docker-output"
}
]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 This helps when building locally too.

platforms = [
"linux/amd64",
# "linux/arm64"
]
ulimits = [
"core=0"
]
# FIXME: verify that caching works as intended
# cache-from = [
# {
# type = "local",
# src = "~/ccache"
# }
# ]
# cache-to = [
# {
# type = "local",
# dest = "~/ccache"
# }
# ]
}

target "vt-build-all" {
Expand Down