Skip to content

Commit cb4676a

Browse files
fix: build docker image even if the dockerfile hasn't changed
* Update README to showcase how to write tests using the macro instead * Update README to note about the ws:// prefix. * Update github actions to use the rust action instead of setting the stable toolchain manually, and use `DOCKER_BUILD` flag at least once before the tests.
1 parent 3729253 commit cb4676a

File tree

3 files changed

+22
-20
lines changed

3 files changed

+22
-20
lines changed

.github/workflows/tests.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,18 @@ jobs:
88
runs-on: ubuntu-latest
99
steps:
1010
- uses: actions/checkout@v1
11-
- name: Install stable
12-
run: rustup toolchain install stable
1311
- name: Install protoc
14-
run: sudo apt-get install protobuf-compiler
12+
run: sudo apt-get update -qqq && sudo apt-get install -y protobuf-compiler
13+
- name: Install latest nightly
14+
uses: actions-rs/toolchain@v1
15+
with:
16+
toolchain: stable
17+
override: true
18+
components: rustfmt, clippy
1519
- name: Build
16-
run: cargo build --all
20+
run: DOCKER_BUILD=1 cargo build --all
1721
- name: Run tests
18-
run: DOCKER_BUILD=1 cargo test
22+
run: DOCKER_BUILD=1 cargo test -- --test-threads=1
1923

2024

2125
fmt:

README.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,21 @@ snippet.
3030
```rust
3131
#[cfg(test)]
3232
mod test {
33-
use testcontainers::clients;
34-
use testcontainers::core::WaitFor;
35-
use testcontainers::images::generic::GenericImage;
33+
use crate::new_nym_client;
3634
#[tokio::test]
3735
async fn test_with_nym() {
38-
let docker_client = clients::Cli::default();
39-
let nym_ready_message = WaitFor::message_on_stderr("Client startup finished!");
40-
let nym_dialer_image = GenericImage::new("nym", "latest")
41-
.with_env_var("NYM_ID", "test_connection_dialer")
42-
.with_wait_for(nym_ready_message.clone())
43-
.with_exposed_port(1977);
44-
let dialer_container = docker_client.run(nym_dialer_image);
45-
let dialer_port = dialer_container.get_host_port_ipv4(1977);
46-
let dialer_uri = format!("ws://0.0.0.0:{dialer_port}");
36+
37+
let nym_id = "test_transport_connection_dialer";
38+
#[allow(unused)]
39+
let dialer_uri: String;
40+
new_nym_client!(nym_id, dialer_uri);
41+
todo!("Now you can use the dialer_uri to make requests.")
4742
}
4843
}
4944
```
5045

5146
One can create as many of these as needed, limited only by the server resources.
47+
48+
**NOTE**: When using a URI for connections, ensure that you're prefixing the
49+
URI with the `ws://` protocol type, otherwise the nym client assumes http and
50+
crashes unceremoniously.

build.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
use std::env;
22
use std::process::Command;
3+
34
fn main() {
4-
println!("cargo:rerun-if-changed=Dockerfile.nym");
5-
let docker_build = env::var("DOCKER_BUILD").is_ok();
6-
if docker_build {
5+
if env::var("DOCKER_BUILD").is_ok() {
76
let output = Command::new("docker")
87
.arg("build")
98
.arg("-t")

0 commit comments

Comments
 (0)