diff --git a/.github/workflows/cargo-build.yml b/.github/workflows/cargo-build.yml index 6d97b5cd..38600635 100644 --- a/.github/workflows/cargo-build.yml +++ b/.github/workflows/cargo-build.yml @@ -1,4 +1,4 @@ -name: ubuntu-matrix +name: cargo-build-matrix # Controls when the action will run. on: @@ -48,9 +48,12 @@ jobs: - name: printenv run: | printenv + touch ~/GITHUB_TOKEN.txt + - name: install rustup run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && source "$HOME/.cargo/env" - - name: make + + - name: sudo apt-get install -y make run: | printenv && sudo apt-get update && \ sudo apt-get install -y make #\ @@ -58,17 +61,28 @@ jobs: #make autoconf automake \ #libtool gettext util-linux bash cmake clang - - name: cmake -S . -B build && cd build && make + - name: cargo-c + run: | + make cargo-c + + - name: cargo-b run: | - touch ~/GITHUB_TOKEN.txt - #touch CMakeCache.txt - #mkdir -p build - #rm CMakeCache.txt || true - #rm build/CMakeCache.txt || true - #CMAKE_CXX_COMPILER=clang cmake -S . -B build && cd build && make - - - name: Build - run: source "$HOME/.cargo/env" && cargo build --verbose + make cargo-b + + - name: cargo-b-release + run: | + make cargo-b-release + + - name: cargo-build-release-tokio + run: | + make cargo-build-release-tokio + + - name: cargo-build-release-async-std + run: | + make cargo-build-release-async-std + + + - name: Run tests run: source "$HOME/.cargo/env" && cargo test --verbose diff --git a/Cargo.toml b/Cargo.toml index 8341382f..ae388e64 100755 --- a/Cargo.toml +++ b/Cargo.toml @@ -53,11 +53,13 @@ curve25519-dalek = "4" crypto_secretstream = "0.2" rust-crypto = "0.2.36" git2 = "0.9.1" -argparse = "0.2.2" +argparse = "0.2.2" time = "0.1.42" chrono = "0" nostr = "0.24.0" nostr-sdk = "0.24.0" +wasi = { version = "0.10.0", features = ["std"] } +oorandom = "11.1.3" [dev-dependencies] async-std = { version = "1.12.0", features = ["attributes", "unstable"] } @@ -91,11 +93,6 @@ async-std = ["hypercore/async-std", "random-access-disk/async-std"] # to verify that this crate works. To run them, use: # cargo test --features js_interop_tests js_interop_tests = [] - -[profile.bench] -# debug = true - -[profile.release] # debug = true [[bench]] diff --git a/Dockerfile b/Dockerfile index 9aa86193..23a0c6ca 100755 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ RUN apt-get install bash libssl-dev pkg-config python-is-python3 systemd -y RUN chmod +x /usr/bin/systemctl RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y WORKDIR /tmp -RUN git clone --recurse-submodules -j2 --branch v0.0.4 --depth 1 https://github.com/gnostr-org/gnostr-command +RUN git clone --recurse-submodules -j2 --branch v0.0.5 --depth 1 https://github.com/gnostr-org/gnostr-command.git WORKDIR /tmp/gnostr-command #RUN . $HOME/.cargo/env && cargo build --release && cargo install --path . RUN install ./serve /usr/local/bin diff --git a/cargo.mk b/cargo.mk index ddb37ad7..12def353 100755 --- a/cargo.mk +++ b/cargo.mk @@ -2,52 +2,111 @@ ##make cargo-* cargo-help:### cargo-help @awk 'BEGIN {FS = ":.*?###"} /^[a-zA-Z_-]+:.*?###/ {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) -cargo-build:### cargo build -## make cargo-build q=true + +cargo-bt:cargo-build-tokio### cargo-bt +cargo-build-tokio:### cargo-build-tokio +## make cargo-build-tokio q=true + @. $(HOME)/.cargo/env + @RUST_BACKTRACE=all cargo b $(QUIET) --no-default-features --features tokio + +cargo-bas:cargo-build-async-std### cargo-bas +cargo-build-async-std:### cargo-build-async-std +## make cargo-build-async-std q=true @. $(HOME)/.cargo/env - @RUST_BACKTRACE=all cargo b $(QUIET) --no-default-features + @RUST_BACKTRACE=all cargo b $(QUIET) --no-default-features --features async-std + cargo-install:### cargo install --path . #@. $(HOME)/.cargo/env #@cargo install --path $(PWD) @cargo install --locked --path $(PWD) -cargo-br:cargo-build-release### cargo-br -## make cargo-br q=true -cargo-build-release:### cargo-build-release -## make cargo-build-release q=true + +cargo-br-tokio:cargo-build-release-tokio### cargo-br-tokio +## make cargo-br-tokio q=true + +cargo-build-release-tokio:### cargo-build-release-tokio +## make cargo-build-release-tokio q=true @. $(HOME)/.cargo/env - @cargo b $(QUIET) --profile=$(PROFILE) --no-default-features + @cargo b $(QUIET) --profile=$(PROFILE) --no-default-features --features tokio + +cargo-br-async-std:cargo-build-release-async-std### cargo-br-async-std +## make cargo-br-async-std q=true + +cargo-build-release-async-std:### cargo-build-release-async-std +## make cargo-build-release-async-std q=true + @. $(HOME)/.cargo/env + @cargo b $(QUIET) --profile=$(PROFILE) --no-default-features --features async-std + cargo-check:### cargo-check ## cargo c @. $(HOME)/.cargo/env @cargo c + +cargo-check-tokio:### cargo-check-tokio +## cargo c --no-default-features --features tokio + @. $(HOME)/.cargo/env @cargo check --no-default-features --features tokio + +cargo-check-async-std:### cargo-check-async-std +## cargo c --no-default-features --features async-std + @. $(HOME)/.cargo/env @cargo check --no-default-features --features async-std + cargo-bench:### cargo-bench -## cargo b -## cargo build --release +## cargo bench @. $(HOME)/.cargo/env @cargo bench -cargo-t:cargo-test### cargo-t -cargo-test:### cargo-test -## cargo t - @. $(HOME)/.cargo/env && cargo test #--no-default-features + +cargo-tt:cargo-test-tokio### cargo-tt +cargo-test-tokio:### cargo-test-tokio +## cargo tt + @. $(HOME)/.cargo/env && cargo test --no-default-features --features tokio + +cargo-ts:cargo-test-async-std### cargo-ts +cargo-test-async-std:### cargo-test-async-std +## cargo ts + @. $(HOME)/.cargo/env && cargo test --no-default-features --features async-std + cargo-jits:### cargo-jits ## cargo-jits @. $(HOME)/.cargo/env && $(MAKE) cargo-t-jit-tokio cargo-t-jit-as + cargo-t-jit-tokio:cargo-test-js-interop-tokio### cargo-test-jit-tokio cargo-test-js-interop-tokio: @. $(HOME)/.cargo/env && cargo test --no-default-features --features js_interop_tests,tokio + cargo-t-jit-as:cargo-test-js-interop-async-std### cargo-test-jit-as cargo-test-js-interop-async-std: @. $(HOME)/.cargo/env && cargo test --no-default-features --features js_interop_tests,async-std -cargo-test-benches:### cargo-test + +cargo-test-benches:### cargo-test-benches cargo test --benches + cargo-report:### cargo-report @. $(HOME)/.cargo/env && cargo report future-incompatibilities --id 1 + cargo-doc:### cargo-doc @. $(HOME)/.cargo/env && cargo doc --no-deps #--open + cargo-b-wasm-tokio: - @. $(HOME)/.cargo/env && cargo clean && cargo build --target=wasm32-unknown-emscripten --no-default-features #--features wasm-bindgen,tokio + @rustup target add wasm32-unknown-emscripten + @. $(HOME)/.cargo/env && cargo clean && cargo build --target=wasm32-unknown-emscripten --no-default-features --features wasm-bindgen,tokio + +cargo-b-wasm-async-std: + @rustup target add wasm32-unknown-emscripten + @. $(HOME)/.cargo/env && cargo clean && cargo build --target=wasm32-unknown-emscripten --no-default-features --features wasm-bindgen,async-std + +node-examples-nodejs-run-js-node:### node-examples-nodejs-run-js-node +## node-examples-nodejs-run-js-node + node examples-nodejs/run.js node +node-examples-nodejs-run-js-node-6102:### node-examples-nodejs-run-js-node-6102 +## node-examples-nodejs-run-js-node-6102 + node examples-nodejs/run.js node 6102 +node-examples-nodejs-run-js-rust:### node-examples-nodejs-run-js-rust +## node-examples-nodejs-run-js-rust + node examples-nodejs/run.js rust +node-examples-nodejs-run-js-rust-2106:### node-examples-nodejs-run-js-rust-2106 +## node-examples-nodejs-run-js-rust-2106 + node examples-nodejs/run.js rust 2106 # vim: set noexpandtab: # vim: set setfiletype make diff --git a/docker.mk b/docker.mk index 8d59be04..975342c1 100644 --- a/docker.mk +++ b/docker.mk @@ -31,3 +31,8 @@ docker-buildx:## docker buildx build sequence @$(DOCKER) buildx create --use --name gnostr-command-buildx || true @$(DOCKER) buildx build -t gnostr-command --platform linux/arm64,linux/amd64 . @$(DOCKER) buildx build -t gnostr-command --platform linux/$(TARGET) . --load + +docker-package-buildx: + @docker build . --tag ghcr.io/gnostr-org/gnostr-command:latest +docker-package-pushx: + @$(DOCKER) push ghcr.io/gnostr-org/gnostr-command:latest diff --git a/gnostr-command-docker b/gnostr-command-docker index fc1e7834..3e94a9ac 100755 --- a/gnostr-command-docker +++ b/gnostr-command-docker @@ -10,7 +10,7 @@ RUN apt-get install bash libssl-dev pkg-config python-is-python3 systemd -y RUN chmod +x /usr/bin/systemctl RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y WORKDIR /tmp -RUN git clone --recurse-submodules -j2 --branch v0.0.4 --depth 1 https://github.com/gnostr-org/gnostr-command +RUN git clone --recurse-submodules -j2 --branch v0.0.5 --depth 1 https://github.com/gnostr-org/gnostr-command.git WORKDIR /tmp/gnostr-command #RUN . "\$HOME/.cargo/env" && cargo build --release && cargo install --path . RUN install ./serve /usr/local/bin