diff --git a/.github/workflows/build-docker-images.yml b/.github/workflows/build-docker-images.yml index 1faabaad6a..c5e3133619 100644 --- a/.github/workflows/build-docker-images.yml +++ b/.github/workflows/build-docker-images.yml @@ -39,23 +39,38 @@ 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 }} + - 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: @@ -63,5 +78,29 @@ jobs: 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 }} diff --git a/ci/docker/vt.dockerfile b/ci/docker/vt.dockerfile index 9f41ce76b4..7a4bda12ef 100644 --- a/ci/docker/vt.dockerfile +++ b/ci/docker/vt.dockerfile @@ -42,18 +42,14 @@ ARG VT_UNITY_BUILD_ENABLED ARG VT_WERROR_ENABLED ARG VT_ZOLTAN_ENABLED -RUN --mount=target=/vt \ -<