Skip to content

Commit

Permalink
Fix MUSL canary builds (#9894)
Browse files Browse the repository at this point in the history
* Build for all targets on CI

* Add secrets inherit to CI job

* Test without monitoring crate

* Try to fix features declaration

* Remove unused parking_lot dependency from monitoring

* Remove feature-gate from libc dep

* Remove libc dependency

* Don't tag CI build releases

* Try to get more information about crashing binaries

* Try to link to pthread on MUSL

* Try to fix linker command

* Remove ldd call

* Try to change linker flags

* Remove all minidumper from MUSL builds

---------

Co-authored-by: pyamada (RDE) <pyamada@atlassian.com>
  • Loading branch information
yamadapc and pyamada-atlassian authored Aug 5, 2024
1 parent de50e27 commit 4ce0f6e
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 24 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,13 @@ jobs:
status: ${{ job.status }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
env_url: ${{ steps.vercel-action.outputs.preview-url }}

run-release-builds:
name: Build for all architectures and smoke-test
uses: ./.github/workflows/release.yml
secrets: inherit
with:
profile: canary
release-command: |
echo "Skipping release as this is a CI build"
type: canary
6 changes: 0 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 1 addition & 8 deletions crates/node-bindings/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ edition = "2021"
crate-type = ["cdylib"]

[features]
canary = ["sentry", "whoami", "rustls", "minidumper", "crash-handler", "parcel_monitoring/canary"]

rustls = ["sentry/rustls"]
openssl = ["sentry/native-tls"]
canary = ["parcel_monitoring/canary"]

[dependencies]
parcel = { path = "../parcel" }
Expand Down Expand Up @@ -56,10 +53,6 @@ oxipng = "8.0.0"
rayon = "1.7.0"

# Crash reporting dependencies
sentry = { version = "0.32.2", optional = true, default-features = false, features = ["anyhow", "backtrace", "contexts", "debug-images", "panic", "reqwest"] }
minidumper = { version = "0.8.3", optional = true }
crash-handler = { version = "0.6.2", optional = true }
whoami = { version = "1.5.1", optional = true }

[target.'cfg(target_arch = "wasm32")'.dependencies]
getrandom = { version = "0.2", features = ["custom"], default-features = false }
Expand Down
4 changes: 2 additions & 2 deletions crates/parcel_monitoring/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ required-features = ["canary"]

[dependencies]
anyhow = "1.0.86"
parking_lot = "0.12.3"
thiserror = "1.0.63"
tracing = "0.1.40"
tracing-subscriber = "0.3.18"
Expand All @@ -26,9 +25,10 @@ serde_json = "1.0.122"

whoami = { version = "1.5.1", optional = true }
sentry = { version = "0.32.2", optional = true, default-features = false, features = ["anyhow", "backtrace", "contexts", "debug-images", "panic", "reqwest"] }

[target.'cfg(not(target_env = "musl"))'.dependencies]
crash-handler = { version = "0.6.2", optional = true }
minidumper = { version = "0.8.3", optional = true }

[dev-dependencies]
cfg-if = "1.0.0"
libc = "0.2.155"
2 changes: 1 addition & 1 deletion crates/parcel_monitoring/examples/sample_usage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ fn main() {
tracing::info!(%pid, "Simulating crash");
cfg_if::cfg_if! {
if #[cfg(any(target_os = "linux", target_os = "android"))] {
handler.simulate_signal(libc::SIGALRM as _);
handler.simulate_signal(14 /* SIGALRM */);
} else if #[cfg(windows)] {
handler.simulate_exception(None);
} else if #[cfg(target_os = "macos")] {
Expand Down
14 changes: 7 additions & 7 deletions crates/parcel_monitoring/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
use std::sync::Mutex;
use std::time::Duration;

#[cfg(feature = "canary")]
#[cfg(all(feature = "canary", not(target_env = "musl")))]
pub use crash_reporter::CrashReporterOptions;
#[cfg(feature = "canary")]
pub use sentry_integration::SentryOptions;
pub use tracer::TracerMode;

#[cfg(feature = "canary")]
#[cfg(all(feature = "canary", not(target_env = "musl")))]
mod crash_reporter;
mod from_env;
#[cfg(feature = "canary")]
Expand All @@ -25,13 +25,13 @@ pub static MONITORING_GUARD: Mutex<Option<MonitoringGuard>> = Mutex::new(None);
pub struct MonitoringGuard {
#[cfg(feature = "canary")]
sentry: Option<sentry::ClientInitGuard>,
#[cfg(feature = "canary")]
#[cfg(all(feature = "canary", not(target_env = "musl")))]
crash_handler: Option<crash_handler::CrashHandler>,
tracer: Option<tracer::Tracer>,
}

impl MonitoringGuard {
#[cfg(feature = "canary")]
#[cfg(all(feature = "canary", not(target_env = "musl")))]
pub fn crash_handler(&self) -> Option<&crash_handler::CrashHandler> {
self.crash_handler.as_ref()
}
Expand All @@ -42,7 +42,7 @@ pub struct MonitoringOptions {
pub tracing_options: Option<TracerMode>,
#[cfg(feature = "canary")]
pub sentry_options: Option<SentryOptions>,
#[cfg(feature = "canary")]
#[cfg(all(feature = "canary", not(target_env = "musl")))]
pub crash_reporter_options: Option<CrashReporterOptions>,
}

Expand All @@ -52,7 +52,7 @@ impl MonitoringOptions {
tracing_options: TracerMode::from_env()?,
#[cfg(feature = "canary")]
sentry_options: SentryOptions::from_env()?,
#[cfg(feature = "canary")]
#[cfg(all(feature = "canary", not(target_env = "musl")))]
crash_reporter_options: CrashReporterOptions::from_env()?,
})
}
Expand All @@ -74,7 +74,7 @@ pub fn initialize_monitoring(options: MonitoringOptions) -> anyhow::Result<()> {
if let Some(sentry_options) = options.sentry_options {
guard.sentry = Some(sentry_integration::init_sentry(sentry_options)?);
}
#[cfg(feature = "canary")]
#[cfg(all(feature = "canary", not(target_env = "musl")))]
if let Some(crash_reporter_options) = options.crash_reporter_options {
guard.crash_handler = Some(crash_reporter::init_crash_reporter(crash_reporter_options)?);
}
Expand Down

0 comments on commit 4ce0f6e

Please sign in to comment.