Skip to content

Commit

Permalink
feat(interop-tests): build test binary inside container (backport #3441
Browse files Browse the repository at this point in the history
…) (#3443)

Co-authored-by: Marco Munizaga <git@marcopolo.io>
  • Loading branch information
mergify[bot] and MarcoPolo authored Feb 10, 2023
1 parent 84d1081 commit ea7836b
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 17 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target
16 changes: 6 additions & 10 deletions .github/workflows/interop-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,13 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@359a70e43a0bb8a13953b04a90f76428b4959bb6 # v2.2.0
with:
shared-key: interop-tests
save-if: ${{ github.ref == 'refs/heads/master' }}
- name: Install Protoc
run: sudo apt-get install protobuf-compiler
- uses: docker/setup-buildx-action@v2
- name: Build image
run: |
cargo build --release -p interop-tests
docker build -t rust-libp2p-head --build-arg=TEST_BINARY=target/release/ping . -f interop-tests/Dockerfile
- uses: libp2p/test-plans/.github/actions/run-interop-ping-test@c9130e425d266e5b222636d61348c0f8d6b978e4
run: docker buildx build --load -t rust-libp2p-head . -f interop-tests/Dockerfile
- uses: libp2p/test-plans/.github/actions/run-interop-ping-test@482e8ac2e5d91c69d7f432d325337e2ddca39cf9
with:
test-filter: rust-libp2p-head
extra-versions: ${{ github.workspace }}/interop-tests/ping-version.json
s3-cache-bucket: libp2p-by-tf-aws-bootstrap
s3-access-key-id: ${{ vars.TEST_PLANS_BUILD_CACHE_KEY_ID }}
s3-secret-access-key: ${{ secrets.TEST_PLANS_BUILD_CACHE_KEY }}
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ members = [
"transports/uds",
"transports/websocket",
"transports/wasm-ext",
<<<<<<< HEAD
=======
"transports/webrtc",
>>>>>>> eeca244c (feat(interop-tests): build test binary inside container (#3441))
"interop-tests"
]

Expand Down
22 changes: 18 additions & 4 deletions interop-tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
3 changes: 1 addition & 2 deletions interop-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
```
Expand Down
2 changes: 1 addition & 1 deletion interop-tests/src/bin/ping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,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")
Expand Down

0 comments on commit ea7836b

Please sign in to comment.