From 3bc0f093011d34cd53c100bc1d5cb09374478a8f Mon Sep 17 00:00:00 2001 From: Antonio Yang Date: Sun, 30 Aug 2026 10:42:10 +0800 Subject: [PATCH 01/15] init examples/ --- .github/workflows/test.yml | 2 +- .gitignore | 4 ++-- Cargo.toml | 4 ++-- {complex-example => examples/complex-example}/Cargo.toml | 2 +- .../complex-example}/catalyst-src/Cargo.toml | 0 .../complex-example}/catalyst-src/src/lib.rs | 0 .../complex-example}/catalyst/Cargo.toml | 0 .../complex-example}/catalyst/build.rs | 0 .../complex-example}/catalyst/src/lib.rs | 0 .../complex-example}/substrate/Cargo.toml | 0 .../complex-example}/substrate/src/lib.rs | 0 .../no-std-examples}/.cargo/config.toml | 0 {no-std-examples => examples/no-std-examples}/Cargo.toml | 2 +- {no-std-examples => examples/no-std-examples}/build.rs | 0 {no-std-examples => examples/no-std-examples}/memory.x | 0 {no-std-examples => examples/no-std-examples}/src/box.rs | 0 {no-std-examples => examples/no-std-examples}/src/option.rs | 0 flake.nix | 2 +- 18 files changed, 8 insertions(+), 8 deletions(-) rename {complex-example => examples/complex-example}/Cargo.toml (93%) rename {complex-example => examples/complex-example}/catalyst-src/Cargo.toml (100%) rename {complex-example => examples/complex-example}/catalyst-src/src/lib.rs (100%) rename {complex-example => examples/complex-example}/catalyst/Cargo.toml (100%) rename {complex-example => examples/complex-example}/catalyst/build.rs (100%) rename {complex-example => examples/complex-example}/catalyst/src/lib.rs (100%) rename {complex-example => examples/complex-example}/substrate/Cargo.toml (100%) rename {complex-example => examples/complex-example}/substrate/src/lib.rs (100%) rename {no-std-examples => examples/no-std-examples}/.cargo/config.toml (100%) rename {no-std-examples => examples/no-std-examples}/Cargo.toml (92%) rename {no-std-examples => examples/no-std-examples}/build.rs (100%) rename {no-std-examples => examples/no-std-examples}/memory.x (100%) rename {no-std-examples => examples/no-std-examples}/src/box.rs (100%) rename {no-std-examples => examples/no-std-examples}/src/option.rs (100%) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9bf0e4d..ad7254e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -77,7 +77,7 @@ jobs: - name: Test in no std run: | - cd no-std-examples + cd examples/no-std-examples nix develop .#no-std -c cargo run --quiet --features=box --bin no-std-box nix develop .#no-std -c cargo run --quiet --features=option --bin no-std-option diff --git a/.gitignore b/.gitignore index 1fa5e3d..16cd716 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,5 @@ Cargo.lock .envrc .direnv/ struct-patch/examples -no-std-examples/target -complex-example/target +examples/no-std-examples/target +examples/complex-example/target diff --git a/Cargo.toml b/Cargo.toml index f013e96..db7b8e8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,8 +5,8 @@ members = [ "derive", ] exclude = [ - "no-std-examples", - "complex-example", + "examples/no-std-examples", + "examples/complex-example", ] [workspace.package] diff --git a/complex-example/Cargo.toml b/examples/complex-example/Cargo.toml similarity index 93% rename from complex-example/Cargo.toml rename to examples/complex-example/Cargo.toml index 52cfb06..caa1747 100644 --- a/complex-example/Cargo.toml +++ b/examples/complex-example/Cargo.toml @@ -6,7 +6,7 @@ members = [ "catalyst-src", ] [workspace.dependencies] -struct-patch = { path = "../lib" } +struct-patch = { path = "../../lib" } [workspace.package] authors = ["Antonio Yang "] diff --git a/complex-example/catalyst-src/Cargo.toml b/examples/complex-example/catalyst-src/Cargo.toml similarity index 100% rename from complex-example/catalyst-src/Cargo.toml rename to examples/complex-example/catalyst-src/Cargo.toml diff --git a/complex-example/catalyst-src/src/lib.rs b/examples/complex-example/catalyst-src/src/lib.rs similarity index 100% rename from complex-example/catalyst-src/src/lib.rs rename to examples/complex-example/catalyst-src/src/lib.rs diff --git a/complex-example/catalyst/Cargo.toml b/examples/complex-example/catalyst/Cargo.toml similarity index 100% rename from complex-example/catalyst/Cargo.toml rename to examples/complex-example/catalyst/Cargo.toml diff --git a/complex-example/catalyst/build.rs b/examples/complex-example/catalyst/build.rs similarity index 100% rename from complex-example/catalyst/build.rs rename to examples/complex-example/catalyst/build.rs diff --git a/complex-example/catalyst/src/lib.rs b/examples/complex-example/catalyst/src/lib.rs similarity index 100% rename from complex-example/catalyst/src/lib.rs rename to examples/complex-example/catalyst/src/lib.rs diff --git a/complex-example/substrate/Cargo.toml b/examples/complex-example/substrate/Cargo.toml similarity index 100% rename from complex-example/substrate/Cargo.toml rename to examples/complex-example/substrate/Cargo.toml diff --git a/complex-example/substrate/src/lib.rs b/examples/complex-example/substrate/src/lib.rs similarity index 100% rename from complex-example/substrate/src/lib.rs rename to examples/complex-example/substrate/src/lib.rs diff --git a/no-std-examples/.cargo/config.toml b/examples/no-std-examples/.cargo/config.toml similarity index 100% rename from no-std-examples/.cargo/config.toml rename to examples/no-std-examples/.cargo/config.toml diff --git a/no-std-examples/Cargo.toml b/examples/no-std-examples/Cargo.toml similarity index 92% rename from no-std-examples/Cargo.toml rename to examples/no-std-examples/Cargo.toml index ddaaf9f..3a5f0d7 100644 --- a/no-std-examples/Cargo.toml +++ b/examples/no-std-examples/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" license = "MIT" [dependencies] -struct-patch = { path = "../lib" } +struct-patch = { path = "../../lib" } linked_list_allocator = "0.10" cortex-m-rt = "0.7" cortex-m-semihosting = "0.5" diff --git a/no-std-examples/build.rs b/examples/no-std-examples/build.rs similarity index 100% rename from no-std-examples/build.rs rename to examples/no-std-examples/build.rs diff --git a/no-std-examples/memory.x b/examples/no-std-examples/memory.x similarity index 100% rename from no-std-examples/memory.x rename to examples/no-std-examples/memory.x diff --git a/no-std-examples/src/box.rs b/examples/no-std-examples/src/box.rs similarity index 100% rename from no-std-examples/src/box.rs rename to examples/no-std-examples/src/box.rs diff --git a/no-std-examples/src/option.rs b/examples/no-std-examples/src/option.rs similarity index 100% rename from no-std-examples/src/option.rs rename to examples/no-std-examples/src/option.rs diff --git a/flake.nix b/flake.nix index 438c6d5..af8a2ab 100644 --- a/flake.nix +++ b/flake.nix @@ -22,7 +22,7 @@ checkCatalystScript = pkgs.writeShellScriptBin "check-catalyst" '' set -ex cd $(git rev-parse --show-toplevel 2>/dev/null) - cd complex-example + cd examples/complex-example cargo test --quiet -p substrate cargo test --quiet -p catalyst cargo test --quiet -p catalyst-src From 8995d12ab63ec1c90949a54db3e604d7fdb62302 Mon Sep 17 00:00:00 2001 From: Antonio Yang Date: Sun, 30 Aug 2026 10:45:15 +0800 Subject: [PATCH 02/15] rn `example/complex-examples` --- .github/dependabot.yml | 4 ++-- .gitignore | 2 +- Cargo.toml | 2 +- examples/{complex-example => complex-examples}/Cargo.toml | 0 .../catalyst-src/Cargo.toml | 0 .../catalyst-src/src/lib.rs | 0 .../{complex-example => complex-examples}/catalyst/Cargo.toml | 0 .../{complex-example => complex-examples}/catalyst/build.rs | 0 .../{complex-example => complex-examples}/catalyst/src/lib.rs | 0 .../substrate/Cargo.toml | 0 .../substrate/src/lib.rs | 0 flake.nix | 2 +- 12 files changed, 5 insertions(+), 5 deletions(-) rename examples/{complex-example => complex-examples}/Cargo.toml (100%) rename examples/{complex-example => complex-examples}/catalyst-src/Cargo.toml (100%) rename examples/{complex-example => complex-examples}/catalyst-src/src/lib.rs (100%) rename examples/{complex-example => complex-examples}/catalyst/Cargo.toml (100%) rename examples/{complex-example => complex-examples}/catalyst/build.rs (100%) rename examples/{complex-example => complex-examples}/catalyst/src/lib.rs (100%) rename examples/{complex-example => complex-examples}/substrate/Cargo.toml (100%) rename examples/{complex-example => complex-examples}/substrate/src/lib.rs (100%) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index b14e5af..95a2779 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -17,10 +17,10 @@ updates: schedule: interval: "weekly" - package-ecosystem: "cargo" - directory: "/no-std-examples" + directory: "/examples/no-std-examples" schedule: interval: "weekly" - package-ecosystem: "cargo" - directory: "/complex-example" + directory: "/examples/complex-examples" schedule: interval: "weekly" diff --git a/.gitignore b/.gitignore index 16cd716..dc0ab34 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,4 @@ Cargo.lock .direnv/ struct-patch/examples examples/no-std-examples/target -examples/complex-example/target +examples/complex-examples/target diff --git a/Cargo.toml b/Cargo.toml index db7b8e8..bde27dd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ members = [ ] exclude = [ "examples/no-std-examples", - "examples/complex-example", + "examples/complex-examples", ] [workspace.package] diff --git a/examples/complex-example/Cargo.toml b/examples/complex-examples/Cargo.toml similarity index 100% rename from examples/complex-example/Cargo.toml rename to examples/complex-examples/Cargo.toml diff --git a/examples/complex-example/catalyst-src/Cargo.toml b/examples/complex-examples/catalyst-src/Cargo.toml similarity index 100% rename from examples/complex-example/catalyst-src/Cargo.toml rename to examples/complex-examples/catalyst-src/Cargo.toml diff --git a/examples/complex-example/catalyst-src/src/lib.rs b/examples/complex-examples/catalyst-src/src/lib.rs similarity index 100% rename from examples/complex-example/catalyst-src/src/lib.rs rename to examples/complex-examples/catalyst-src/src/lib.rs diff --git a/examples/complex-example/catalyst/Cargo.toml b/examples/complex-examples/catalyst/Cargo.toml similarity index 100% rename from examples/complex-example/catalyst/Cargo.toml rename to examples/complex-examples/catalyst/Cargo.toml diff --git a/examples/complex-example/catalyst/build.rs b/examples/complex-examples/catalyst/build.rs similarity index 100% rename from examples/complex-example/catalyst/build.rs rename to examples/complex-examples/catalyst/build.rs diff --git a/examples/complex-example/catalyst/src/lib.rs b/examples/complex-examples/catalyst/src/lib.rs similarity index 100% rename from examples/complex-example/catalyst/src/lib.rs rename to examples/complex-examples/catalyst/src/lib.rs diff --git a/examples/complex-example/substrate/Cargo.toml b/examples/complex-examples/substrate/Cargo.toml similarity index 100% rename from examples/complex-example/substrate/Cargo.toml rename to examples/complex-examples/substrate/Cargo.toml diff --git a/examples/complex-example/substrate/src/lib.rs b/examples/complex-examples/substrate/src/lib.rs similarity index 100% rename from examples/complex-example/substrate/src/lib.rs rename to examples/complex-examples/substrate/src/lib.rs diff --git a/flake.nix b/flake.nix index af8a2ab..64b1a71 100644 --- a/flake.nix +++ b/flake.nix @@ -22,7 +22,7 @@ checkCatalystScript = pkgs.writeShellScriptBin "check-catalyst" '' set -ex cd $(git rev-parse --show-toplevel 2>/dev/null) - cd examples/complex-example + cd examples/complex-examples cargo test --quiet -p substrate cargo test --quiet -p catalyst cargo test --quiet -p catalyst-src From 0cc174a521a7683e95fd38412e541c704725996c Mon Sep 17 00:00:00 2001 From: Antonio Yang Date: Sun, 30 Aug 2026 10:48:17 +0800 Subject: [PATCH 03/15] rn `check-complex` test script --- .github/workflows/test.yml | 4 ++-- flake.nix | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ad7254e..a48aee5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -81,5 +81,5 @@ jobs: nix develop .#no-std -c cargo run --quiet --features=box --bin no-std-box nix develop .#no-std -c cargo run --quiet --features=option --bin no-std-option - - name: Test with catalyst - run: nix develop .#ci -c check-catalyst + - name: Test complex examples + run: nix develop .#ci -c check-complex diff --git a/flake.nix b/flake.nix index 64b1a71..d0a6959 100644 --- a/flake.nix +++ b/flake.nix @@ -19,7 +19,7 @@ sleep 10 cargo publish -p struct-patch ''; - checkCatalystScript = pkgs.writeShellScriptBin "check-catalyst" '' + checkComplexScript = pkgs.writeShellScriptBin "check-complex" '' set -ex cd $(git rev-parse --show-toplevel 2>/dev/null) cd examples/complex-examples @@ -49,7 +49,7 @@ openssl pkg-config - checkCatalystScript + checkComplexScript ]; }; @@ -61,7 +61,7 @@ publishScript - checkCatalystScript + checkComplexScript ]; }; From 485871642d5d1a5b56feffb96badb23ab4ba91f5 Mon Sep 17 00:00:00 2001 From: Antonio Yang Date: Sun, 30 Aug 2026 10:52:41 +0800 Subject: [PATCH 04/15] add check-no-std script --- .github/workflows/test.yml | 5 +---- flake.nix | 10 +++++++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a48aee5..df54486 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -76,10 +76,7 @@ jobs: nix develop .#ci -c cargo test --quiet - name: Test in no std - run: | - cd examples/no-std-examples - nix develop .#no-std -c cargo run --quiet --features=box --bin no-std-box - nix develop .#no-std -c cargo run --quiet --features=option --bin no-std-option + run: nix develop .#no-std -c check-no-std - name: Test complex examples run: nix develop .#ci -c check-complex diff --git a/flake.nix b/flake.nix index d0a6959..77ea18c 100644 --- a/flake.nix +++ b/flake.nix @@ -19,6 +19,13 @@ sleep 10 cargo publish -p struct-patch ''; + checkNoStdScript = pkgs.writeShellScriptBin "check-no-std" '' + set -ex + cd $(git rev-parse --show-toplevel 2>/dev/null) + cd examples/no-std-examples + cargo run --quiet --features=box --bin no-std-box + cargo run --quiet --features=option --bin no-std-option + ''; checkComplexScript = pkgs.writeShellScriptBin "check-complex" '' set -ex cd $(git rev-parse --show-toplevel 2>/dev/null) @@ -67,8 +74,9 @@ no-std = mkShell { buildInputs = [ - noStdRust + noStdRust qemu + checkNoStdScript ]; }; }; From ef10ae5182bc11d45f15dd59dcb93f31f021118c Mon Sep 17 00:00:00 2001 From: Antonio Yang Date: Sun, 30 Aug 2026 11:06:06 +0800 Subject: [PATCH 05/15] refact devshells --- .github/workflows/lint.yml | 3 ++ flake.nix | 82 +++++++++--------------------------- nix/scripts/check-complex.sh | 10 +++++ nix/scripts/check-no-std.sh | 5 +++ nix/scripts/crate-publish.sh | 4 ++ nix/shells/ci.nix | 18 ++++++++ nix/shells/default.nix | 16 +++++++ nix/shells/no-std.nix | 21 +++++++++ 8 files changed, 97 insertions(+), 62 deletions(-) create mode 100644 nix/scripts/check-complex.sh create mode 100644 nix/scripts/check-no-std.sh create mode 100644 nix/scripts/crate-publish.sh create mode 100644 nix/shells/ci.nix create mode 100644 nix/shells/default.nix create mode 100644 nix/shells/no-std.nix diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 8f994a1..7103cee 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -17,6 +17,9 @@ jobs: with: github_access_token: ${{ secrets.GITHUB_TOKEN }} + - name: Nix flake check + run: nix flake check + - name: fmt run: nix develop .#ci -c cargo fmt diff --git a/flake.nix b/flake.nix index 77ea18c..8cb2b79 100644 --- a/flake.nix +++ b/flake.nix @@ -13,72 +13,30 @@ pkgs = import nixpkgs { inherit system overlays; }; - publishScript = pkgs.writeShellScriptBin "crate-publish" '' - cargo login $1 - cargo publish -p struct-patch-derive || echo "publish struct-patch-derive fail" - sleep 10 - cargo publish -p struct-patch - ''; - checkNoStdScript = pkgs.writeShellScriptBin "check-no-std" '' - set -ex - cd $(git rev-parse --show-toplevel 2>/dev/null) - cd examples/no-std-examples - cargo run --quiet --features=box --bin no-std-box - cargo run --quiet --features=option --bin no-std-option - ''; - checkComplexScript = pkgs.writeShellScriptBin "check-complex" '' - set -ex - cd $(git rev-parse --show-toplevel 2>/dev/null) - cd examples/complex-examples - cargo test --quiet -p substrate - cargo test --quiet -p catalyst - cargo test --quiet -p catalyst-src - echo "Run catatyst test with unsafe features" - cargo test --quiet -p catalyst --features unsafe - cargo test --quiet -p catalyst-src --features unsafe + publishScript = pkgs.writeShellScriptBin "crate-publish" + (builtins.readFile ./nix/scripts/crate-publish.sh); + checkNoStdScript = pkgs.writeShellScriptBin "check-no-std" + (builtins.readFile ./nix/scripts/check-no-std.sh); + checkComplexScript = pkgs.writeShellScriptBin "check-complex" + (builtins.readFile ./nix/scripts/check-complex.sh); + + PROMPT = '' + _git_ps1() { + git rev-parse --is-inside-work-tree &>/dev/null || return + local branch dirty + branch=$(git symbolic-ref --short HEAD 2>/dev/null) + [[ -n $(git status --porcelain) ]] && dirty='*' + echo "<$branch$dirty>" + } + PS1='\[\e[33m\][$DEVSHELL] \w $(_git_ps1) \$\[\e[0m\] ' ''; in - with pkgs; { - devShells = let - noStdRust = rust-bin.stable.latest.default.override { - targets = [ - "thumbv7m-none-eabi" - ]; - extensions = [ "rust-src" "llvm-tools-preview" ]; - }; - in - { - default = mkShell { - buildInputs = [ - rust-bin.stable.latest.minimal - openssl - pkg-config - - checkComplexScript - ]; - }; - - ci = mkShell { - buildInputs = [ - rust-bin.stable.latest.default - openssl - pkg-config - - publishScript - - checkComplexScript - ]; - }; - - no-std = mkShell { - buildInputs = [ - noStdRust - qemu - checkNoStdScript - ]; - }; + devShells = { + default = import ./nix/shells/default.nix { inherit pkgs checkComplexScript PROMPT; }; + ci = import ./nix/shells/ci.nix { inherit pkgs publishScript checkComplexScript PROMPT; }; + no-std = import ./nix/shells/no-std.nix { inherit pkgs checkNoStdScript PROMPT; }; }; } ); diff --git a/nix/scripts/check-complex.sh b/nix/scripts/check-complex.sh new file mode 100644 index 0000000..6ff60bf --- /dev/null +++ b/nix/scripts/check-complex.sh @@ -0,0 +1,10 @@ +set -ex +cd $(git rev-parse --show-toplevel 2>/dev/null) +cd examples/complex-examples +cargo test --quiet -p substrate +cargo test --quiet -p catalyst +cargo test --quiet -p catalyst-src + +echo "Run catalyst test with unsafe features" +cargo test --quiet -p catalyst --features unsafe +cargo test --quiet -p catalyst-src --features unsafe diff --git a/nix/scripts/check-no-std.sh b/nix/scripts/check-no-std.sh new file mode 100644 index 0000000..68210f8 --- /dev/null +++ b/nix/scripts/check-no-std.sh @@ -0,0 +1,5 @@ +set -ex +cd $(git rev-parse --show-toplevel 2>/dev/null) +cd examples/no-std-examples +cargo run --quiet --features=box --bin no-std-box +cargo run --quiet --features=option --bin no-std-option diff --git a/nix/scripts/crate-publish.sh b/nix/scripts/crate-publish.sh new file mode 100644 index 0000000..b579d4b --- /dev/null +++ b/nix/scripts/crate-publish.sh @@ -0,0 +1,4 @@ +cargo login $1 +cargo publish -p struct-patch-derive || echo "publish struct-patch-derive fail" +sleep 10 +cargo publish -p struct-patch diff --git a/nix/shells/ci.nix b/nix/shells/ci.nix new file mode 100644 index 0000000..6ee1be7 --- /dev/null +++ b/nix/shells/ci.nix @@ -0,0 +1,18 @@ +{ pkgs, publishScript, checkComplexScript, PROMPT ? "" }: +pkgs.mkShell { + name = "ci"; + shellHook = '' + export DEVSHELL=ci + ${PROMPT} + echo "Scripts:" + echo " ${publishScript.name}" + echo " ${checkComplexScript.name}" + ''; + buildInputs = [ + pkgs.rust-bin.stable.latest.default + pkgs.openssl + pkgs.pkg-config + publishScript + checkComplexScript + ]; +} diff --git a/nix/shells/default.nix b/nix/shells/default.nix new file mode 100644 index 0000000..8f94157 --- /dev/null +++ b/nix/shells/default.nix @@ -0,0 +1,16 @@ +{ pkgs, checkComplexScript, PROMPT ? "" }: +pkgs.mkShell { + name = "default"; + shellHook = '' + export DEVSHELL=default + ${PROMPT} + echo "Scripts:" + echo " ${checkComplexScript.name}" + ''; + buildInputs = [ + pkgs.rust-bin.stable.latest.minimal + pkgs.openssl + pkgs.pkg-config + checkComplexScript + ]; +} diff --git a/nix/shells/no-std.nix b/nix/shells/no-std.nix new file mode 100644 index 0000000..de8a3fd --- /dev/null +++ b/nix/shells/no-std.nix @@ -0,0 +1,21 @@ +{ pkgs, checkNoStdScript, PROMPT ? "" }: +let + noStdRust = pkgs.rust-bin.stable.latest.default.override { + targets = [ "thumbv7m-none-eabi" ]; + extensions = [ "rust-src" "llvm-tools-preview" ]; + }; +in +pkgs.mkShell { + name = "no-std"; + shellHook = '' + export DEVSHELL=no-std + ${PROMPT} + echo "Scripts:" + echo " ${checkNoStdScript.name}" + ''; + buildInputs = [ + noStdRust + pkgs.qemu + checkNoStdScript + ]; +} From fc54ddb8383199e6ced140a31666f6c94449bb8b Mon Sep 17 00:00:00 2001 From: Antonio Yang Date: Sun, 30 Aug 2026 11:23:10 +0800 Subject: [PATCH 06/15] add examples/patch-examples --- .github/dependabot.yml | 4 + .github/workflows/test.yml | 99 +++++++++++-------- .gitignore | 1 + Cargo.toml | 1 + examples/patch-examples/Cargo.toml | 32 ++++++ .../patch-examples}/examples/apply-by.rs | 0 .../patch-examples}/examples/box.rs | 0 .../patch-examples}/examples/clap.rs | 0 .../patch-examples}/examples/diff.rs | 0 .../patch-examples}/examples/instance.rs | 0 .../patch-examples}/examples/json.rs | 0 .../patch-examples}/examples/log.rs | 0 .../patch-examples}/examples/nesting.rs | 0 .../patch-examples}/examples/op.rs | 0 .../patch-examples}/examples/option.rs | 0 .../patch-examples}/examples/patch-attr.rs | 0 .../examples/rename-patch-struct.rs | 0 .../patch-examples}/examples/status.rs | 0 .../patch-examples}/examples/time.rs | 0 flake.nix | 1 - lib/Cargo.toml | 12 --- 21 files changed, 96 insertions(+), 54 deletions(-) create mode 100644 examples/patch-examples/Cargo.toml rename {lib => examples/patch-examples}/examples/apply-by.rs (100%) rename {lib => examples/patch-examples}/examples/box.rs (100%) rename {lib => examples/patch-examples}/examples/clap.rs (100%) rename {lib => examples/patch-examples}/examples/diff.rs (100%) rename {lib => examples/patch-examples}/examples/instance.rs (100%) rename {lib => examples/patch-examples}/examples/json.rs (100%) rename {lib => examples/patch-examples}/examples/log.rs (100%) rename {lib => examples/patch-examples}/examples/nesting.rs (100%) rename {lib => examples/patch-examples}/examples/op.rs (100%) rename {lib => examples/patch-examples}/examples/option.rs (100%) rename {lib => examples/patch-examples}/examples/patch-attr.rs (100%) rename {lib => examples/patch-examples}/examples/rename-patch-struct.rs (100%) rename {lib => examples/patch-examples}/examples/status.rs (100%) rename {lib => examples/patch-examples}/examples/time.rs (100%) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 95a2779..e88a5f3 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -24,3 +24,7 @@ updates: directory: "/examples/complex-examples" schedule: interval: "weekly" + - package-ecosystem: "cargo" + directory: "/examples/patch-examples" + schedule: + interval: "weekly" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index df54486..a7cca81 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,63 +17,80 @@ jobs: with: github_access_token: ${{ secrets.GITHUB_TOKEN }} - - name: Test no default features + - name: Test lib - no default features run: | - nix develop .#ci -c cargo run --quiet --no-default-features --example instance nix develop .#ci -c cargo run --quiet --no-default-features --example filler - nix develop .#ci -c cargo run --quiet --no-default-features --example diff - nix develop .#ci -c cargo run --quiet --no-default-features --example json - nix develop .#ci -c cargo run --quiet --no-default-features --example rename-patch-struct - nix develop .#ci -c cargo run --quiet --no-default-features --example patch-attr - nix develop .#ci -c cargo run --quiet --no-default-features --example time - nix develop .#ci -c cargo run --quiet --no-default-features --example clap - nix develop .#ci -c cargo run --quiet --no-default-features --features=nesting --example nesting - nix develop .#ci -c cargo run --quiet --no-default-features --features=option --example option - nix develop .#ci -c cargo run --quiet --no-default-features --example=log - nix develop .#ci -c cargo run --quiet --no-default-features --example apply-by - nix develop .#ci -c cargo run --quiet --no-default-features --features=box --example box nix develop .#ci -c cargo test --quiet --no-default-features - - name: Test with std features + - name: Test lib - std features run: | - nix develop .#ci -c cargo run --quiet --features=std --example instance nix develop .#ci -c cargo run --quiet --features=std --example filler nix develop .#ci -c cargo run --quiet --features=std --example filler-op - nix develop .#ci -c cargo run --quiet --features=std --example diff - nix develop .#ci -c cargo run --quiet --features=std --example json - nix develop .#ci -c cargo run --quiet --features=std --example rename-patch-struct - nix develop .#ci -c cargo run --quiet --features=std --example patch-attr - nix develop .#ci -c cargo run --quiet --features=std --example option - nix develop .#ci -c cargo run --quiet --features=std --example box - nix develop .#ci -c cargo run --quiet --features=std,nesting --example nesting nix develop .#ci -c cargo test --quiet --features=std - - name: Test with merge features + - name: Test lib - merge features run: | - nix develop .#ci -c cargo run --quiet --features=option,merge --example option - nix develop .#ci -c cargo run --quiet --features=merge --example op - nix develop .#ci -c cargo run --quiet --features=merge,nesting --example nesting nix develop .#ci -c cargo test --quiet --features=merge --no-default-features nix develop .#ci -c cargo test --quiet --features=merge - - name: Test with option features + - name: Test lib - default features + run: nix develop .#ci -c cargo test --quiet + + - name: Test patch examples - no default features + run: | + MANIFEST=examples/patch-examples/Cargo.toml + nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --no-default-features --example instance + nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --no-default-features --example filler + nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --no-default-features --example diff + nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --no-default-features --example json + nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --no-default-features --example rename-patch-struct + nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --no-default-features --example patch-attr + nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --no-default-features --example time + nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --no-default-features --example clap + nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --no-default-features --features=nesting --example nesting + nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --no-default-features --features=option --example option + nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --no-default-features --example log + nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --no-default-features --example apply-by + nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --no-default-features --features=box --example box + + - name: Test patch examples - std features + run: | + MANIFEST=examples/patch-examples/Cargo.toml + nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --features=std --example instance + nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --features=std --example diff + nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --features=std --example json + nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --features=std --example rename-patch-struct + nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --features=std --example patch-attr + nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --features=std --example option + nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --features=std --example box + nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --features=std,nesting --example nesting + + - name: Test patch examples - merge features + run: | + MANIFEST=examples/patch-examples/Cargo.toml + nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --features=option,merge --example option + nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --features=merge --example op + nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --features=merge,nesting --example nesting + + - name: Test patch examples - option features run: | - nix develop .#ci -c cargo run --quiet --features=none_as_default --example option - nix develop .#ci -c cargo run --quiet --features=none_as_default,nesting --example nesting - nix develop .#ci -c cargo run --quiet --features=keep_none --example option - nix develop .#ci -c cargo run --quiet --features=keep_none,nesting --example nesting + MANIFEST=examples/patch-examples/Cargo.toml + nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --features=none_as_default --example option + nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --features=none_as_default,nesting --example nesting + nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --features=keep_none --example option + nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --features=keep_none,nesting --example nesting - - name: Test with default features + - name: Test patch examples - default features run: | - nix develop .#ci -c cargo run --quiet --example status - nix develop .#ci -c cargo run --quiet --example op - nix develop .#ci -c cargo run --quiet --example clap - nix develop .#ci -c cargo run --quiet --features=nesting --example nesting - nix develop .#ci -c cargo run --quiet --features=nesting --example clap - nix develop .#ci -c cargo run --quiet --example=log - nix develop .#ci -c cargo run --quiet --example apply-by - nix develop .#ci -c cargo run --quiet --features=box --example box - nix develop .#ci -c cargo test --quiet + MANIFEST=examples/patch-examples/Cargo.toml + nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --example status + nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --example op + nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --example clap + nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --features=nesting --example nesting + nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --features=nesting --example clap + nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --example log + nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --example apply-by + nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --features=box --example box - name: Test in no std run: nix develop .#no-std -c check-no-std diff --git a/.gitignore b/.gitignore index dc0ab34..3ed6912 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ Cargo.lock struct-patch/examples examples/no-std-examples/target examples/complex-examples/target +examples/patch-examples/target diff --git a/Cargo.toml b/Cargo.toml index bde27dd..4b740b5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,7 @@ members = [ exclude = [ "examples/no-std-examples", "examples/complex-examples", + "examples/patch-examples", ] [workspace.package] diff --git a/examples/patch-examples/Cargo.toml b/examples/patch-examples/Cargo.toml new file mode 100644 index 0000000..7b47aa8 --- /dev/null +++ b/examples/patch-examples/Cargo.toml @@ -0,0 +1,32 @@ +[package] +name = "patch-examples" +authors = ["Antonio Yang "] +version = "0.14.1" +edition = "2021" +license = "MIT" + +[dependencies] +struct-patch = { path = "../../lib" } +serde_json = "1.0" +serde = { version = "1", features = ["derive"] } +serde_with = "3.9.0" +toml = "1.1.2" +humantime-serde = "1.1.1" +clap = { version = "4.4.7", features = ["derive"] } + +[features] +default = ["status", "op"] +status = ["struct-patch/status"] +op = ["struct-patch/op"] +merge = ["struct-patch/merge"] +alloc = ["struct-patch/alloc"] +std = ["box", "option"] +box = ["alloc", "struct-patch/box"] +option = ["struct-patch/option"] +nesting = ["struct-patch/nesting"] +none_as_default = ["option", "struct-patch/none_as_default"] +keep_none = ["option", "struct-patch/keep_none"] + +[[example]] +name = "box" +required-features = ["box"] diff --git a/lib/examples/apply-by.rs b/examples/patch-examples/examples/apply-by.rs similarity index 100% rename from lib/examples/apply-by.rs rename to examples/patch-examples/examples/apply-by.rs diff --git a/lib/examples/box.rs b/examples/patch-examples/examples/box.rs similarity index 100% rename from lib/examples/box.rs rename to examples/patch-examples/examples/box.rs diff --git a/lib/examples/clap.rs b/examples/patch-examples/examples/clap.rs similarity index 100% rename from lib/examples/clap.rs rename to examples/patch-examples/examples/clap.rs diff --git a/lib/examples/diff.rs b/examples/patch-examples/examples/diff.rs similarity index 100% rename from lib/examples/diff.rs rename to examples/patch-examples/examples/diff.rs diff --git a/lib/examples/instance.rs b/examples/patch-examples/examples/instance.rs similarity index 100% rename from lib/examples/instance.rs rename to examples/patch-examples/examples/instance.rs diff --git a/lib/examples/json.rs b/examples/patch-examples/examples/json.rs similarity index 100% rename from lib/examples/json.rs rename to examples/patch-examples/examples/json.rs diff --git a/lib/examples/log.rs b/examples/patch-examples/examples/log.rs similarity index 100% rename from lib/examples/log.rs rename to examples/patch-examples/examples/log.rs diff --git a/lib/examples/nesting.rs b/examples/patch-examples/examples/nesting.rs similarity index 100% rename from lib/examples/nesting.rs rename to examples/patch-examples/examples/nesting.rs diff --git a/lib/examples/op.rs b/examples/patch-examples/examples/op.rs similarity index 100% rename from lib/examples/op.rs rename to examples/patch-examples/examples/op.rs diff --git a/lib/examples/option.rs b/examples/patch-examples/examples/option.rs similarity index 100% rename from lib/examples/option.rs rename to examples/patch-examples/examples/option.rs diff --git a/lib/examples/patch-attr.rs b/examples/patch-examples/examples/patch-attr.rs similarity index 100% rename from lib/examples/patch-attr.rs rename to examples/patch-examples/examples/patch-attr.rs diff --git a/lib/examples/rename-patch-struct.rs b/examples/patch-examples/examples/rename-patch-struct.rs similarity index 100% rename from lib/examples/rename-patch-struct.rs rename to examples/patch-examples/examples/rename-patch-struct.rs diff --git a/lib/examples/status.rs b/examples/patch-examples/examples/status.rs similarity index 100% rename from lib/examples/status.rs rename to examples/patch-examples/examples/status.rs diff --git a/lib/examples/time.rs b/examples/patch-examples/examples/time.rs similarity index 100% rename from lib/examples/time.rs rename to examples/patch-examples/examples/time.rs diff --git a/flake.nix b/flake.nix index 8cb2b79..6b51fd3 100644 --- a/flake.nix +++ b/flake.nix @@ -20,7 +20,6 @@ (builtins.readFile ./nix/scripts/check-no-std.sh); checkComplexScript = pkgs.writeShellScriptBin "check-complex" (builtins.readFile ./nix/scripts/check-complex.sh); - PROMPT = '' _git_ps1() { git rev-parse --is-inside-work-tree &>/dev/null || return diff --git a/lib/Cargo.toml b/lib/Cargo.toml index b9e9822..10bf3f9 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -14,14 +14,6 @@ rust-version.workspace = true [dependencies] struct-patch-derive = { version = "=0.14.1", path = "../derive" } -[dev-dependencies] -serde_json = "1.0" -serde = { version = "1", features = ["derive"] } -serde_with = "3.9.0" -toml = "1.1.2" -humantime-serde = "1.1.1" -clap = { version = "4.4.7", features = ["derive"] } - [features] default = ["status", "op"] status = [ @@ -54,7 +46,3 @@ unsafe = [ "struct-patch-derive/unsafe" ] - -[[example]] -name = "box" -required-features = ["box"] From 8ba52b8fc38425b5a1e0161467ec711279bdadf5 Mon Sep 17 00:00:00 2001 From: Antonio Yang Date: Sun, 30 Aug 2026 11:28:36 +0800 Subject: [PATCH 07/15] fixup! add examples/patch-examples --- lib/Cargo.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/Cargo.toml b/lib/Cargo.toml index 10bf3f9..2f3b61b 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -14,6 +14,10 @@ rust-version.workspace = true [dependencies] struct-patch-derive = { version = "=0.14.1", path = "../derive" } +[dev-dependencies] +serde = { version = "1", features = ["derive"] } +serde_json = "1.0" + [features] default = ["status", "op"] status = [ From cacd8923f810863167fa917b890e81e36ff1b551 Mon Sep 17 00:00:00 2001 From: Antonio Yang Date: Sun, 30 Aug 2026 11:39:44 +0800 Subject: [PATCH 08/15] add `examples/filler-examples` --- .github/dependabot.yml | 4 ++++ .github/workflows/test.yml | 21 ++++++++++++------- Cargo.toml | 1 + examples/filler-examples/Cargo.toml | 14 +++++++++++++ .../filler-examples}/examples/filler-op.rs | 0 .../filler-examples}/examples/filler.rs | 0 6 files changed, 32 insertions(+), 8 deletions(-) create mode 100644 examples/filler-examples/Cargo.toml rename {lib => examples/filler-examples}/examples/filler-op.rs (100%) rename {lib => examples/filler-examples}/examples/filler.rs (100%) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index e88a5f3..672145d 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -28,3 +28,7 @@ updates: directory: "/examples/patch-examples" schedule: interval: "weekly" + - package-ecosystem: "cargo" + directory: "/examples/filler-examples" + schedule: + interval: "weekly" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a7cca81..29c1d61 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,15 +18,10 @@ jobs: github_access_token: ${{ secrets.GITHUB_TOKEN }} - name: Test lib - no default features - run: | - nix develop .#ci -c cargo run --quiet --no-default-features --example filler - nix develop .#ci -c cargo test --quiet --no-default-features + run: nix develop .#ci -c cargo test --quiet --no-default-features - name: Test lib - std features - run: | - nix develop .#ci -c cargo run --quiet --features=std --example filler - nix develop .#ci -c cargo run --quiet --features=std --example filler-op - nix develop .#ci -c cargo test --quiet --features=std + run: nix develop .#ci -c cargo test --quiet --features=std - name: Test lib - merge features run: | @@ -40,7 +35,6 @@ jobs: run: | MANIFEST=examples/patch-examples/Cargo.toml nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --no-default-features --example instance - nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --no-default-features --example filler nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --no-default-features --example diff nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --no-default-features --example json nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --no-default-features --example rename-patch-struct @@ -92,6 +86,17 @@ jobs: nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --example apply-by nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --features=box --example box + - name: Test filler examples - no default features + run: | + MANIFEST=examples/filler-examples/Cargo.toml + nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --no-default-features --example filler + + - name: Test filler examples - default features + run: | + MANIFEST=examples/filler-examples/Cargo.toml + nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --example filler + nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --example filler-op + - name: Test in no std run: nix develop .#no-std -c check-no-std diff --git a/Cargo.toml b/Cargo.toml index 4b740b5..915ff03 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,6 +8,7 @@ exclude = [ "examples/no-std-examples", "examples/complex-examples", "examples/patch-examples", + "examples/filler-examples", ] [workspace.package] diff --git a/examples/filler-examples/Cargo.toml b/examples/filler-examples/Cargo.toml new file mode 100644 index 0000000..07ae398 --- /dev/null +++ b/examples/filler-examples/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "filler-examples" +authors = ["Antonio Yang "] +version = "0.14.1" +edition = "2021" +license = "MIT" + +[dependencies] +struct-patch = { path = "../../lib" } + +[features] +default = ["status", "op"] +status = ["struct-patch/status"] +op = ["struct-patch/op"] diff --git a/lib/examples/filler-op.rs b/examples/filler-examples/examples/filler-op.rs similarity index 100% rename from lib/examples/filler-op.rs rename to examples/filler-examples/examples/filler-op.rs diff --git a/lib/examples/filler.rs b/examples/filler-examples/examples/filler.rs similarity index 100% rename from lib/examples/filler.rs rename to examples/filler-examples/examples/filler.rs From 3b1f14fec26d4a6d9d05ac9a9a10f70af3916781 Mon Sep 17 00:00:00 2001 From: Antonio Yang Date: Sun, 30 Aug 2026 11:48:43 +0800 Subject: [PATCH 09/15] add `check-filler` --- .github/workflows/test.yml | 9 ++------- flake.nix | 8 +++++--- nix/scripts/check-filler.sh | 25 +++++++++++++++++++++++++ nix/shells/ci.nix | 7 +++---- nix/shells/default.nix | 7 +++---- nix/shells/no-std.nix | 7 +++---- 6 files changed, 41 insertions(+), 22 deletions(-) create mode 100644 nix/scripts/check-filler.sh diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 29c1d61..4b9082e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -87,15 +87,10 @@ jobs: nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --features=box --example box - name: Test filler examples - no default features - run: | - MANIFEST=examples/filler-examples/Cargo.toml - nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --no-default-features --example filler + run: nix develop .#ci -c check-filler no-default - name: Test filler examples - default features - run: | - MANIFEST=examples/filler-examples/Cargo.toml - nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --example filler - nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --example filler-op + run: nix develop .#ci -c check-filler default - name: Test in no std run: nix develop .#no-std -c check-no-std diff --git a/flake.nix b/flake.nix index 6b51fd3..16ccc7a 100644 --- a/flake.nix +++ b/flake.nix @@ -20,6 +20,8 @@ (builtins.readFile ./nix/scripts/check-no-std.sh); checkComplexScript = pkgs.writeShellScriptBin "check-complex" (builtins.readFile ./nix/scripts/check-complex.sh); + checkFillerScript = pkgs.writeShellScriptBin "check-filler" + (builtins.readFile ./nix/scripts/check-filler.sh); PROMPT = '' _git_ps1() { git rev-parse --is-inside-work-tree &>/dev/null || return @@ -33,9 +35,9 @@ in { devShells = { - default = import ./nix/shells/default.nix { inherit pkgs checkComplexScript PROMPT; }; - ci = import ./nix/shells/ci.nix { inherit pkgs publishScript checkComplexScript PROMPT; }; - no-std = import ./nix/shells/no-std.nix { inherit pkgs checkNoStdScript PROMPT; }; + default = import ./nix/shells/default.nix { inherit pkgs PROMPT; checkScripts = [ checkComplexScript checkFillerScript ]; }; + ci = import ./nix/shells/ci.nix { inherit pkgs publishScript PROMPT; checkScripts = [ checkComplexScript checkFillerScript ]; }; + no-std = import ./nix/shells/no-std.nix { inherit pkgs PROMPT; checkScripts = [ checkNoStdScript ]; }; }; } ); diff --git a/nix/scripts/check-filler.sh b/nix/scripts/check-filler.sh new file mode 100644 index 0000000..9b56287 --- /dev/null +++ b/nix/scripts/check-filler.sh @@ -0,0 +1,25 @@ +set -ex +cd $(git rev-parse --show-toplevel 2>/dev/null) +cd examples/filler-examples + +run_no_default() { + cargo run --quiet --no-default-features --example filler +} + +run_default() { + cargo run --quiet --example filler + cargo run --quiet --example filler-op +} + +case "${1:-}" in + no-default) + run_no_default + ;; + default) + run_default + ;; + *) + run_no_default + run_default + ;; +esac diff --git a/nix/shells/ci.nix b/nix/shells/ci.nix index 6ee1be7..67fdd04 100644 --- a/nix/shells/ci.nix +++ b/nix/shells/ci.nix @@ -1,4 +1,4 @@ -{ pkgs, publishScript, checkComplexScript, PROMPT ? "" }: +{ pkgs, publishScript, checkScripts, PROMPT ? "" }: pkgs.mkShell { name = "ci"; shellHook = '' @@ -6,13 +6,12 @@ pkgs.mkShell { ${PROMPT} echo "Scripts:" echo " ${publishScript.name}" - echo " ${checkComplexScript.name}" + ${builtins.concatStringsSep "\n" (map (s: "echo \" ${s.name}\"") checkScripts)} ''; buildInputs = [ pkgs.rust-bin.stable.latest.default pkgs.openssl pkgs.pkg-config publishScript - checkComplexScript - ]; + ] ++ checkScripts; } diff --git a/nix/shells/default.nix b/nix/shells/default.nix index 8f94157..9a5a91f 100644 --- a/nix/shells/default.nix +++ b/nix/shells/default.nix @@ -1,16 +1,15 @@ -{ pkgs, checkComplexScript, PROMPT ? "" }: +{ pkgs, checkScripts, PROMPT ? "" }: pkgs.mkShell { name = "default"; shellHook = '' export DEVSHELL=default ${PROMPT} echo "Scripts:" - echo " ${checkComplexScript.name}" + ${builtins.concatStringsSep "\n" (map (s: "echo \" ${s.name}\"") checkScripts)} ''; buildInputs = [ pkgs.rust-bin.stable.latest.minimal pkgs.openssl pkgs.pkg-config - checkComplexScript - ]; + ] ++ checkScripts; } diff --git a/nix/shells/no-std.nix b/nix/shells/no-std.nix index de8a3fd..3a6a235 100644 --- a/nix/shells/no-std.nix +++ b/nix/shells/no-std.nix @@ -1,4 +1,4 @@ -{ pkgs, checkNoStdScript, PROMPT ? "" }: +{ pkgs, checkScripts, PROMPT ? "" }: let noStdRust = pkgs.rust-bin.stable.latest.default.override { targets = [ "thumbv7m-none-eabi" ]; @@ -11,11 +11,10 @@ pkgs.mkShell { export DEVSHELL=no-std ${PROMPT} echo "Scripts:" - echo " ${checkNoStdScript.name}" + ${builtins.concatStringsSep "\n" (map (s: "echo \" ${s.name}\"") checkScripts)} ''; buildInputs = [ noStdRust pkgs.qemu - checkNoStdScript - ]; + ] ++ checkScripts; } From 2fb983f9c72e6f81b80a4bddeed1ce9b97403c1a Mon Sep 17 00:00:00 2001 From: Antonio Yang Date: Sun, 30 Aug 2026 11:51:12 +0800 Subject: [PATCH 10/15] add `check-patch` --- .github/workflows/test.yml | 50 +++--------------------- flake.nix | 6 ++- nix/scripts/check-patch.sh | 78 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+), 47 deletions(-) create mode 100644 nix/scripts/check-patch.sh diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4b9082e..4fda000 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,59 +32,19 @@ jobs: run: nix develop .#ci -c cargo test --quiet - name: Test patch examples - no default features - run: | - MANIFEST=examples/patch-examples/Cargo.toml - nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --no-default-features --example instance - nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --no-default-features --example diff - nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --no-default-features --example json - nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --no-default-features --example rename-patch-struct - nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --no-default-features --example patch-attr - nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --no-default-features --example time - nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --no-default-features --example clap - nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --no-default-features --features=nesting --example nesting - nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --no-default-features --features=option --example option - nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --no-default-features --example log - nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --no-default-features --example apply-by - nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --no-default-features --features=box --example box + run: nix develop .#ci -c check-patch no-default - name: Test patch examples - std features - run: | - MANIFEST=examples/patch-examples/Cargo.toml - nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --features=std --example instance - nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --features=std --example diff - nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --features=std --example json - nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --features=std --example rename-patch-struct - nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --features=std --example patch-attr - nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --features=std --example option - nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --features=std --example box - nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --features=std,nesting --example nesting + run: nix develop .#ci -c check-patch std - name: Test patch examples - merge features - run: | - MANIFEST=examples/patch-examples/Cargo.toml - nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --features=option,merge --example option - nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --features=merge --example op - nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --features=merge,nesting --example nesting + run: nix develop .#ci -c check-patch merge - name: Test patch examples - option features - run: | - MANIFEST=examples/patch-examples/Cargo.toml - nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --features=none_as_default --example option - nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --features=none_as_default,nesting --example nesting - nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --features=keep_none --example option - nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --features=keep_none,nesting --example nesting + run: nix develop .#ci -c check-patch option - name: Test patch examples - default features - run: | - MANIFEST=examples/patch-examples/Cargo.toml - nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --example status - nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --example op - nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --example clap - nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --features=nesting --example nesting - nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --features=nesting --example clap - nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --example log - nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --example apply-by - nix develop .#ci -c cargo run --quiet --manifest-path $MANIFEST --features=box --example box + run: nix develop .#ci -c check-patch default - name: Test filler examples - no default features run: nix develop .#ci -c check-filler no-default diff --git a/flake.nix b/flake.nix index 16ccc7a..5ae4c41 100644 --- a/flake.nix +++ b/flake.nix @@ -22,6 +22,8 @@ (builtins.readFile ./nix/scripts/check-complex.sh); checkFillerScript = pkgs.writeShellScriptBin "check-filler" (builtins.readFile ./nix/scripts/check-filler.sh); + checkPatchScript = pkgs.writeShellScriptBin "check-patch" + (builtins.readFile ./nix/scripts/check-patch.sh); PROMPT = '' _git_ps1() { git rev-parse --is-inside-work-tree &>/dev/null || return @@ -35,8 +37,8 @@ in { devShells = { - default = import ./nix/shells/default.nix { inherit pkgs PROMPT; checkScripts = [ checkComplexScript checkFillerScript ]; }; - ci = import ./nix/shells/ci.nix { inherit pkgs publishScript PROMPT; checkScripts = [ checkComplexScript checkFillerScript ]; }; + default = import ./nix/shells/default.nix { inherit pkgs PROMPT; checkScripts = [ checkComplexScript checkFillerScript checkPatchScript ]; }; + ci = import ./nix/shells/ci.nix { inherit pkgs publishScript PROMPT; checkScripts = [ checkComplexScript checkFillerScript checkPatchScript ]; }; no-std = import ./nix/shells/no-std.nix { inherit pkgs PROMPT; checkScripts = [ checkNoStdScript ]; }; }; } diff --git a/nix/scripts/check-patch.sh b/nix/scripts/check-patch.sh new file mode 100644 index 0000000..c1bf126 --- /dev/null +++ b/nix/scripts/check-patch.sh @@ -0,0 +1,78 @@ +set -ex +cd $(git rev-parse --show-toplevel 2>/dev/null) +cd examples/patch-examples + +run_no_default() { + cargo run --quiet --no-default-features --example instance + cargo run --quiet --no-default-features --example diff + cargo run --quiet --no-default-features --example json + cargo run --quiet --no-default-features --example rename-patch-struct + cargo run --quiet --no-default-features --example patch-attr + cargo run --quiet --no-default-features --example time + cargo run --quiet --no-default-features --example clap + cargo run --quiet --no-default-features --features=nesting --example nesting + cargo run --quiet --no-default-features --features=option --example option + cargo run --quiet --no-default-features --example log + cargo run --quiet --no-default-features --example apply-by + cargo run --quiet --no-default-features --features=box --example box +} + +run_std() { + cargo run --quiet --features=std --example instance + cargo run --quiet --features=std --example diff + cargo run --quiet --features=std --example json + cargo run --quiet --features=std --example rename-patch-struct + cargo run --quiet --features=std --example patch-attr + cargo run --quiet --features=std --example option + cargo run --quiet --features=std --example box + cargo run --quiet --features=std,nesting --example nesting +} + +run_merge() { + cargo run --quiet --features=option,merge --example option + cargo run --quiet --features=merge --example op + cargo run --quiet --features=merge,nesting --example nesting +} + +run_option() { + cargo run --quiet --features=none_as_default --example option + cargo run --quiet --features=none_as_default,nesting --example nesting + cargo run --quiet --features=keep_none --example option + cargo run --quiet --features=keep_none,nesting --example nesting +} + +run_default() { + cargo run --quiet --example status + cargo run --quiet --example op + cargo run --quiet --example clap + cargo run --quiet --features=nesting --example nesting + cargo run --quiet --features=nesting --example clap + cargo run --quiet --example log + cargo run --quiet --example apply-by + cargo run --quiet --features=box --example box +} + +case "${1:-}" in + no-default) + run_no_default + ;; + std) + run_std + ;; + merge) + run_merge + ;; + option) + run_option + ;; + default) + run_default + ;; + *) + run_no_default + run_std + run_merge + run_option + run_default + ;; +esac From 751e7f6bc92f17b76546a3b5110b4fd67c44fdfc Mon Sep 17 00:00:00 2001 From: Antonio Yang Date: Sun, 30 Aug 2026 11:54:08 +0800 Subject: [PATCH 11/15] readme --- README.md | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 29a65b9..8762a68 100644 --- a/README.md +++ b/README.md @@ -17,15 +17,15 @@ This crate provides the `Patch`, `Filler`, `Substrate`, `Catalyst` and `Complex` - If any field in the instance is empty (`None` or an empty collection), `Filler` will try to fill it. It supports `Option`, `Vec`, `VecDeque`, `LinkedList`, `HashMap`, `BTreeMap`, `HashSet`, `BTreeSet`, `BinaryHeap` fields, as well as custom types via `#[filler(extendable)]` and any type via `#[filler(empty_value = ...)]`. - With the `substrate` feature, the `Substrate` derive macro exposes field information so that other crates can access it. With the `catalyst` feature (which implies `substrate`), `Catalyst` and `Complex` derive macros help you extend a struct with extra fields from another crate. -This crate supports `no_std` — check the [no-std-examples](./no-std-examples). +This crate supports `no_std` — check the [no-std-examples](./examples/no-std-examples). The following are more specific scenarios to help you learn the details: - A project with config from environments, files, and command line: you can use `Patch` to keep your config organized. Please check this [template](https://github.com/yanganto/ConfigTemplate). -- A project extended from another project, where only some fields of the config differ. You can use the `catalyst` feature to expose the base struct in a build script with `Substrate`, then a `Catalyst` struct can bind to it and produce a complex struct. Check the [complex-example](./complex-example) and [Quick Example: case 3](#case-3---extend-a-struct-from-a-crate). +- A project extended from another project, where only some fields of the config differ. You can use the `catalyst` feature to expose the base struct in a build script with `Substrate`, then a `Catalyst` struct can bind to it and produce a complex struct. Check the [complex-examples](./examples/complex-examples) and [Quick Example: case 3](#case-3---extend-a-struct-from-a-crate). ## Quick Example -#### Case 1 - Patch on a Config +#### Case 1 (Patch) - Patch on a Config Deriving `Patch` on a struct generates a struct similar to the original one, but with all fields wrapped in an `Option`. An instance of such a patch struct can be applied onto the original struct, replacing values only if they are set to `Some`, leaving them unchanged otherwise. See also Case Studies: @@ -82,7 +82,7 @@ fn patch_json() { } ``` -#### Case 2 - Fill up on a Config +#### Case 2 (Filler) - Fill up on a Config Deriving `Filler` on a struct generates a struct similar to the original one, keeping only the fields that can be filled (`Option`, collections, `extendable`, or `empty_value` fields). Unlike `Patch`, the `Filler` only works on empty fields of the instance. See also Case Studies: - [Log which fields were patched or filled](docs/logs.md) @@ -119,11 +119,11 @@ assert_eq!(item.maybe_field_int, Some(7)); assert_eq!(item.list, vec![7]); ``` -#### Case 3 - Extend a struct from a crate +#### Case 3 (Complex) - Extend a struct from a crate Deriving `Substrate` on a struct exposes the field information so that other crates can access it. Deriving `Catalyst` reads the field information of a `Substrate` and generates a new complex struct. In the other words, the catalyst is a struct with extra fields that the developer writes down in the downstream crate. The complex is a generated struct that combines the substrate's fields with the catalyst's extra fields. The overall behavior is like [chemical catalysts](https://en.wikipedia.org/wiki/Enzyme_catalysis): a catalyst **binds** onto a substrate to form a complex struct, which has all fields from both. -A complex can also **decouple** without cloning, returning the original catalyst and substrate. Check the [complex-example](./complex-example/catalyst/src/lib.rs). +A complex can also **decouple** without cloning, returning the original catalyst and substrate. Check the [complex-examples](./examples/complex-examples/catalyst/src/lib.rs). With the `unsafe` feature, `bind` and `decouple` use `ManuallyDrop` + `ptr::read` to avoid memory moves, and `__substrate_new` uses `MaybeUninit` + `ptr::write` while `__substrate_unpack` uses `ManuallyDrop` + `ptr::read`, such that the copy will be less. In terms of crate dependencies, the crate using `Substrate` is **upstream** (a dependency), and the crate using `Catalyst` is **downstream** (it depends on the substrate crate). There are two ways for the downstream crate to read the substrate's field layout: @@ -165,7 +165,7 @@ struct Amyloid { // } ``` -**Option B: via source code with `src` attribute**: point the `Catalyst` macro directly at the substrate crate's source file using `#[catalyst(src = "crate_name:/path/to/file.rs")]`. The macro uses `cargo_metadata` to locate the package and `syn` to parse the file, so no `build.rs` or `expose()` call is required. Check the [catalyst-src example](./complex-example/catalyst-src/src/lib.rs). +**Option B: via source code with `src` attribute**: point the `Catalyst` macro directly at the substrate crate's source file using `#[catalyst(src = "crate_name:/path/to/file.rs")]`. The macro uses `cargo_metadata` to locate the package and `syn` to parse the file, so no `build.rs` or `expose()` call is required. Check the [catalyst-src example](./examples/complex-examples/catalyst-src/src/lib.rs). ```rust /// In the substrate crate (src/lib.rs) @@ -231,7 +231,9 @@ Please check the [traits documentation][doc-traits] to learn more. ## Examples -The [examples][examples] demonstrate the following scenarios: +Examples are organised into focused sub-projects under [`examples/`](./examples): + +**[patch-examples](./examples/patch-examples)** — `Patch` derive macro scenarios: - diff two instances for a patch (`diff.rs`) - create a patch from a JSON string (`json.rs`) - rename the patch structure (`rename-patch-struct.rs`) @@ -241,14 +243,20 @@ The [examples][examples] demonstrate the following scenarios: - show operators on patches (`op.rs`) - show example with serde crates, e.g. `humantime_serde` for durations (`time.rs`) - show a patch nesting another patch (`nesting.rs`) -- show filler with all possible types (`filler.rs`) -- show operators on fillers (`filler-op.rs`) - show `skip_wrap` field behavior (`instance.rs`) - use `Patch` with `clap` for command-line config (`clap.rs`) - demonstrate `default_log` and `apply_with_log` for both `Patch` and `Filler` (`log.rs`) - apply a heap-allocated (boxed) patch and produce a boxed diff (`box.rs`) - demonstrate `apply_by` for custom field-level apply logic, e.g. list concatenation (`apply-by.rs`) +**[filler-examples](./examples/filler-examples)** — `Filler` derive macro scenarios: +- show filler with all possible types (`filler.rs`) +- show operators on fillers (`filler-op.rs`) + +**[no-std-examples](./examples/no-std-examples)** — `no_std` usage with a bare-metal target. + +**[complex-examples](./examples/complex-examples)** — `Substrate` / `Catalyst` / `Complex` derive macros for extending a struct across crates. + ## Features This crate includes the following optional features: @@ -275,4 +283,4 @@ This crate includes the following optional features: [doc-badge]: https://img.shields.io/badge/docs-rs-orange.svg [doc-url]: https://docs.rs/struct-patch/ [doc-traits]: https://docs.rs/struct-patch/latest/struct_patch/traits/trait.Patch.html#container-attributes -[examples]: /lib/examples +[examples]: /examples From 251cfbf939ab2556e3aab3947ed127d3e36308d5 Mon Sep 17 00:00:00 2001 From: Antonio Yang Date: Sun, 30 Aug 2026 14:42:01 +0800 Subject: [PATCH 12/15] move lib test to scripts --- .github/workflows/test.yml | 47 +++++++++++++------------------------- flake.nix | 6 +++-- nix/scripts/test.sh | 40 ++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 33 deletions(-) create mode 100644 nix/scripts/test.sh diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4fda000..814413b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,40 +17,25 @@ jobs: with: github_access_token: ${{ secrets.GITHUB_TOKEN }} - - name: Test lib - no default features - run: nix develop .#ci -c cargo test --quiet --no-default-features - - - name: Test lib - std features - run: nix develop .#ci -c cargo test --quiet --features=std - - - name: Test lib - merge features + - name: Test lib run: | - nix develop .#ci -c cargo test --quiet --features=merge --no-default-features - nix develop .#ci -c cargo test --quiet --features=merge - - - name: Test lib - default features - run: nix develop .#ci -c cargo test --quiet - - - name: Test patch examples - no default features - run: nix develop .#ci -c check-patch no-default - - - name: Test patch examples - std features - run: nix develop .#ci -c check-patch std + nix develop .#ci -c test no-default + nix develop .#ci -c cargo test std + nix develop .#ci -c cargo test merge + nix develop .#ci -c cargo test default - - name: Test patch examples - merge features - run: nix develop .#ci -c check-patch merge - - - name: Test patch examples - option features - run: nix develop .#ci -c check-patch option - - - name: Test patch examples - default features - run: nix develop .#ci -c check-patch default - - - name: Test filler examples - no default features - run: nix develop .#ci -c check-filler no-default + - name: Test patch examples + run: | + nix develop .#ci -c check-patch no-default + nix develop .#ci -c check-patch std + nix develop .#ci -c check-patch merge + nix develop .#ci -c check-patch option + nix develop .#ci -c check-patch default - - name: Test filler examples - default features - run: nix develop .#ci -c check-filler default + - name: Test filler examples + run: | + nix develop .#ci -c check-filler no-default + nix develop .#ci -c check-filler default - name: Test in no std run: nix develop .#no-std -c check-no-std diff --git a/flake.nix b/flake.nix index 5ae4c41..fb330d7 100644 --- a/flake.nix +++ b/flake.nix @@ -24,6 +24,8 @@ (builtins.readFile ./nix/scripts/check-filler.sh); checkPatchScript = pkgs.writeShellScriptBin "check-patch" (builtins.readFile ./nix/scripts/check-patch.sh); + testScript = pkgs.writeShellScriptBin "test" + (builtins.readFile ./nix/scripts/test.sh); PROMPT = '' _git_ps1() { git rev-parse --is-inside-work-tree &>/dev/null || return @@ -37,8 +39,8 @@ in { devShells = { - default = import ./nix/shells/default.nix { inherit pkgs PROMPT; checkScripts = [ checkComplexScript checkFillerScript checkPatchScript ]; }; - ci = import ./nix/shells/ci.nix { inherit pkgs publishScript PROMPT; checkScripts = [ checkComplexScript checkFillerScript checkPatchScript ]; }; + default = import ./nix/shells/default.nix { inherit pkgs PROMPT; checkScripts = [ checkComplexScript checkFillerScript checkPatchScript testScript ]; }; + ci = import ./nix/shells/ci.nix { inherit pkgs publishScript PROMPT; checkScripts = [ checkComplexScript checkFillerScript checkPatchScript testScript ]; }; no-std = import ./nix/shells/no-std.nix { inherit pkgs PROMPT; checkScripts = [ checkNoStdScript ]; }; }; } diff --git a/nix/scripts/test.sh b/nix/scripts/test.sh new file mode 100644 index 0000000..5ec58ff --- /dev/null +++ b/nix/scripts/test.sh @@ -0,0 +1,40 @@ +set -ex +cd $(git rev-parse --show-toplevel 2>/dev/null) + +run_no_default() { + cargo test --quiet --no-default-features +} + +run_std() { + cargo test --quiet --features=std +} + +run_merge() { + cargo test --quiet --features=merge --no-default-features + cargo test --quiet --features=merge +} + +run_default() { + cargo test --quiet +} + +case "${1:-}" in + no-default) + run_no_default + ;; + std) + run_std + ;; + merge) + run_merge + ;; + default) + run_default + ;; + *) + run_no_default + run_std + run_merge + run_default + ;; +esac From baaa1adee4a5feb865591deb1ec125b4698526ee Mon Sep 17 00:00:00 2001 From: Antonio Yang Date: Sun, 30 Aug 2026 14:48:18 +0800 Subject: [PATCH 13/15] fixup! move lib test to scripts --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 814413b..ebd84e7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,9 +20,9 @@ jobs: - name: Test lib run: | nix develop .#ci -c test no-default - nix develop .#ci -c cargo test std - nix develop .#ci -c cargo test merge - nix develop .#ci -c cargo test default + nix develop .#ci -c test std + nix develop .#ci -c test merge + nix develop .#ci -c test default - name: Test patch examples run: | From a26a13ab6ddd2b28bdd37266dc4d6e652d21b545 Mon Sep 17 00:00:00 2001 From: Antonio Yang Date: Sun, 30 Aug 2026 15:01:28 +0800 Subject: [PATCH 14/15] remove print check stripts in ci devshell --- nix/shells/ci.nix | 3 --- 1 file changed, 3 deletions(-) diff --git a/nix/shells/ci.nix b/nix/shells/ci.nix index 67fdd04..d919d7b 100644 --- a/nix/shells/ci.nix +++ b/nix/shells/ci.nix @@ -4,9 +4,6 @@ pkgs.mkShell { shellHook = '' export DEVSHELL=ci ${PROMPT} - echo "Scripts:" - echo " ${publishScript.name}" - ${builtins.concatStringsSep "\n" (map (s: "echo \" ${s.name}\"") checkScripts)} ''; buildInputs = [ pkgs.rust-bin.stable.latest.default From 3138f0dc9c3bf10fd0d647340f6797650b50fce3 Mon Sep 17 00:00:00 2001 From: Antonio Yang Date: Sun, 30 Aug 2026 15:05:20 +0800 Subject: [PATCH 15/15] ci: split devshell build step --- .github/workflows/test.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ebd84e7..410a754 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,6 +17,11 @@ jobs: with: github_access_token: ${{ secrets.GITHUB_TOKEN }} + - name: Build devshells + run: | + nix develop .#ci -c echo Build ci devshell + nix develop .#no-std -c echo Build no-std devshell + - name: Test lib run: | nix develop .#ci -c test no-default