Skip to content

Commit

Permalink
ci: WASM checks
Browse files Browse the repository at this point in the history
  • Loading branch information
realeinherjar committed Oct 19, 2023
1 parent d932cf5 commit 1e42b2a
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 43 deletions.
50 changes: 21 additions & 29 deletions .github/workflows/cont_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,17 @@ jobs:
name: bitcoindevkit
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
continue-on-error: true # for forks outside of bitcoindevkit GH org
# Cache Builds
- name: Build and Cache latest Rust
run: nix build -L . --keep-failed
- name: Build and Cache MRSV Rust
- name: Build and Cache MRSV
run: nix build -L .#MSRV --keep-failed
- name: Build and Cache WASM
run: nix build -L .#WASM --keep-failed
# Rustfmt
- name: Rustfmt
run: nix build -L .#ci.fmt --keep-failed
# Clippy
- name: Clippy
run: nix build -L .#ci.clippy --keep-failed
# Audit
Expand All @@ -41,40 +46,27 @@ jobs:
# Tests: latest
- name: Test workspace all-features latest
run: nix build -L .#ci.latest.all --keep-failed
- name: Test '--no-default-features' latest Rust
- name: Test workspace no-default-features latest
run: nix build -L .#ci.latest.noDefault --keep-failed
- name: Test '-p bdk' no-std latest Rust
- name: Test bdk no-std latest
run: nix build -L .#ci.latest.noStdBdk --keep-failed
- name: Test '-p chain' no-std latest Rust
- name: Test bdk_chain no-std latest
run: nix build -L .#ci.latest.noStdChain --keep-failed
- name: Test '-p esplora' no-std latest Rust
- name: Test bdk_esplora no-std latest
run: nix build -L .#ci.latest.noStdEsplora --keep-failed
- name: Test '--all-features' MSRV Rust
# Tests: MSRV
- name: Test workspace all-features MSRV
run: nix build -L .#ci.MSRV.all --keep-failed
- name: Test '--no-default-features' MSRV Rust
- name: Test workspace no-default-features MSRV
run: nix build -L .#ci.MSRV.noDefault --keep-failed
- name: Test '-p bdk' no-std MSRV Rust
- name: Test bdk no-std MSRV
run: nix build -L .#ci.MSRV.noStdBdk --keep-failed
- name: Test '-p chain' no-std MSRV Rust
- name: Test bdk_chain no-std MSRV
run: nix build -L .#ci.MSRV.noStdChain --keep-failed
- name: Test '-p esplora' no-std MSRV Rust
- name: Test bdk_esplora no-std MSRV
run: nix build -L .#ci.MSRV.noStdEsplora --keep-failed
# check-wasm:
# name: Check WASM
# runs-on: ubuntu-20.04
# env:
# CC: clang-10
# CFLAGS: -I/usr/include
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# - name: Install Nix
# uses: DeterminateSystems/nix-installer-action@v5
# - name: Rust Cache
# uses: Swatinem/[email protected]
# - name: Check bdk
# working-directory: ./crates/bdk
# run: 'nix develop -L .#test.WASM --command bash -c "cargo check --target wasm32-unknown-unknown --no-default-features --features bitcoin/no-std,miniscript/no-std,bdk_chain/hashbrown,dev-getrandom-wasm"'
# - name: Check esplora
# working-directory: ./crates/esplora
# run: 'nix develop -L .#test.WASM --command bash -c "cargo check --target wasm32-unknown-unknown --no-default-features --features bitcoin/no-std,miniscript/no-std,bdk_chain/hashbrown,async"'
# Checks: WASM
- name: Check bdk WASM
run: nix build -L .#ci.WASM.bdk --keep-failed
- name: Check bdk_esplora WASM
run: nix build -L .#ci.WASM.esplora --keep-failed
55 changes: 41 additions & 14 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,12 @@
] ++ lib.optionals isDarwin libsDarwin;

# WASM deps
wasmInputs = [
WASMInputs = [
# Additional wasm specific inputs can be set here
pkgs.wasm-bindgen-cli
pkgs.llvmPackages_14.clang-unwrapped
pkgs.llvmPackages_14.stdenv
pkgs.llvmPackages_14.libcxxClang
pkgs.llvmPackages_14.libcxxStdenv
];

nativeBuildInputs = [
Expand Down Expand Up @@ -139,8 +142,20 @@
# WASM derivation arguments
WASMArgs = {
CARGO_BUILD_TARGET = "wasm32-unknown-unknown";
buildInputs = buildInputs ++ wasmInputs;
buildInputs = buildInputs ++ WASMInputs;
inherit nativeBuildInputs;
# crane tries to run the Wasm file as if it were a binary
doCheck = false;
# don't test
cargoTestCommand = "";
# just build bdk for now
cargoExtraArgs = "--locked --target wasm32-unknown-unknown -p bdk --no-default-features --features bitcoin/no-std,miniscript/no-std,bdk_chain/hashbrown,dev-getrandom-wasm";
# env vars
CC = "${stdenv.cc.nativePrefix}cc";
AR = "${stdenv.cc.nativePrefix}ar";
CC_wasm32_unknown_unknown = "${pkgs.llvmPackages_14.clang-unwrapped}/bin/clang-14";
CFLAGS_wasm32_unknown_unknown = "-I ${pkgs.llvmPackages_14.libclang.lib}/lib/clang/14.0.6/include/";
AR_wasm32_unknown_unknown = "${pkgs.llvmPackages_14.llvm}/bin/llvm-ar";
};


Expand Down Expand Up @@ -172,6 +187,7 @@
checks = {
inherit clippy;
inherit fmt;

# Latest
latest = packages.default;
latestAll = craneLib.cargoTest (commonArgs // {
Expand All @@ -194,6 +210,7 @@
inherit cargoArtifacts;
cargoCheckExtraArgs = "-p bdk_esplora --no-default-features --features bitcoin/no-std,miniscript/no-std,bdk_chain/hashbrown";
});

# MSRV
MSRV = packages.MSRV;
MSRVAll = craneMSRVLib.cargoTest (commonArgs // MSRVArgs // {
Expand All @@ -216,15 +233,16 @@
cargoArtifacts = cargoArtifactsMSRV;
cargoCheckExtraArgs = "-p bdk_esplora --no-default-features --features bitcoin/no-std,miniscript/no-std,bdk_chain/hashbrown";
});

# WASM
# WASMBdk = craneWASMLib.cargoBuild (commonArgs // WASMArgs // {
# cargoArtifacts = cargoArtifactsWASM;
# cargoCheckExtraArgs = "-p bdk --no-default-features --features bitcoin/no-std,miniscript/no-std,bdk_chain/hashbrown,dev-getrandom-wasm";
# });
# WASMEsplora = craneWASMLib.cargoBuild (commonArgs // WASMArgs // {
# cargoArtifacts = cargoArtifactsWASM;
# cargoCheckExtraArgs = "-p bdk_esplora --no-default-features --features bitcoin/no-std,miniscript/no-std,bdk_chain/hashbrown,async";
# });
WASMBdk = craneWASMLib.buildPackage (commonArgs // WASMArgs // {
cargoArtifacts = cargoArtifactsWASM;
});
WASMEsplora = craneWASMLib.cargoBuild (commonArgs // WASMArgs // {
cargoArtifacts = cargoArtifactsWASM;
cargoExtraArgs = "--locked -p bdk_esplora --no-default-features --features bitcoin/no-std,miniscript/no-std,bdk_chain/hashbrown,async";
});

# Audit dependencies
audit = craneLib.cargoAudit (commonArgs // {
inherit advisory-db;
Expand All @@ -240,7 +258,7 @@
cargoArtifacts = cargoArtifactsMSRV;
});
WASM = craneWASMLib.cargoBuild (commonArgs // WASMArgs // {
cargoArtifacts = null;
cargoArtifacts = cargoArtifactsWASM;
});
};
legacyPackages = {
Expand All @@ -262,6 +280,10 @@
noStdChain = checks.MSRVNoStdChain;
noStdEsplora = checks.MSRVNoStdEsplora;
};
WASM = {
bdk = checks.WASMBdk;
esplora = checks.WASMEsplora;
};
};
};

Expand Down Expand Up @@ -329,7 +351,7 @@
noStdEsplora = checks.MSRVNoStdEsplora;
};
# dependencies
packages = buildInputs ++ [
packages = buildInputs ++ WASMInputs ++ [
pkgs.bashInteractive
pkgs.git
pkgs.ripgrep
Expand All @@ -338,7 +360,12 @@

BITCOIND_EXEC = commonArgs.BITCOIND_EXEC;
ELECTRS_EXEC = commonArgs.ELECTRS_EXEC;
CARGO_BUILD_TARGET = "wasm32-unknown-unknown";
CARGO_BUILD_TARGET = WASMArgs.CARGO_BUILD_TARGET;
CC = WASMArgs.CC;
AR = WASMArgs.AR;
CC_wasm32_unknown_unknown = WASMArgs.CC_wasm32_unknown_unknown;
CFLAGS_wasm32_unknown_unknown = WASMArgs.CFLAGS_wasm32_unknown_unknown;
AR_wasm32_unknown_unknown = WASMArgs.AR_wasm32_unknown_unknown;
};
};
}
Expand Down

0 comments on commit 1e42b2a

Please sign in to comment.