Skip to content

Commit ec1e960

Browse files
author
bryn
committed
Fix build for windows and osx.
OSX had an issue with max UDP packet size Windows has all sorts of file related issues. On the plus side the special handling for windows in circle has been removed as the root cause of the hang on windows is now known to be: rust-lang/rust#45572
1 parent 6be0629 commit ec1e960

File tree

6 files changed

+65
-57
lines changed

6 files changed

+65
-57
lines changed

.circleci/config.yml

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ parameters:
2727
cache_version:
2828
type: string
2929
# increment that one to invalidate all the caches
30-
default: v3.{{ checksum "rust-toolchain.toml" }}
30+
default: v5.{{ checksum "rust-toolchain.toml" }}
3131

3232
commands:
3333
initialize_submodules:
@@ -88,6 +88,12 @@ commands:
8888
- run:
8989
name: Assert npm version
9090
command: test "$(npm --version)" = "${NPM_VERSION}"
91+
- run:
92+
# The jaeger exporter won't work without this
93+
name: Increase udp packet size
94+
command: |
95+
sudo sysctl net.inet.udp.maxdgram=65536
96+
sudo sysctl net.inet.udp.maxdgram
9197
linux_prepare_node_env:
9298
steps:
9399
#TODO[igni]: check for node version before we try to install it
@@ -143,33 +149,6 @@ commands:
143149
command: |
144150
if ((npm --version) -Ne "${Env:NPM_VERSION}") { exit 1 }
145151
146-
windows_prepare_test_env:
147-
steps:
148-
- restore_cache:
149-
keys:
150-
- subgraph-node-modules-v2-windows-{{ checksum "dockerfiles/federation-demo/federation-demo/package.json" }}-{{ checksum "dockerfiles/federation-demo/federation-demo/package-lock.json" }}
151-
- subgraph-node-modules-v2-windows-{{ checksum "dockerfiles/federation-demo/federation-demo/package.json" }}
152-
- run:
153-
name: npm clean-install
154-
working_directory: dockerfiles/federation-demo/federation-demo
155-
command: npm clean-install
156-
- save_cache:
157-
key: subgraph-node-modules-v2-windows-{{ checksum "dockerfiles/federation-demo/federation-demo/package.json" }}-{{ checksum "dockerfiles/federation-demo/federation-demo/package-lock.json" }}
158-
paths:
159-
- dockerfiles/federation-demo/federation-demo/node_modules
160-
161-
# TODO: normally xtask can run the federation by itself and it
162-
# works on GitHub Actions on Windows. Unfortunately it
163-
# doesn't work here on CircleCI on Windows only.
164-
- run:
165-
name: start federation-demo (background)
166-
working_directory: dockerfiles/federation-demo/federation-demo
167-
command: npm start
168-
background: true
169-
- run:
170-
name: wait for federation demo to start
171-
command: npx wait-on tcp:4001 tcp:4002 tcp:4003 tcp:4004 tcp:4100
172-
173152
windows_prepare_rust_env:
174153
steps:
175154
- run:
@@ -501,6 +480,7 @@ jobs:
501480
condition:
502481
equal: [*rust_windows_executor, << parameters.platform >>]
503482
steps:
483+
- windows_install_baseline
504484
- windows_prepare_node_env
505485
- windows_prepare_rust_env
506486
- windows_build_workspace
@@ -537,8 +517,8 @@ jobs:
537517
condition:
538518
equal: [*rust_windows_executor, << parameters.platform >>]
539519
steps:
520+
- windows_install_baseline
540521
- windows_prepare_node_env
541-
- windows_prepare_test_env
542522
- windows_prepare_rust_env
543523
- windows_test_workspace
544524
- when:

NEXT_CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,7 @@ Jaeger tracing end to end test including client->router->subgraphs
104104
### Router tracing span cleanup [PR #850](https://github.com/apollographql/router/pull/850)
105105
Spans generated by the Router are now aligned with plugin services.
106106

107+
### Simplified CI for windows [PR #850](https://github.com/apollographql/router/pull/850)
108+
All windows processes are spawned via xtask rather than a separate CircleCI stage.
109+
107110
## 📚 Documentation

apollo-router/tests/common.rs

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use opentelemetry::propagation::TextMapPropagator;
66
use opentelemetry::sdk::trace::Tracer;
77
use opentelemetry_http::HttpClient;
88
use serde_json::Value;
9-
use std::path::Path;
9+
use std::path::{Path, PathBuf};
1010
use std::process::{Child, Command, Stdio};
1111
use std::time::Duration;
1212
use tower::BoxError;
@@ -39,25 +39,29 @@ impl TracingTest {
3939
tracing::subscriber::set_global_default(subscriber).unwrap();
4040
global::set_text_map_propagator(propagator);
4141

42-
let config_location = Path::new("apollo-router/src/testdata").join(config_location);
43-
tracing::debug!(
44-
"starting router with config: {}",
45-
config_location.to_string_lossy()
46-
);
42+
let router_location = if cfg!(windows) {
43+
PathBuf::from_iter(["..", "target", "debug", "router.exe"])
44+
} else {
45+
PathBuf::from_iter(["..", "target", "debug", "router"])
46+
};
47+
48+
let mut command = Command::new(router_location);
49+
command = set_command_log(command);
4750

4851
Self {
49-
router: Command::new("target/debug/router")
50-
.current_dir("..")
51-
.env("RUST_LOG", "INFO")
52+
router: command
5253
.args([
5354
"--hr",
5455
"--config",
55-
&config_location.to_string_lossy().to_string(),
56+
&PathBuf::from_iter(["..", "apollo-router", "src", "testdata"])
57+
.join(config_location)
58+
.to_string_lossy()
59+
.to_string(),
5660
"--supergraph",
57-
"examples/graphql/local.graphql",
61+
&PathBuf::from_iter(["..", "examples", "graphql", "local.graphql"])
62+
.to_string_lossy()
63+
.to_string(),
5864
])
59-
.stdout(Stdio::piped())
60-
.stderr(Stdio::piped())
6165
.spawn()
6266
.expect("Router should start"),
6367
}
@@ -103,6 +107,20 @@ impl TracingTest {
103107
}
104108
}
105109

110+
#[cfg(windows)]
111+
fn set_command_log(mut command: Command) -> Command {
112+
// Pipe to NULL is required for Windows to not hang
113+
// https://github.com/rust-lang/rust/issues/45572
114+
command.stdout(Stdio::null()).stderr(Stdio::null());
115+
command
116+
}
117+
118+
#[cfg(not(windows))]
119+
fn set_command_log(mut command: Command) -> Command {
120+
command.stdout(Stdio::piped()).stderr(Stdio::piped());
121+
command
122+
}
123+
106124
impl Drop for TracingTest {
107125
fn drop(&mut self) {
108126
self.router.kill().expect("router could not be halted");

xtask/src/commands/test.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,7 @@ impl Test {
3434
);
3535

3636
// NOTE: it worked nicely on GitHub Actions but it hangs on CircleCI on Windows
37-
let _guard: Box<dyn std::any::Any> = if !std::env::var("CIRCLECI")
38-
.ok()
39-
.unwrap_or_default()
40-
.is_empty()
41-
&& cfg!(windows)
42-
{
43-
eprintln!("Not running federation-demo because it makes the step hang on Circle CI.");
44-
Box::new(())
45-
} else if self.no_demo {
37+
let _guard: Box<dyn std::any::Any> = if self.no_demo {
4638
eprintln!("Flag --no-demo is the default now. Not running federation-demo.");
4739
Box::new(())
4840
} else if !self.with_demo {

xtask/src/federation_demo.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,14 @@ impl FederationDemoRunner {
2727

2828
eprintln!("Running federation-demo in background...");
2929
let mut command = Command::new(which::which("npm")?);
30+
31+
// Pipe to NULL is required for Windows to not hang
32+
// https://github.com/rust-lang/rust/issues/45572
3033
command
3134
.current_dir(&self.path)
3235
.args(["run", "start"])
33-
.stdout(Stdio::piped())
34-
.stderr(Stdio::piped());
36+
.stdout(Stdio::null())
37+
.stderr(Stdio::null());
3538
let task = BackgroundTask::new(command)?;
3639

3740
eprintln!("Waiting for federation-demo services and gateway to be ready...");

xtask/src/jaeger.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::*;
22
use anyhow::Result;
33
use camino::Utf8PathBuf;
4-
use std::path::Path;
4+
use std::path::PathBuf;
55
use std::{
66
process::{Command, Stdio},
77
thread::sleep,
@@ -21,11 +21,23 @@ impl JaegerRunner {
2121

2222
pub fn start_background(&self) -> Result<BackgroundTask> {
2323
eprintln!("Running jaeger in background...");
24-
let mut command = Command::new(Path::new("jaeger/jaeger-all-in-one"));
24+
let jaeger_path = if cfg!(windows) {
25+
PathBuf::from_iter(["jaeger", "jaeger-all-in-one.exe"])
26+
} else {
27+
PathBuf::from_iter(["jaeger", "jaeger-all-in-one"])
28+
};
29+
30+
let mut command = Command::new(jaeger_path);
31+
32+
// Pipe to NULL is required for Windows to not hang
33+
// https://github.com/rust-lang/rust/issues/45572
2534
command
2635
.current_dir(&self.path)
27-
.stdout(Stdio::piped())
28-
.stderr(Stdio::piped());
36+
.stdout(Stdio::null())
37+
.stderr(Stdio::null());
38+
39+
if cfg!(windows) {}
40+
2941
let task = BackgroundTask::new(command)?;
3042

3143
loop {

0 commit comments

Comments
 (0)