Skip to content

Commit 550cc5f

Browse files
author
Michiel de Jong
committed
fix(ci): isolate the WASI plugin build from musl compiler settings
1 parent bae1642 commit 550cc5f

3 files changed

Lines changed: 43 additions & 9 deletions

File tree

.dagger/src/index.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,12 +1265,9 @@ export class AtomicServer {
12651265
// `rustTest()` already installs this target for the same reason —
12661266
// same fix, applied where the e2e server binary is actually built.
12671267
const containerReadyToBuild = wasmPluginsEnabled
1268-
? containerWithAssets.withExec([
1269-
'rustup',
1270-
'target',
1271-
'add',
1272-
'wasm32-wasip2',
1273-
])
1268+
? containerWithAssets
1269+
.withExec(['rustup', 'target', 'add', 'wasm32-wasip2'])
1270+
.withEnvVariable('ATOMICSERVER_REQUIRE_PLUGIN_RUNTIME', 'true')
12741271
: containerWithAssets;
12751272

12761273
return (
@@ -1388,6 +1385,7 @@ export class AtomicServer {
13881385
return (
13891386
this.rustChecksContainer()
13901387
.withExec(['rustup', 'target', 'add', 'wasm32-wasip2'])
1388+
.withEnvVariable('ATOMICSERVER_REQUIRE_PLUGIN_RUNTIME', 'true')
13911389
// Persist nextest in the shared cargo-bin volume. Previously the
13921390
// curl install sat *after* the source mount, so every Rust source
13931391
// change re-downloaded it. The `linux-musl` URL is required: the

browser/e2e/tests/plugins.spec.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,18 @@ test.describe('plugins', () => {
3636
await expect(
3737
setup.getByRole('button', { name: 'Install demo pets', exact: true }),
3838
).toBeVisible();
39-
await setup
40-
.getByRole('button', { name: 'Install demo pets', exact: true })
41-
.click();
39+
const [preview] = await Promise.all([
40+
page.waitForResponse(
41+
response =>
42+
response.url().endsWith('/plugin-run') &&
43+
response.request().method() === 'POST',
44+
{ timeout: 45_000 },
45+
),
46+
setup
47+
.getByRole('button', { name: 'Install demo pets', exact: true })
48+
.click(),
49+
]);
50+
expect(preview.ok(), await preview.text()).toBe(true);
4251

4352
const review = page.locator('dialog[open]');
4453
// Installing walks pluginClassesFor, two ensureSchema calls, three

server/build.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,18 +595,27 @@ fn is_newer_than_dist(dir_entry: &walkdir::DirEntry, dist_time: Duration) -> boo
595595
/// server-side plugins is a degraded server, not a broken build, and failing
596596
/// here would block anyone who never touches plugins. The absence is reported
597597
/// at the point someone tries to use it, not swallowed.
598+
/// CI sets ATOMICSERVER_REQUIRE_PLUGIN_RUNTIME=true to fail the build instead
599+
/// of allowing this degradation in jobs that exercise server-side plugins.
598600
fn build_plugin_runtime() {
599601
const TARGET: &str = "wasm32-wasip2";
600602
const CRATE: &str = "atomic-plugin-runtime";
601603

602604
println!("cargo:rerun-if-changed=../plugin-runtime/src");
603605
println!("cargo:rerun-if-changed=../plugin-runtime/wit");
606+
println!("cargo:rerun-if-changed=../plugin-runtime/Cargo.toml");
604607
println!("cargo:rerun-if-env-changed=ATOMICSERVER_SKIP_PLUGIN_RUNTIME");
608+
println!("cargo:rerun-if-env-changed=ATOMICSERVER_REQUIRE_PLUGIN_RUNTIME");
609+
let required = std::env::var("ATOMICSERVER_REQUIRE_PLUGIN_RUNTIME").is_ok_and(|v| v == "true");
605610

606611
let out_dir = std::env::var("OUT_DIR").expect("OUT_DIR is set by cargo");
607612
let embedded = PathBuf::from(&out_dir).join("plugin_runtime.wasm");
608613

609614
if std::env::var("ATOMICSERVER_SKIP_PLUGIN_RUNTIME").is_ok_and(|v| v == "true") {
615+
assert!(
616+
!required,
617+
"the plugin runtime cannot be both required and skipped"
618+
);
610619
p!("ATOMICSERVER_SKIP_PLUGIN_RUNTIME is set, skipping the plugin runtime.");
611620
let _ = std::fs::write(&embedded, []);
612621

@@ -624,6 +633,10 @@ fn build_plugin_runtime() {
624633
.unwrap_or(false);
625634

626635
if !has_target {
636+
assert!(
637+
!required,
638+
"the required {TARGET} plugin runtime target is unavailable"
639+
);
627640
p!("{TARGET} is unknown to this toolchain; plugins will not run server-side.");
628641
let _ = std::fs::write(&embedded, []);
629642

@@ -640,6 +653,16 @@ fn build_plugin_runtime() {
640653
.env_remove("CARGO_ENCODED_RUSTFLAGS")
641654
.env_remove("RUSTFLAGS")
642655
.env_remove("CARGO_BUILD_TARGET")
656+
// rust-musl-cross exports TARGET_CC/AR for the native server.
657+
// cc-rs prefers these over the CC/AR selected by rquickjs's
658+
// WASI SDK, so leaking them compiles QuickJS with the Linux
659+
// toolchain instead of clang for WebAssembly.
660+
.env_remove("TARGET_CC")
661+
.env_remove("TARGET_CXX")
662+
.env_remove("TARGET_AR")
663+
.env_remove("TARGET_RANLIB")
664+
.env_remove("TARGET_CFLAGS")
665+
.env_remove("TARGET_CXXFLAGS")
643666
.current_dir("..")
644667
.status();
645668

@@ -658,6 +681,10 @@ fn build_plugin_runtime() {
658681
);
659682
}
660683
_ => {
684+
assert!(
685+
!required,
686+
"could not build the required {CRATE} for {TARGET}; see the nested cargo build error above"
687+
);
661688
p!(
662689
"could not build {CRATE} for {TARGET}; plugins will not run server-side. \
663690
Install the target with `rustup target add {TARGET}`.",

0 commit comments

Comments
 (0)