Skip to content

Commit

Permalink
build: add docker runner for mac users to run tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TheButlah committed Jan 29, 2025
1 parent 9a58dd1 commit f332df9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@
[net]
# libgit2 doesn't handle git credentials well
git-fetch-with-cli = true

# Run cargo with `RUSTFLAGS='--cfg docker_runner'`
[target.'cfg(docker_runner)']
runner = "docker/cargo-runner.sh"
21 changes: 21 additions & 0 deletions docker/cargo-runner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
# Allows running tests inside docker. Takes care of linux-only dependencies and avoids
# the need to emulate the architecture.

set -o pipefail -eu

PROGRAM=$1; shift

main() {
local -r absolute_path="$(realpath ${PROGRAM})"

docker run \
--rm \
-v "${absolute_path}:/mnt/program" \
-w /mnt \
-e RUST_BACKTRACE \
-it debian:latest \
/mnt/program $@
}

main $@

0 comments on commit f332df9

Please sign in to comment.