Skip to content

Commit b04809b

Browse files
authored
ci: replace use of cargo cross for centos7 tests (#1675)
# What does this PR do? The Centos7 tests we run uses [cargo cross](https://github.com/cross-rs/cross). However, we don't actually do any cross-compilation. The host is `x86_64` and the build target is `x86_64-unknown-linux-gnu`, the same architecture. What this test is doing is running tests for the `x86_64-unknown-linux-gnu` build in a CentOS7 environment with the older 2.17 glibc. Cross makes it easier to leverage the centOS7 docker container to run tests, but isn't really necessary. Using cargo cross means we can can't use nextest as the test runner. Without nextest we don't get process isolation for tests and we can't generate a junit.xml file to upload to CI Viz / test optimization. We can just handle spinning up the docker container ourselves. # Motivation What inspired you to submit this pull request? # Additional Notes The nextest binary needs to be the musl variant since the regular version requires glibc 2.25+, which isn't available in CentOS7 As a future enhancement we should look into not building the docker image on every run. # How to test the change? Observe the CI runs Co-authored-by: edmund.kump <edmund.kump@datadoghq.com>
1 parent 9d2d0bb commit b04809b

File tree

2 files changed

+63
-5
lines changed

2 files changed

+63
-5
lines changed

.github/workflows/test.yml

Lines changed: 60 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ jobs:
298298
.\build-profiling.ps1
299299
300300
cross-centos7:
301-
name: build and test using cross - on centos7
301+
name: Test x86_64-unknown-linux-gnu on centOS7 docker image
302302
runs-on: ubuntu-latest
303303
concurrency:
304304
group: ci-${{ github.ref }}-cross-centos7
@@ -323,10 +323,65 @@ jobs:
323323
with:
324324
cache-targets: true # cache build artifacts
325325
cache-bin: true # cache the ~/.cargo/bin directory
326-
- run: cargo install cross || true
327-
- run: cross build --workspace --target x86_64-unknown-linux-gnu --exclude builder
328-
- run: cross test --workspace --features libdd-crashtracker/generate-unit-test-files --target x86_64-unknown-linux-gnu --exclude builder -- --skip "::single_threaded_tests::" --skip "tracing_integration_tests::"
329-
- run: cross test --workspace --features libdd-crashtracker/generate-unit-test-files --target x86_64-unknown-linux-gnu --exclude builder --exclude bin_tests -- --skip "::tests::" --skip "::api_tests::" --test-threads 1 --skip "tracing_integration_tests::"
326+
- name: Build CentOS 7 Docker image
327+
run: docker build -t libdatadog-centos7 -f tools/docker/Dockerfile.centos .
328+
- name: "cargo nextest run (centos7)"
329+
# Run docker as a user, not the default root
330+
# Mount and use the runner's toolchain as it's the same arch
331+
# exclude tracing integration tests since they require docker in docker to run a test-agent
332+
run: >-
333+
docker run --rm
334+
--user "$(id -u):$(id -g)"
335+
-v "${{ github.workspace }}:/workspace"
336+
-v "${CARGO_HOME:-$HOME/.cargo}:/usr/local/cargo"
337+
-v "${RUSTUP_HOME:-$HOME/.rustup}:/usr/local/rustup"
338+
-e CARGO_HOME=/usr/local/cargo
339+
-e RUSTUP_HOME=/usr/local/rustup
340+
-e PATH=/usr/local/cargo/bin:/usr/local/rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin:/opt/rh/devtoolset-11/root/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
341+
-w /workspace
342+
libdatadog-centos7
343+
cargo nextest run --workspace --features libdd-crashtracker/generate-unit-test-files
344+
--exclude builder --profile ci
345+
-E '!test(tracing_integration_tests::)'
346+
- name: Add file attributes to JUnit XML
347+
if: success() || failure()
348+
run: cargo run --bin add_junit_file_attributes -- target/nextest/ci/junit.xml
349+
- name: Report Test Results
350+
if: success() || failure()
351+
uses: mikepenz/action-junit-report@db71d41eb79864e25ab0337e395c352e84523afe # 4.3.1
352+
with:
353+
report_paths: "target/nextest/ci/junit.xml"
354+
check_name: "[centos7] test report"
355+
include_passed: true
356+
- name: Upload test results to Datadog
357+
if: success() || failure()
358+
run: |
359+
URL="https://github.com/DataDog/datadog-ci/releases/download/v4.2.2/datadog-ci_linux-x64"
360+
OUTPUT="datadog-ci"
361+
EXPECTED_CHECKSUM="3e1e9649d15d3feacced89ec90de66151046a58c7844217e4112362ad8dbf8d1"
362+
363+
echo "Downloading datadog-ci from $URL"
364+
curl -L --fail --retry 3 -o "$OUTPUT" "$URL"
365+
chmod +x "$OUTPUT"
366+
367+
ACTUAL_CHECKSUM=$(sha256sum "$OUTPUT" | cut -d' ' -f1)
368+
echo "Expected checksum: $EXPECTED_CHECKSUM"
369+
echo "Actual checksum: $ACTUAL_CHECKSUM"
370+
371+
if [ "$ACTUAL_CHECKSUM" != "$EXPECTED_CHECKSUM" ]; then
372+
echo "Checksum verification failed!"
373+
exit 1
374+
fi
375+
echo "Checksum verification passed"
376+
377+
./"$OUTPUT" junit upload \
378+
--service libdatadog \
379+
--env ci \
380+
--logs \
381+
--tags arch:${{ runner.arch }},os:Linux,platform:centos7 \
382+
target/nextest/ci/junit.xml
383+
env:
384+
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
330385

331386
ffi_bake:
332387
strategy:

tools/docker/Dockerfile.centos

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@ RUN sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo \
1616
&& yum clean all
1717

1818
ENV PATH="/opt/rh/devtoolset-11/root/usr/bin:$PATH"
19+
20+
# use the musl binary for nextest since glibc isn't new enough on CentOS7 for nextest
21+
RUN curl -LsSf https://get.nexte.st/0.9.96/linux-musl | tar zxf - -C /usr/local/bin

0 commit comments

Comments
 (0)