diff --git a/.github/workflows/test-suite.yml b/.github/workflows/test-suite.yml index 5b6ae513b..628ccf9a4 100644 --- a/.github/workflows/test-suite.yml +++ b/.github/workflows/test-suite.yml @@ -26,6 +26,19 @@ jobs: run: sudo npm install -g ganache-cli - name: Run tests in release run: make test-release + release-tests-and-install-macos: + runs-on: macos-latest + needs: cargo-fmt + steps: + - uses: actions/checkout@v1 + - name: Get latest version of stable Rust + run: rustup update stable + - name: Install ganache-cli + run: sudo npm install -g ganache-cli + - name: Run tests in release + run: make test-release + - name: Install Lighthouse + run: make debug-tests-ubuntu: runs-on: ubuntu-latest needs: cargo-fmt diff --git a/beacon_node/rest_api/src/metrics.rs b/beacon_node/rest_api/src/metrics.rs index b367a21be..ac6775623 100644 --- a/beacon_node/rest_api/src/metrics.rs +++ b/beacon_node/rest_api/src/metrics.rs @@ -105,6 +105,8 @@ pub fn get_prometheus( store::scrape_for_metrics(&db_path, &freezer_db_path); beacon_chain::scrape_for_metrics(&beacon_chain); + // This will silently fail if we are unable to observe the health. This is desired behaviour + // since we don't support `Health` for all platforms. if let Ok(health) = Health::observe() { set_gauge(&PROCESS_NUM_THREADS, health.pid_num_threads as i64); set_gauge(&PROCESS_RES_MEM, health.pid_mem_resident_set_size as i64); diff --git a/beacon_node/rest_api/tests/test.rs b/beacon_node/rest_api/tests/test.rs index a38d62a44..6d62a5fe3 100644 --- a/beacon_node/rest_api/tests/test.rs +++ b/beacon_node/rest_api/tests/test.rs @@ -1253,6 +1253,7 @@ mod validator_attestation { } } +#[cfg(target_os = "linux")] #[test] fn get_health() { let mut env = build_env(); diff --git a/common/rest_types/Cargo.toml b/common/rest_types/Cargo.toml index 31126aa20..c8a2d8a11 100644 --- a/common/rest_types/Cargo.toml +++ b/common/rest_types/Cargo.toml @@ -14,5 +14,7 @@ state_processing = { path = "../../consensus/state_processing" } bls = { path = "../../crypto/bls" } serde = { version = "1.0.110", features = ["derive"] } rayon = "1.3.0" + +[target.'cfg(target_os = "linux")'.dependencies] psutil = "3.1.0" procinfo = "0.4.2" diff --git a/common/rest_types/src/node.rs b/common/rest_types/src/node.rs index 9246c13d9..854cfd360 100644 --- a/common/rest_types/src/node.rs +++ b/common/rest_types/src/node.rs @@ -1,10 +1,11 @@ //! Collection of types for the /node HTTP -use procinfo::pid; -use psutil::process::Process; use serde::{Deserialize, Serialize}; use ssz_derive::{Decode, Encode}; use types::Slot; +#[cfg(target_os = "linux")] +use {procinfo::pid, psutil::process::Process}; + #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Encode, Decode)] /// The current syncing status of the node. pub struct SyncingStatus { @@ -63,6 +64,12 @@ pub struct Health { } impl Health { + #[cfg(not(target_os = "linux"))] + pub fn observe() -> Result { + Err("Health is only available on Linux".into()) + } + + #[cfg(target_os = "linux")] pub fn observe() -> Result { let process = Process::current().map_err(|e| format!("Unable to get current process: {:?}", e))?;