Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-noland committed Oct 29, 2024
1 parent 9f248c5 commit a14491c
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 29 deletions.
54 changes: 44 additions & 10 deletions .github/workflows/sterile-build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
47 changes: 28 additions & 19 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)" \
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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 }}"
Expand All @@ -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]
Expand All @@ -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" <<EOF
cat >> "${report_dir}/report.md" <<EOF
<details>
<summary>
Test log

## Test log

</summary>

\`\`\`log
Expand All @@ -484,3 +488,8 @@ test:
</details>

EOF

if [ -n "${GITHUB_STEP_SUMMARY:-}" ]; then
cat $report_dir/report.md >> $GITHUB_STEP_SUMMARY
fi

0 comments on commit a14491c

Please sign in to comment.