From da5bbf715a9646707216307c362babc22e8ae977 Mon Sep 17 00:00:00 2001 From: Max Inden Date: Wed, 23 Nov 2022 10:52:07 +0100 Subject: [PATCH 1/4] fix(ping/rust): Don't set PR ref for master build (#79) When building the `master` image we would previously mistakingly set the ref to the PR commit hash. This surfaced when testing a pull request from a fork. `master` would be pointed at the forks HEAD commit hash, but not the fork URL. Thus the build could not find the commit and would fail. See https://github.com/libp2p/rust-libp2p/pull/3154 --- ping/_compositions/rust-cross-versions.toml | 2 +- ping/rust/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ping/_compositions/rust-cross-versions.toml b/ping/_compositions/rust-cross-versions.toml index bc0829a..4f18e47 100644 --- a/ping/_compositions/rust-cross-versions.toml +++ b/ping/_compositions/rust-cross-versions.toml @@ -25,7 +25,7 @@ [groups.build_config.build_args] BINARY_NAME = '{{ .BinaryName }}' - GIT_REF = '{{ $.Env.GitReference }}' + GIT_REF = "master" {{ end }} {{ if $.Env.GitReference }} diff --git a/ping/rust/Dockerfile b/ping/rust/Dockerfile index b9455b2..238cdb5 100644 --- a/ping/rust/Dockerfile +++ b/ping/rust/Dockerfile @@ -11,7 +11,7 @@ ARG GIT_TARGET="" RUN if [ ! -z "${GIT_TARGET}" ]; then sed -i "s,^git.*,git = \"https://${GIT_TARGET}\"," ./plan/Cargo.toml; fi ARG GIT_REF="" -RUN if [ ! -z "${GIT_REF}" ]; then sed -i "s/^rev.*/rev = \"${GIT_REF}\"/" ./plan/Cargo.toml; fi +RUN if [ ! -z "${GIT_REF}" ]; then sed -i "s/^rev.*/branch = \"${GIT_REF}\"/" ./plan/Cargo.toml; fi # Build the requested binary: Cargo will update lockfile on changed manifest (i.e. if one of the above `sed`s patched it). ARG BINARY_NAME From 4f8297fd345dfee7a76ba05e73f2a2e0794f6ab0 Mon Sep 17 00:00:00 2001 From: Max Inden Date: Wed, 23 Nov 2022 15:23:51 +0100 Subject: [PATCH 2/4] fix(ping/rust): Only specify branch when building master (#80) --- ping/rust/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ping/rust/Dockerfile b/ping/rust/Dockerfile index 238cdb5..655160c 100644 --- a/ping/rust/Dockerfile +++ b/ping/rust/Dockerfile @@ -11,7 +11,7 @@ ARG GIT_TARGET="" RUN if [ ! -z "${GIT_TARGET}" ]; then sed -i "s,^git.*,git = \"https://${GIT_TARGET}\"," ./plan/Cargo.toml; fi ARG GIT_REF="" -RUN if [ ! -z "${GIT_REF}" ]; then sed -i "s/^rev.*/branch = \"${GIT_REF}\"/" ./plan/Cargo.toml; fi +RUN if [ "master" = "${GIT_REF}" ]; then sed -i "s/^rev.*/branch= \"master\"/" ./plan/Cargo.toml; elif [ ! -z "${GIT_REF}" ]; then sed -i "s/^rev.*/rev = \"${GIT_REF}\"/" ./plan/Cargo.toml; fi # Build the requested binary: Cargo will update lockfile on changed manifest (i.e. if one of the above `sed`s patched it). ARG BINARY_NAME From ddb2e4bad27b6a95b49dc98837d38545a084f84f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveira?= Date: Wed, 23 Nov 2022 14:49:54 +0000 Subject: [PATCH 3/4] ping: update Rust versions 0.45.0 and 0.46.0, (#76) to 0.45.1 and 0.46.1 respectively. --- ping/_compositions/rust.toml | 6 +++--- ping/rust/Cargo.toml | 4 ++-- ping/rust/src/bin/{testplan_0450.rs => testplan_0451.rs} | 4 ++-- ping/rust/src/bin/{testplan_0460.rs => testplan_0461.rs} | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) rename ping/rust/src/bin/{testplan_0450.rs => testplan_0451.rs} (97%) rename ping/rust/src/bin/{testplan_0460.rs => testplan_0461.rs} (97%) diff --git a/ping/_compositions/rust.toml b/ping/_compositions/rust.toml index 0dc0c03..e18cce1 100644 --- a/ping/_compositions/rust.toml +++ b/ping/_compositions/rust.toml @@ -17,12 +17,12 @@ Id = "v0.47.0" BinaryName = 'testplan_0470' [[groups]] -Id = "v0.46.0" -BinaryName = 'testplan_0460' +Id = "v0.46.1" +BinaryName = 'testplan_0461' [[groups]] Id = "v0.45.1" -BinaryName = 'testplan_0450' +BinaryName = 'testplan_0451' [[groups]] Id = "v0.44.0" diff --git a/ping/rust/Cargo.toml b/ping/rust/Cargo.toml index 4a98506..e28cf33 100644 --- a/ping/rust/Cargo.toml +++ b/ping/rust/Cargo.toml @@ -21,8 +21,8 @@ tokio-util = { version = "0.7", default-features = false, features = ["compat"] futures = "0.3.1" libp2pv0440 = { package = "libp2p", version = "0.44.0", default_features = false, features = ["websocket", "mplex", "yamux", "tcp-async-io", "ping", "noise", "dns-async-std"] } -libp2pv0450 = { package = "libp2p", version = "0.45.0", default_features = false, features = ["websocket", "mplex", "yamux", "tcp-async-io", "ping", "noise", "dns-async-std"] } -libp2pv0460 = { package = "libp2p", version = "0.46.0", default_features = false, features = ["websocket", "mplex", "yamux", "tcp-async-io", "ping", "noise", "dns-async-std"] } +libp2pv0451 = { package = "libp2p", version = "0.45.1", default_features = false, features = ["websocket", "mplex", "yamux", "tcp-async-io", "ping", "noise", "dns-async-std"] } +libp2pv0461 = { package = "libp2p", version = "0.46.1", default_features = false, features = ["websocket", "mplex", "yamux", "tcp-async-io", "ping", "noise", "dns-async-std"] } libp2pv0470 = { package = "libp2p", version = "0.47.0", default_features = false, features = ["websocket", "mplex", "yamux", "tcp-async-io", "ping", "noise", "dns-async-std"] } libp2pv0480 = { package = "libp2p", version = "0.48.0", default_features = false, features = ["websocket", "mplex", "yamux", "tcp-async-io", "ping", "noise", "dns-async-std", "rsa"] } libp2pv0490 = { package = "libp2p", version = "0.49.0", features = ["websocket", "mplex", "yamux", "tcp", "async-std", "ping", "noise", "dns", "rsa"] } diff --git a/ping/rust/src/bin/testplan_0450.rs b/ping/rust/src/bin/testplan_0451.rs similarity index 97% rename from ping/rust/src/bin/testplan_0450.rs rename to ping/rust/src/bin/testplan_0451.rs index 5f51690..5a35113 100644 --- a/ping/rust/src/bin/testplan_0450.rs +++ b/ping/rust/src/bin/testplan_0451.rs @@ -1,8 +1,8 @@ use anyhow::Result; use async_trait::async_trait; use futures::StreamExt; -use libp2pv0450::swarm::SwarmEvent; -use libp2pv0450::*; +use libp2pv0451::swarm::SwarmEvent; +use libp2pv0451::*; use std::collections::HashSet; use std::time::Duration; use testplan::{run_ping, PingSwarm}; diff --git a/ping/rust/src/bin/testplan_0460.rs b/ping/rust/src/bin/testplan_0461.rs similarity index 97% rename from ping/rust/src/bin/testplan_0460.rs rename to ping/rust/src/bin/testplan_0461.rs index 6d5f228..9caa590 100644 --- a/ping/rust/src/bin/testplan_0460.rs +++ b/ping/rust/src/bin/testplan_0461.rs @@ -1,8 +1,8 @@ use anyhow::Result; use async_trait::async_trait; use futures::StreamExt; -use libp2pv0460::swarm::SwarmEvent; -use libp2pv0460::*; +use libp2pv0461::swarm::SwarmEvent; +use libp2pv0461::*; use std::collections::HashSet; use std::time::Duration; use testplan::{run_ping, PingSwarm}; From 31a128833da19f1ded62a73296c9e1764d97ac13 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Thu, 24 Nov 2022 04:00:19 +1100 Subject: [PATCH 4/4] feat(ping/rust): Add dummy main to allow for caching of built dependencies (#78) --- ping/rust/Dockerfile | 10 +++++++++- ping/rust/src/main.rs | 3 +++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 ping/rust/src/main.rs diff --git a/ping/rust/Dockerfile b/ping/rust/Dockerfile index 655160c..9406109 100644 --- a/ping/rust/Dockerfile +++ b/ping/rust/Dockerfile @@ -4,7 +4,12 @@ WORKDIR /usr/src/testplan RUN apt-get update && apt-get install -y cmake protobuf-compiler ARG PLAN_PATH="./" -COPY ./plan/${PLAN_PATH} ./plan + +RUN mkdir -p ./plan/src +COPY ./plan/${PLAN_PATH}/src/main.rs ./plan/src/main.rs +COPY ./plan/${PLAN_PATH}/Cargo.toml ./plan/Cargo.toml +COPY ./plan/${PLAN_PATH}/Cargo.lock ./plan/Cargo.lock + RUN cd ./plan/ && cargo build # Initial build acts as a cache. ARG GIT_TARGET="" @@ -13,6 +18,9 @@ RUN if [ ! -z "${GIT_TARGET}" ]; then sed -i "s,^git.*,git = \"https://${GIT_TAR ARG GIT_REF="" RUN if [ "master" = "${GIT_REF}" ]; then sed -i "s/^rev.*/branch= \"master\"/" ./plan/Cargo.toml; elif [ ! -z "${GIT_REF}" ]; then sed -i "s/^rev.*/rev = \"${GIT_REF}\"/" ./plan/Cargo.toml; fi +COPY ./plan/${PLAN_PATH}/src/lib.rs ./plan/src/lib.rs +COPY ./plan/${PLAN_PATH}/src/bin/ ./plan/src/bin/ + # Build the requested binary: Cargo will update lockfile on changed manifest (i.e. if one of the above `sed`s patched it). ARG BINARY_NAME RUN cd ./plan/ \ diff --git a/ping/rust/src/main.rs b/ping/rust/src/main.rs new file mode 100644 index 0000000..8f55947 --- /dev/null +++ b/ping/rust/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("This is a dummy main file that is used for creating a cache layer inside the docker container.") +}