feat(interop-tests): build test binary inside container (#3441)

Building inside the container allows Windows and MacOS users to also build this binary. Thanks to a new feature from docker, `--mount=type=cache`, rebuilding layers is fast without any additional hacks.
This commit is contained in:
Marco Munizaga
2023-02-09 22:14:25 -08:00
committed by GitHub
parent 351a166b39
commit eeca244ca5
6 changed files with 29 additions and 28 deletions

View File

@@ -1,6 +1,20 @@
FROM ubuntu:22.04
ARG TEST_BINARY
COPY $TEST_BINARY /usr/local/bin/testplan
LABEL org.opencontainers.image.source https://github.com/libp2p/rust-libp2p
# syntax=docker/dockerfile:1.5-labs
FROM rust:1.67.0
# Setup protoc. TODO this breaks reproducibility and uses an old version of protoc.
# In the future protobuf generated files will be checked in, so we can remove this
WORKDIR /protoc-setup
RUN apt-get update && apt-get install -y cmake protobuf-compiler
# Run with access to the target cache to speed up builds
WORKDIR /workspace
ADD . .
RUN --mount=type=cache,target=./target \
--mount=type=cache,target=/usr/local/cargo/registry \
cargo build --package interop-tests
RUN --mount=type=cache,target=./target \
mv ./target/debug/ping /usr/local/bin/testplan
ENV RUST_BACKTRACE=1
ENTRYPOINT ["testplan"]

View File

@@ -25,8 +25,7 @@ To run this test against all released libp2p versions you'll need to have the
(libp2p/test-plans)[https://github.com/libp2p/test-plans] checked out. Then do
the following (from the root directory of this repository):
1. Build the ping binary: `cargo build --release -p interop-tests`
1. Build the image: `docker build -t rust-libp2p-head --build-arg=TEST_BINARY=target/release/ping . -f interop-tests/Dockerfile`.
1. Build the image: `docker build -t rust-libp2p-head . -f interop-tests/Dockerfile`.
1. Build the images for all released versions in `libp2p/test-plans`: `(cd <path to >/libp2p/test-plans/multidim-interop/ && make)`.
1. Run the test:
```

View File

@@ -33,7 +33,7 @@ async fn main() -> Result<()> {
.parse::<bool>()?;
let test_timeout = env::var("test_timeout_seconds")
.unwrap_or_else(|_| "10".into())
.unwrap_or_else(|_| "180".into())
.parse::<u64>()?;
let redis_addr = env::var("redis_addr")