Skip to content

Commit db5b884

Browse files
authored
Merge pull request #2462 from DARMA-tasking/2461-ci-fix-code-coverage-build
#2461: Fix code coverage pipeline
2 parents 497d1c3 + fbef7b7 commit db5b884

File tree

4 files changed

+49
-35
lines changed

4 files changed

+49
-35
lines changed

.github/workflows/build-docker-images.yml

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,29 +39,68 @@ jobs:
3939
- name: Checkout
4040
uses: actions/checkout@v4
4141

42+
- name: Set up Docker Buildx
43+
id: setup-buildx
44+
uses: docker/setup-buildx-action@v3
45+
4246
- uses: actions/cache@v4
47+
id: ccache-archive
4348
with:
44-
path: docker-output/build/ccache
49+
path: ccache-archive
4550
key: ${{ matrix.target }}-${{ github.ref }}-${{ github.sha }}
4651
restore-keys: |
4752
${{ matrix.target }}-${{ github.ref }}
4853
${{ matrix.target }}-
4954
55+
- name: Inject ccache
56+
uses: reproducible-containers/buildkit-cache-dance@v3
57+
with:
58+
builder: ${{ steps.setup-buildx.outputs.name }}
59+
cache-map: |
60+
{
61+
"ccache-archive": {
62+
"target": "/build/ccache",
63+
"id": "${{ matrix.target }}"
64+
}
65+
}
66+
skip-extraction: ${{ steps.ccache-archive.outputs.cache-hit }}
67+
5068
- name: Login to DockerHub
5169
uses: docker/login-action@v3
5270
with:
5371
username: ${{ secrets.DOCKER_USERNAME }}
5472
password: ${{ secrets.DOCKER_TOKEN }}
5573

56-
- name: Set up Docker Buildx
57-
uses: docker/setup-buildx-action@v3
58-
5974
- name: Build
6075
uses: docker/bake-action@v6
6176
with:
6277
source: .
6378
targets: ${{ matrix.target }}
6479
files: docker-bake.hcl
6580
push: ${{ github.ref == 'refs/heads/develop' }}
81+
set: |
82+
*.args.CACHE_ID=${{ matrix.target }}
6683
env:
6784
GIT_BRANCH: ${{ github.head_ref || github.ref_name }}
85+
86+
- name: Retrieve build artifacts
87+
if: ${{ matrix.target == 'vt-build-amd64-ubuntu-22-04-gcc-11-cpp' }}
88+
run: |
89+
# We rely on the persistence of data on cache mounts with identical IDs and builders.
90+
# This allows us to copy build artifacts from the "bake" step and use the Codecov action within the GitHub environment.
91+
92+
echo "
93+
FROM ubuntu:latest
94+
RUN --mount=type=cache,id=BUILD-${{ matrix.target }},target=/build/vt \
95+
mkdir -p /vt \
96+
&& cp -p -R /build/vt/. /vt/ || true
97+
" >> tmp_dockerfile
98+
99+
docker buildx build --builder ${{ steps.setup-buildx.outputs.name }} -f tmp_dockerfile --output type=local,dest=build .
100+
101+
- name: Upload coverage
102+
if: ${{ matrix.target == 'vt-build-amd64-ubuntu-22-04-gcc-11-cpp' }}
103+
uses: codecov/codecov-action@v5
104+
with:
105+
files: build/vt/coverage.info
106+
token: ${{ secrets.CODECOV_TOKEN }}

ci/docker/vt.dockerfile

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,14 @@ ARG VT_UNITY_BUILD_ENABLED
4242
ARG VT_WERROR_ENABLED
4343
ARG VT_ZOLTAN_ENABLED
4444

45-
RUN --mount=target=/vt \
46-
<<EOF
47-
if [ -d vt/docker-output/build/ccache ]; then
48-
cp -r vt/docker-output/build/ccache /build
49-
ccache -c
50-
ccache -s
51-
fi
52-
EOF
45+
ARG IMAGE
46+
ARG CACHE_ID=${IMAGE}
5347

5448
ENV GIT_BRANCH=${GIT_BRANCH}
5549

56-
RUN --mount=target=/vt,rw \
50+
RUN --mount=type=cache,id=${CACHE_ID},target=/build/ccache \
51+
--mount=type=cache,id=BUILD-${CACHE_ID},target=/build/vt \
52+
--mount=target=/vt,rw \
5753
if [ "${VT_TEST_SPACK}" = "1" ]; then \
5854
apt update -y -q && apt install -y -q libssl-dev unzip && \
5955
/vt/ci/test_spack_package.sh; \

ci/test_cpp.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ then
1818
lcov --capture --directory . --output-file coverage.info
1919
lcov --remove coverage.info '/usr/*' --output-file coverage.info
2020
lcov --list coverage.info
21-
pushd "$VT"
22-
bash <(curl -s https://codecov.io/bash) -f "${VT_BUILD}/coverage.info" || echo "Codecov did not collect coverage reports"
23-
popd
2421
fi
2522

2623
if test "${VT_CI_TEST_LB_SCHEMA:-0}" -eq 1

docker-bake.hcl

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -174,32 +174,14 @@ target "vt-build" {
174174
target = "build"
175175
context = "."
176176
dockerfile = "ci/docker/vt.dockerfile"
177-
output = [
178-
{
179-
type = "local"
180-
dest = "docker-output"
181-
}
182-
]
177+
183178
platforms = [
184179
"linux/amd64",
185180
# "linux/arm64"
186181
]
187182
ulimits = [
188183
"core=0"
189184
]
190-
# FIXME: verify that caching works as intended
191-
# cache-from = [
192-
# {
193-
# type = "local",
194-
# src = "~/ccache"
195-
# }
196-
# ]
197-
# cache-to = [
198-
# {
199-
# type = "local",
200-
# dest = "~/ccache"
201-
# }
202-
# ]
203185
}
204186

205187
target "vt-build-all" {

0 commit comments

Comments
 (0)