From a3f69715792d46630ee9091a289adb626d197b26 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Mon, 27 Oct 2025 17:49:29 +0000 Subject: [PATCH] docker: Add rust-sdk memcheck target. docker: Separate and tweak cargo cache paths. ci: Improve memcheck job targets. cargo: Add missing debug syms to bench profile. docker: Optimize layer copying. Signed-off-by: Jason Volk --- .github/workflows/main.yml | 20 ++++--- .github/workflows/test.yml | 43 ++++++++++----- Cargo.toml | 4 +- docker/Dockerfile.cargo | 19 ++++--- docker/Dockerfile.cargo.deb | 15 ++--- docker/Dockerfile.cargo.rpm | 14 +++-- docker/Dockerfile.complement | 9 --- docker/Dockerfile.matrix-rust-sdk | 67 ++++++++++------------- docker/Dockerfile.nix | 1 + docker/Dockerfile.rust | 6 -- docker/Dockerfile.source | 7 --- docker/Dockerfile.system | 3 - docker/bake.hcl | 91 +++++++++++++++++++++---------- tests/complement/results.jsonl | 1 - 14 files changed, 163 insertions(+), 137 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6f742f06..4d65854e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -20,13 +20,13 @@ jobs: name: Init runs-on: ${{matrix.runner}} env: - default_cargo_profiles: '["test", "release"]' + default_cargo_profiles: '["test", "bench", "release"]' default_feat_sets: '["none", "default", "all"]' default_rust_toolchains: '["nightly", "stable"]' default_sys_names: '["debian"]' default_sys_versions: '["testing-slim"]' default_rust_targets: '["x86_64-unknown-linux-gnu"]' - default_sys_targets: '["x86_64-v1-linux-gnu"]' + default_sys_targets: '["x86_64-v1-linux-gnu", "x86_64-v3-linux-gnu"]' default_machines: '["X64"]' outputs: @@ -38,17 +38,17 @@ jobs: sys_targets: ${{vars.SYS_TARGETS || env.default_sys_targets}} sys_versions: ${{vars.SYS_VERSIONS || env.default_sys_versions}} machines: ${{vars.MACHINES || env.default_machines}} - package: ${{vars.PACKAGE || !contains(github.ref, 'refs/pull/')}} - publish: ${{vars.PUBLISH || !contains(github.ref, 'refs/pull/')}} - build_nix: ${{vars.BUILD_NIX || !contains(github.ref, 'refs/pull/')}} - build_pkgs: ${{vars.BUILD_PKGS || github.ref == 'refs/heads/main' || contains(github.ref, 'tags/v')}} + package: ${{vars.PACKAGE != 'false'}} + publish: ${{vars.PUBLISH != 'false'}} + build_nix: ${{vars.BUILD_NIX != 'false'}} + build_pkgs: ${{vars.BUILD_PKGS || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/test' || contains(github.ref, 'tags/v')}} check_pkgs: ${{vars.CHECK_PKGS || 'false'}} - complement: ${{vars.COMPLEMENT || 'true'}} + complement: ${{vars.COMPLEMENT != 'false'}} complement_runner: 'het' docker_repo: ${{vars.DOCKER_REPO}} release_url: ${{steps.release.outputs.upload_url}} pages_url: 'https://matrix-construct.github.io/tuwunel/' - rust_sdk_integration: ${{vars.RUST_SDK_INTEGRATION || 'true'}} + rust_sdk_integ: ${{vars.RUST_SDK_INTEGRATION != 'false'}} head_msg: ${{github.event.head_commit.message || github.event.workflow_run.head_commit.message}} strategy: @@ -176,7 +176,7 @@ jobs: with: head_msg: ${{needs.init.outputs.head_msg}} build_nix: ${{fromJSON(needs.init.outputs.build_nix)}} - rust_sdk_integration: ${{fromJSON(needs.init.outputs.rust_sdk_integration)}} + rust_sdk_integ: ${{fromJSON(needs.init.outputs.rust_sdk_integ)}} complement: ${{fromJSON(needs.init.outputs.complement)}} complement_runner: ${{needs.init.outputs.complement_runner}} cargo_profiles: ${{needs.init.outputs.cargo_profiles}} @@ -222,6 +222,7 @@ jobs: if: > !failure() && !cancelled() && needs.init.outputs.package + && !contains(github.ref, 'refs/pull') && !contains(needs.init.outputs.head_msg, '[ci only it]') && !contains(needs.init.outputs.head_msg, '[ci no build]') && !contains(needs.init.outputs.head_msg, '[ci no package]') @@ -285,6 +286,7 @@ jobs: if: > !failure() && !cancelled() && needs.init.outputs.publish + && !contains(github.ref, 'refs/pull') && !contains(needs.init.outputs.head_msg, '[ci only it]') && !contains(needs.init.outputs.head_msg, '[ci no build]') && !contains(needs.init.outputs.head_msg, '[ci no package]') diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b9e9574c..aa755835 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -40,7 +40,7 @@ on: default: true complement_runner: type: string - rust_sdk_integration: + rust_sdk_integ: type: boolean default: true build_nix: @@ -81,10 +81,10 @@ jobs: && contains(fromJSON(inputs.rust_toolchains), fromJSON('["nightly"]')[0]) && contains(fromJSON(inputs.sys_targets), fromJSON('["x86_64-v1-linux-gnu"]')[0]) - name: Unit + name: Module uses: ./.github/workflows/bake.yml with: - bake_targets: '["unit", "integration"]' + bake_targets: '["unit", "integ"]' cargo_profiles: '["test"]' feat_sets: '["all"]' rust_toolchains: ${{inputs.rust_toolchains}} @@ -107,7 +107,7 @@ jobs: name: Bench uses: ./.github/workflows/bake.yml with: - bake_targets: '["unit", "integration"]' + bake_targets: '["unit", "integ"]' cargo_profiles: '["bench"]' feat_sets: '["all"]' rust_toolchains: '["nightly"]' @@ -119,7 +119,7 @@ jobs: excludes: ${{inputs.excludes}} includes: ${{inputs.includes}} - valgrind: + memcheck: if: > !contains(inputs.head_msg, '[ci only it]') && contains(fromJSON(inputs.cargo_profiles), fromJSON('["bench"]')[0]) @@ -130,8 +130,9 @@ jobs: name: Memcheck uses: ./.github/workflows/bake.yml with: - bake_targets: '["integration-valgrind"]' - cargo_profiles: '["bench"]' + #bake_targets: '["unit-valgrind", "integ-valgrind"]' + bake_targets: '["integ-valgrind"]' + cargo_profiles: '["bench"]' # use bench not release for debug syms feat_sets: '["all"]' rust_toolchains: '["nightly"]' sys_names: ${{inputs.sys_names}} @@ -139,8 +140,8 @@ jobs: rust_targets: ${{inputs.rust_targets}} sys_targets: '["x86_64-v3-linux-gnu"]' machines: ${{inputs.machines}} - excludes: ${{inputs.excludes}} includes: ${{inputs.includes}} + excludes: ${{inputs.excludes}} smoke: if: > @@ -222,6 +223,7 @@ jobs: !failure() && !cancelled() && !contains(inputs.head_msg, '[ci only it]') && !contains(inputs.head_msg, '[ci no build]') + && !contains(github.ref, 'refs/pull') && contains(fromJSON(inputs.cargo_profiles), fromJSON('["release"]')[0]) && contains(fromJSON(inputs.feat_sets), fromJSON('["all"]')[0]) && contains(fromJSON(inputs.rust_toolchains), fromJSON('["stable"]')[0]) @@ -243,45 +245,56 @@ jobs: excludes: ${{inputs.excludes}} includes: ${{inputs.includes}} - matrix-rust-sdk-integration: + rust-sdk-integ: if: > !failure() && !cancelled() && !contains(inputs.head_msg, '[ci no build]') - && inputs.rust_sdk_integration + && inputs.rust_sdk_integ && contains(fromJSON(inputs.feat_sets), fromJSON('["all"]')[0]) && contains(fromJSON(inputs.rust_toolchains), fromJSON('["nightly"]')[0]) && contains(fromJSON(inputs.rust_targets), fromJSON('["x86_64-unknown-linux-gnu"]')[0]) - && contains(fromJSON(inputs.sys_targets), fromJSON('["x86_64-v1-linux-gnu"]')[0]) name: Matrix SDK Integration needs: [smoke] uses: ./.github/workflows/bake.yml with: - bake_targets: '["matrix-rust-sdk-integration"]' + #bake_targets: '["rust-sdk-integ", "rust-sdk-valgrind"]' + bake_targets: '["rust-sdk-integ"]' cargo_profiles: ${{inputs.cargo_profiles}} feat_sets: '["all"]' rust_toolchains: '["nightly"]' sys_names: ${{inputs.sys_names}} sys_versions: ${{inputs.sys_versions}} rust_targets: '["x86_64-unknown-linux-gnu"]' - sys_targets: '["x86_64-v1-linux-gnu"]' + sys_targets: ${{inputs.sys_targets}} machines: '["X64"]' runner: ${{inputs.complement_runner}} includes: ${{inputs.includes}} artifact: > { - "matrix-rust-sdk-integration": { + "rust-sdk-integ": { "src": "/var/log/tuwunel.log", - "dst": "matrix-rust-sdk-integration.tuwunel.log", + "dst": "rust-sdk-integ.tuwunel.log", + }, + "rust-sdk-valgrind": { + "src": "/var/log/tuwunel.log", + "dst": "rust-sdk-valgrind.tuwunel.log", } } excludes: > [ + {"bake_target": "rust-sdk-valgrind", "cargo_profile": "test"}, {"feat_set": "none"}, {"feat_set": "logging"}, {"cargo_profile": "release"}, {"cargo_profile": "release-debuginfo"}, {"cargo_profile": "release-native"}, + {"cargo_profile": "test", "sys_target": "x86_64-v2-linux-gnu"}, + {"cargo_profile": "test", "sys_target": "x86_64-v3-linux-gnu"}, + {"cargo_profile": "bench", "sys_target": "x86_64-v1-linux-gnu"}, + {"cargo_profile": "bench", "sys_target": "x86_64-v2-linux-gnu"}, + {"rust_target": "aarch64-unknown-linux-gnu"}, + {"sys_target": "aarch64-v8-linux-gnu"}, ] complement: diff --git a/Cargo.toml b/Cargo.toml index 33a45fbd..fa909952 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -704,8 +704,8 @@ inherits = "release-native.build-override" #] [profile.bench] -debug = false -strip = false +debug = "limited" +strip = "none" #rustflags = [ # "-Cremark=all", # '-Ztime-passes', diff --git a/docker/Dockerfile.cargo b/docker/Dockerfile.cargo index 224853fb..abffaa72 100644 --- a/docker/Dockerfile.cargo +++ b/docker/Dockerfile.cargo @@ -12,6 +12,7 @@ ARG CARGO_TARGET_DIR ARG cargo_target_profile ARG cargo_target_artifact ARG cargo_target_share +ARG cargo_share ARG CARGO_TERM_VERBOSE=0 ARG RUST_BACKTRACE ARG JEMALLOC_OVERRIDE @@ -33,6 +34,8 @@ ARG color_args="--color always" ARG recipe_args="" ARG cargo_args="" ARG git_checkout +ARG targ_dir="${CARGO_TARGET_DIR}/${cargo_target_profile}" +ARG targ_targ_dir="${CARGO_TARGET_DIR}/${rust_target}/${cargo_target_profile}" WORKDIR / COPY --link --from=input . . @@ -43,6 +46,7 @@ WORKDIR /usr/lib/${sys_triple} COPY --link --from=rocksdb . . WORKDIR /usr/src/tuwunel +SHELL ["/bin/bash", "-c"] ENV PATH="${CARGO_HOME}/bin:$PATH" ENV CARGO_TERM_VERBOSE="${CARGO_TERM_VERBOSE}" ENV RUST_BACKTRACE="${RUST_BACKTRACE}" @@ -58,17 +62,15 @@ ENV CARGO_PROFILE_RELEASE_DEBUGINFO_DEBUG="${CARGO_PROFILE_RELEASE_DEBUGINFO_DEB ENV CARGO_PROFILE_RELEASE_DEBUGINFO_LTO="${CARGO_PROFILE_RELEASE_DEBUGINFO_LTO}" ENV CARGO_BUILD_RUSTFLAGS="${CARGO_BUILD_RUSTFLAGS}" ENV CARGO_TARGET_DIR="${CARGO_TARGET_DIR}" -ENV targ_dir="${CARGO_TARGET_DIR}/${cargo_target_profile}" -ENV targ_targ_dir="${CARGO_TARGET_DIR}/${rust_target}/${cargo_target_profile}" RUN \ --mount=type=cache,dst=${RUSTUP_HOME}/downloads,sharing=shared \ --mount=type=cache,dst=${CARGO_HOME}/registry,sharing=shared \ --mount=type=cache,dst=${CARGO_HOME}/git,sharing=shared \ ---mount=type=cache,dst=${targ_dir}/deps,id=${cargo_target_share}/deps,sharing=locked \ ---mount=type=cache,dst=${targ_dir}/build,id=${cargo_target_share}/build,sharing=locked \ ---mount=type=cache,dst=${targ_dir}/examples,id=${cargo_target_share}/examples,sharing=locked \ ---mount=type=cache,dst=${targ_dir}/incremental,id=${cargo_target_share}/incremental,sharing=locked \ ---mount=type=cache,dst=${targ_dir}/.fingerprint,id=${cargo_target_share}/fingerprint,sharing=locked \ +--mount=type=cache,dst=${targ_dir}/deps,id=${cargo_share}/deps,sharing=locked \ +--mount=type=cache,dst=${targ_dir}/build,id=${cargo_share}/build,sharing=locked \ +--mount=type=cache,dst=${targ_dir}/examples,id=${cargo_share}/examples,sharing=locked \ +--mount=type=cache,dst=${targ_dir}/incremental,id=${cargo_share}/incremental,sharing=locked \ +--mount=type=cache,dst=${targ_dir}/.fingerprint,id=${cargo_share}/fingerprint,sharing=locked \ --mount=type=cache,dst=${targ_targ_dir}/deps,id=${cargo_target_share}/deps,sharing=locked \ --mount=type=cache,dst=${targ_targ_dir}/build,id=${cargo_target_share}/build,sharing=locked \ --mount=type=cache,dst=${targ_targ_dir}/examples,id=${cargo_target_share}/examples,sharing=locked \ @@ -77,7 +79,8 @@ RUN \ < /var/log/tuwunel.log & - PID=$!; trap "sleep 10s; set +ex; kill -QUIT ${PID}; wait ${PID}" EXIT - sleep 3s + nohup ${mrsdk_testee[@]} 1> /var/log/tuwunel.log & + PID=$!; trap "sleep 10s; set +e; kill -QUIT ${PID}; wait ${PID}" EXIT + sleep "${mrsdk_startup_delay}" rustup run ${rust_toolchain} \ cargo test \ --locked \ --release \ - --color always \ - --features default \ - --target "${rust_target}" \ - --target-dir "${MRSDK_TARGET_DIR}" \ - --package matrix-sdk-integration-testing \ - ${mrsdk_test_args} \ + "--color=always" \ + "--features=default" \ + "--target=${rust_target}" \ + "--target-dir=${MRSDK_TARGET_DIR}" \ + "--package=matrix-sdk-integration-testing" \ + ${mrsdk_test_args[@]} \ -- \ - --test-threads 1 \ - --color always \ - ${mrsdk_skip_list} \ - ${mrsdk_test_opts} \ + "--color=always" \ + "--test-threads=${mrsdk_parallel}" \ + ${mrsdk_skip_list[@]} \ + ${mrsdk_test_opts[@]} \ ; EOF diff --git a/docker/Dockerfile.nix b/docker/Dockerfile.nix index 7dcbacb4..02112416 100644 --- a/docker/Dockerfile.nix +++ b/docker/Dockerfile.nix @@ -4,6 +4,7 @@ FROM input AS nix-base WORKDIR / COPY --link --from=input . . + RUN \ --mount=type=cache,dst=/nix,sharing=shared \ --mount=type=cache,dst=/root/.cache/nix,sharing=shared \ diff --git a/docker/Dockerfile.rust b/docker/Dockerfile.rust index 8dffe40a..25650b06 100644 --- a/docker/Dockerfile.rust +++ b/docker/Dockerfile.rust @@ -6,9 +6,6 @@ ARG rust_target ARG rustup_version="1.28.2" ARG rustup_profile="minimal" -WORKDIR / -COPY --link --from=input . . - WORKDIR ${RUST_HOME} RUN <