From a14491cbca8721479d84abc468eaa09b9459b122 Mon Sep 17 00:00:00 2001 From: Daniel Noland Date: Mon, 28 Oct 2024 20:34:39 -0600 Subject: [PATCH] debug --- .github/workflows/sterile-build-and-test.yml | 54 ++++++++++++++++---- justfile | 47 ++++++++++------- 2 files changed, 72 insertions(+), 29 deletions(-) diff --git a/.github/workflows/sterile-build-and-test.yml b/.github/workflows/sterile-build-and-test.yml index 2f7b21bd..c5fdc000 100644 --- a/.github/workflows/sterile-build-and-test.yml +++ b/.github/workflows/sterile-build-and-test.yml @@ -50,23 +50,57 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - run: just rust="${{matrix.rust}}" sterile cargo nextest run --locked --profile=debug --target=x86_64-unknown-linux-gnu - - run: just rust="${{matrix.rust}}" sterile cargo nextest run --locked --profile=debug --target=x86_64-unknown-linux-musl - - run: just rust="${{matrix.rust}}" sterile cargo nextest run --locked --profile=release --target=x86_64-unknown-linux-gnu - - run: just rust="${{matrix.rust}}" sterile cargo nextest run --locked --profile=release --target=x86_64-unknown-linux-musl + - run: just rust="${{matrix.rust}}" profile=debug target=x86_64-unknown-linux-gnu test + - run: just rust="${{matrix.rust}}" profile=debug target=x86_64-unknown-linux-musl test + - run: just rust="${{matrix.rust}}" profile=release target=x86_64-unknown-linux-gnu test + - run: just rust="${{matrix.rust}}" profile=release target=x86_64-unknown-linux-musl test - - run: just rust="${{matrix.rust}}" profile=debug target=x86_64-unknown-linux-gnu push-container - - run: just rust="${{matrix.rust}}" profile=release target=x86_64-unknown-linux-gnu push-container - - - run: just rust="${{matrix.rust}}" profile=debug target=x86_64-unknown-linux-musl push-container - - run: just rust="${{matrix.rust}}" profile=release target=x86_64-unknown-linux-musl push-container + - run: just rust="${{matrix.rust}}" profile=debug target=x86_64-unknown-linux-gnu report + if: ${{ always() }} + - run: just rust="${{matrix.rust}}" profile=debug target=x86_64-unknown-linux-musl report + if: ${{ always() }} + - run: just rust="${{matrix.rust}}" profile=release target=x86_64-unknown-linux-gnu report + if: ${{ always() }} + - run: just rust="${{matrix.rust}}" profile=release target=x86_64-unknown-linux-musl report + if: ${{ always() }} - uses: actions/upload-artifact@v4 if: ${{ always() }} with: name: 'rust-${{matrix.rust}}-test-results' - path: test-results + path: target/nextest + + - name: Setup tmate session for debug + if: ${{ failure() }} + uses: mxschmitt/action-tmate@v3 + timeout-minutes: 30 + with: + limit-access-to-actor: true + push: + runs-on: + - lab + strategy: + fail-fast: false + matrix: + dpdk_sys: + - main + rust: + - stable + - nightly + steps: + - name: login to ghcr.io + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: "${{ github.actor }}" + password: "${{ secrets.GITHUB_TOKEN }}" + - name: install just + uses: extractions/setup-just@v2 + with: + just-version: ${{env.just}} + - name: Checkout + uses: actions/checkout@v4 - name: Setup tmate session for debug if: ${{ failure() }} uses: mxschmitt/action-tmate@v3 diff --git a/justfile b/justfile index a0c161dc..e34b7318 100644 --- a/justfile +++ b/justfile @@ -163,14 +163,14 @@ compile-env *args: fill-out-dev-env-template tmp_link="$(mktemp -p "$(pwd)/sterile" -d --suffix=.compile-env.link)" declare -r tmp_link cleanup() { - rm -r "${tmp_link}" + rm -fr "${tmp_link}" } trap cleanup EXIT - declare tmp_targetdir - tmp_targetdir="$(pwd)/sterile/target" - declare -r tmp_targetdir - rm -fr "${tmp_targetdir}" - mkdir -p "${tmp_targetdir}" + declare CARGO_TARGET_DIR + CARGO_TARGET_DIR="$(pwd)/target" + declare -r CARGO_TARGET_DIR + rm -fr "${CARGO_TARGET_DIR}" + mkdir -p "${CARGO_TARGET_DIR}" ln -s /bin "${tmp_link}/bin" ln -s /lib "${tmp_link}/lib" ln -s /sysroot "${tmp_link}/sysroot" @@ -179,14 +179,15 @@ compile-env *args: fill-out-dev-env-template --rm \ --name dataplane-compile-env \ --network="{{ _network }}" \ - --env DOCKER_HOST="${DOCKER_HOST}" \ + --env DOCKER_HOST \ + --env CARGO_TARGET_DIR \ --tmpfs "/tmp:uid=$(id -u),gid=$(id -g),nodev,noexec,nosuid" \ --mount "type=tmpfs,destination=/home/${USER:-runner},tmpfs-mode=1777" \ --mount "type=bind,source=$(pwd),destination=$(pwd),bind-propagation=rprivate" \ --mount "type=bind,source=${tmp_link},destination=$(pwd)/compile-env,bind-propagation=rprivate" \ --mount "type=bind,source=$(pwd)/dev-env-template/etc/passwd,destination=/etc/passwd,readonly" \ --mount "type=bind,source=$(pwd)/dev-env-template/etc/group,destination=/etc/group,readonly" \ - --mount "type=bind,source=${tmp_targetdir},destination=$(pwd)/target,bind-propagation=rprivate" \ + --mount "type=bind,source=${CARGO_TARGET_DIR},destination=${CARGO_TARGET_DIR},bind-propagation=rprivate" \ --mount "type=bind,source={{ DOCKER_SOCK }},destination=/var/run/docker.sock" \ --user "$(id -u):$(id -g)" \ --workdir "$(pwd)" \ @@ -342,7 +343,7 @@ fill-out-dev-env-template: envsubst < dev-env-template/etc.template/passwd.template > dev-env-template/etc/passwd [group('env')] -sterile *args: (compile-env "just" "debug={{debug}}" "rust={{rust}}" "target={{target}}" "profile={{profile}}" args) +sterile *args: (compile-env "just" ("debug=" + debug) ("rust=" + rust) ("target=" + target) ("profile=" + profile) args) [script] compress *args: @@ -352,7 +353,7 @@ compress *args: [private] sterile-build: (sterile "_network=none" "cargo" "--locked" "build" ("--profile=" + profile) ("--target=" + target)) mkdir -p "artifact/{{ target }}/{{ profile }}" - cp -r "sterile/target/{{ target }}/{{ profile }}/scratch" "artifact/{{ target }}/{{ profile }}/scratch" + cp -r "${CARGO_TARGET_DIR:-sterile/target}/{{ target }}/{{ profile }}/scratch" "artifact/{{ target }}/{{ profile }}/scratch" [script] build-container: sterile-build @@ -436,7 +437,7 @@ serve-docs: [group("test")] [script] test: - declare report_dir="target/nextest/{{profile}}" + declare -r report_dir="${CARGO_TARGET_DIR:-target}/nextest/{{profile}}" mkdir -p "${report_dir}" {{ _just_debuggable_ }} PROFILE="{{ profile }}" @@ -450,18 +451,20 @@ test: esac [ -z "${RUSTFLAGS:-}" ] && declare -rx RUSTFLAGS="${RUSTFLAGS_DEBUG}" # >&2 echo "With RUSTFLAGS=\"${RUSTFLAGS:-}\"" - cargo +{{ rust }} nextest --profile={{profile}} run \ + cargo $(if rustup -V &>/dev/null; then echo +{{ rust }}; fi) nextest --profile={{profile}} run \ --message-format libtest-json-plus \ --locked \ --cargo-profile={{ profile }} \ --target={{ target }} \ > >(tee "$report_dir/report.json") \ 2> >(tee "$report_dir/report.log") + +[group("test")] +[script] +report: + declare -r report_dir="${CARGO_TARGET_DIR:-target}/nextest/{{profile}}" markdown-test-report "$report_dir/report.json" -o "$report_dir/report.md" - if [ -z "${GITHUB_STEP_SUMMARY:-}" ]; then - exit 0; - fi - cat <<'EOF' >> $GITHUB_STEP_SUMMARY + cat <<'EOF' >> "${report_dir}/report.md" ## Test Report > [!NOTE] @@ -471,11 +474,12 @@ test: EOF declare -rx log="$(ansi2txt < $report_dir/report.log)" - cat "$report_dir/report.md" >> $GITHUB_STEP_SUMMARY - cat >> "$GITHUB_STEP_SUMMARY" <> "${report_dir}/report.md" < - Test log + + ## Test log + \`\`\`log @@ -484,3 +488,8 @@ test: EOF + + if [ -n "${GITHUB_STEP_SUMMARY:-}" ]; then + cat $report_dir/report.md >> $GITHUB_STEP_SUMMARY + fi +