Skip to content

Commit

Permalink
wip - lints + CI
Browse files Browse the repository at this point in the history
  • Loading branch information
aspect committed Jan 9, 2024
1 parent 3fba9c8 commit 7139618
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 25 deletions.
93 changes: 88 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -251,14 +251,65 @@ jobs:
# build
wasm-pack build --target web --out-name kaspa-ng --out-dir ../../dist-chrome ./extensions/chrome
# build-release:
# name: Ubuntu Release
# runs-on: ubuntu-latest
# steps:

# - name: Install desktop dependencies
# run: |
# sudo apt install -y libglib2.0-dev libatk1.0-dev libgtk-3-dev

# - name: Checkout sources
# uses: actions/checkout@v3

# - name: Install Protoc
# uses: arduino/setup-protoc@v1
# with:
# repo-token: ${{ secrets.GITHUB_TOKEN }}

# - name: Install stable toolchain
# uses: dtolnay/rust-toolchain@stable

# - name: Cache
# uses: actions/cache@v3
# with:
# path: |
# ~/.cargo/bin/
# ~/.cargo/registry/index/
# ~/.cargo/registry/cache/
# ~/.cargo/git/db/
# target/
# key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

# - name: Install zig
# if: runner.os == 'Linux'
# uses: goto-bus-stop/setup-zig@v2 # needed for cargo-zigbuild

# - name: Build on Linux
# if: runner.os == 'Linux'
# # We're using musl to make the binaries statically linked and portable
# run: |
# cargo install cargo-zigbuild
# cargo --verbose zigbuild --release --target x86_64-unknown-linux-gnu.2.27 # Use an older glibc version
build-release:
name: Ubuntu Release
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# Build gnu-linux on ubuntu-18.04 and musl on ubuntu latest
# os: [ ubuntu-18.04, ubuntu-latest, windows-latest, macos-latest ]
# os: [ ubuntu-latest, windows-latest, macos-latest ]
os: [ windows-latest, macos-latest ]
name: Building, ${{ matrix.os }}
steps:
- name: Fix CRLF on Windows
if: runner.os == 'Windows'
run: git config --global core.autocrlf false

- name: Install desktop dependencies
run: |
sudo apt install -y libglib2.0-dev libatk1.0-dev libgtk-3-dev
sudo apt install -y libglib2.0-dev libatk1.0-dev libgtk-3-dev librust-atk-dev
- name: Checkout sources
uses: actions/checkout@v3
Expand All @@ -282,7 +333,7 @@ jobs:
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Install zig
- name: Install zig on linux
if: runner.os == 'Linux'
uses: goto-bus-stop/setup-zig@v2 # needed for cargo-zigbuild

Expand All @@ -291,4 +342,36 @@ jobs:
# We're using musl to make the binaries statically linked and portable
run: |
cargo install cargo-zigbuild
cargo --verbose zigbuild --release --target x86_64-unknown-linux-gnu.2.27 # Use an older glibc version
cargo --verbose zigbuild --bin kaspa-ng --release --target x86_64-unknown-linux-gnu.2.27 # Use an older glibc version
mkdir kaspa-ng-${{ github.event.release.tag_name }}-linux-gnu-amd64 || true
cp target/x86_64-unknown-linux-gnu/release/kaspa-ng kaspa-ng-${{ github.event.release.tag_name }}-linux-gnu-amd64/
archive="kaspa-ng-${{ github.event.release.tag_name }}-linux-gnu-amd64/kaspa-ng-${{ github.event.release.tag_name }}-linux-gnu-amd64.zip"
asset_name="kaspa-ng-${{ github.event.release.tag_name }}-linux-gnu-amd64.zip"
zip -r "${archive}" ./kaspa-ng-${{ github.event.release.tag_name }}-linux-gnu-amd64/*
echo "archive=${archive}" >> $GITHUB_ENV
echo "asset_name=${asset_name}" >> $GITHUB_ENV
- name: Build on Windows
if: runner.os == 'Windows'
shell: bash
run: |
cargo build --bin kaspa-ng --release
mkdir kaspa-ng-${{ github.event.release.tag_name }}-windows-x64 || true
cp target/release/kaspa-ng.exe kaspa-ng-${{ github.event.release.tag_name }}-windows-x64/
archive="kaspa-ng-${{ github.event.release.tag_name }}-windows-x64/kaspa-ng-${{ github.event.release.tag_name }}-windows-x64.zip"
asset_name="kaspa-ng-${{ github.event.release.tag_name }}-windows-x64.zip"
powershell "Compress-Archive kaspa-ng-${{ github.event.release.tag_name }}-windows-x64/* \"${archive}\""
echo "archive=${archive}" >> $GITHUB_ENV
echo "asset_name=${asset_name}" >> $GITHUB_ENV
- name: Build on MacOS
if: runner.os == 'macOS'
run: |
cargo build --bin kaspa-ng --release
mkdir kaspa-ng-${{ github.event.release.tag_name }}-macos-arm64 || true
cp target/release/kaspa-ng kaspa-ng-${{ github.event.release.tag_name }}-macos-arm64/
archive="kaspa-ng-${{ github.event.release.tag_name }}-macos-arm64/kaspa-ng-${{ github.event.release.tag_name }}-macos-arm64.zip"
asset_name="kaspa-ng-${{ github.event.release.tag_name }}-macos-arm64.zip"
zip -r "${archive}" ./kaspa-ng-${{ github.event.release.tag_name }}-macos-arm64/*
echo "archive=${archive}" >> $GITHUB_ENV
echo "asset_name=${asset_name}" >> $GITHUB_ENV
14 changes: 8 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ kaspa-ng-macros = { version = "0.1.0", path = "macros/" }
# |___ |__] |__| |
# ___________________

egui = "0.24.0"
epaint = "0.24.0"
egui_plot = "0.24.0"
egui_extras = { version = "0.24.0", features = ["svg","image"] }
eframe = { version = "0.24.0", default-features = false, features = [
egui = "=0.24.0"
epaint = "=0.24.0"
egui_plot = "=0.24.0"
egui_extras = { version = "=0.24.0", features = ["svg","image"] }
eframe = { version = "=0.24.0", default-features = false, features = [
"accesskit", # Make egui comptaible with screen readers. NOTE: adds a lot of dependencies.
"default_fonts", # Embed the default egui fonts.
"glow", # Use the glow rendering backend. Alternative: "wgpu".
Expand Down Expand Up @@ -169,4 +169,6 @@ xxhash-rust = { version = "0.8.7", features = ["xxh3"] }
zeroize = { version = "1", default-features = false, features = ["alloc"] }

[profile.release]
opt-level = 2 # fast and small wasm
opt-level = 2
# opt-level = 3
# lto = true
27 changes: 15 additions & 12 deletions core/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ use kaspa_metrics_core::MetricsSnapshot;
use kaspa_wallet_core::api::TransactionsDataGetResponse;
use kaspa_wallet_core::events::Events as CoreWallet;
use kaspa_wallet_core::storage::{Binding, Hint, PrvKeyDataInfo};
use workflow_wasm::callback::CallbackMap;
use std::borrow::Cow;
#[allow(unused_imports)]
use workflow_i18n::*;
use workflow_wasm::callback::CallbackMap;

pub enum Exception {
UtxoIndexNotEnabled { url: Option<String> },
Expand Down Expand Up @@ -53,7 +53,7 @@ pub struct Core {
pub servers: Arc<Vec<Server>>,
pub debug: bool,
pub window_frame: bool,
callback_map : CallbackMap,
callback_map: CallbackMap,
}

impl Core {
Expand Down Expand Up @@ -198,7 +198,8 @@ impl Core {
this.update_servers();
this.wallet_update_list();

#[cfg(target_arch = "wasm32")] {
#[cfg(target_arch = "wasm32")]
{
this.register_visibility_handler();
}

Expand Down Expand Up @@ -598,7 +599,7 @@ impl Core {
_frame: &mut eframe::Frame,
) -> Result<()> {
match event {
Events::VisibilityChange(_state) => { }
Events::VisibilityChange(_state) => {}
Events::ServerList { server_list } => {
self.servers = server_list;
}
Expand Down Expand Up @@ -1095,8 +1096,8 @@ impl Core {
}

pub fn register_visibility_handler(&self) {
use workflow_wasm::callback::*;
use workflow_dom::utils::document;
use workflow_wasm::callback::*;

let block_dag_background_state = self.get::<modules::BlockDag>().background_state();

Expand All @@ -1105,15 +1106,18 @@ impl Core {
let visibility_state = document().visibility_state();
match visibility_state {
VisibilityState::Visible => {
crate::runtime::runtime().block_dag_monitor_service().enable(None);

},
crate::runtime::runtime()
.block_dag_monitor_service()
.enable(None);
}
VisibilityState::Hidden => {
if !block_dag_background_state.load(Ordering::SeqCst) {
crate::runtime::runtime().block_dag_monitor_service().disable(None);
crate::runtime::runtime()
.block_dag_monitor_service()
.disable(None);
}
},
_ => { }
}
_ => {}
};
sender
.try_send(Events::VisibilityChange(visibility_state))
Expand All @@ -1124,5 +1128,4 @@ impl Core {
document().set_onvisibilitychange(Some(callback.as_ref()));
self.callback_map.retain(callback).unwrap();
}

}
2 changes: 1 addition & 1 deletion core/src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pub use std::sync::OnceLock;
pub use std::sync::{Arc, Mutex, MutexGuard, RwLock};
pub use std::time::Duration;

pub use web_sys::VisibilityState;
pub use workflow_core::abortable::Abortable;
pub use workflow_core::channel::{oneshot, Channel, Receiver, Sender};
pub use workflow_core::enums::Describe;
Expand All @@ -43,7 +44,6 @@ pub use workflow_core::time::{unixtime_as_millis_f64, Instant};
pub use workflow_http as http;
pub use workflow_i18n::*;
pub use workflow_log::*;
pub use web_sys::VisibilityState;

pub use ahash::{AHashMap, AHashSet};
pub use pad::{Alignment, PadStr};
Expand Down
2 changes: 1 addition & 1 deletion core/src/modules/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ impl std::fmt::Debug for Module {
}
}

impl Eq for Module { }
impl Eq for Module {}

impl PartialEq for Module {
fn eq(&self, other: &Self) -> bool {
Expand Down

0 comments on commit 7139618

Please sign in to comment.