From 3aba21045deaa4d18e7fb7b44f328ba4cf9fb84f Mon Sep 17 00:00:00 2001 From: Einherjar Date: Fri, 20 Oct 2023 16:41:01 -0300 Subject: [PATCH] ci(nix): add rust nightly docs --- .github/workflows/nightly_docs.yml | 32 ++++++++++++++--------------- crates/bdk/src/keys/mod.rs | 2 +- crates/bdk/src/wallet/tx_builder.rs | 2 +- flake.nix | 9 ++++++++ 4 files changed, 26 insertions(+), 19 deletions(-) diff --git a/.github/workflows/nightly_docs.yml b/.github/workflows/nightly_docs.yml index 0321cc5337..7b9fc36be5 100644 --- a/.github/workflows/nightly_docs.yml +++ b/.github/workflows/nightly_docs.yml @@ -7,22 +7,20 @@ jobs: name: Build docs runs-on: ubuntu-latest steps: - - name: Checkout sources - uses: actions/checkout@v2 - - name: Set default toolchain - run: rustup default nightly-2022-12-14 - - name: Set profile - run: rustup set profile minimal - - name: Update toolchain - run: rustup update - - name: Rust Cache - uses: Swatinem/rust-cache@v2.2.1 + - name: checkout + uses: actions/checkout@v4 + - name: Install Nix + uses: DeterminateSystems/nix-installer-action@v5 + # Cache Nix artifacts + - uses: cachix/cachix-action@v12 + with: + name: bitcoindevkit + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + continue-on-error: true # for forks outside of bitcoindevkit GH org - name: Build docs - run: cargo doc --no-deps - env: - RUSTDOCFLAGS: '--cfg docsrs -Dwarnings' + run: nix develop -L .#docsNightly --command bash -c "cargo doc --no-deps" - name: Upload artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: built-docs path: ./target/doc/* @@ -34,7 +32,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout `bitcoindevkit.org` - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: ssh-key: ${{ secrets.DOCS_PUSH_SSH_KEY }} repository: bitcoindevkit/bitcoindevkit.org @@ -44,14 +42,14 @@ jobs: - name: Remove old latest run: rm -rf ./docs/.vuepress/public/docs-rs/bdk/nightly/latest - name: Download built docs - uses: actions/download-artifact@v1 + uses: actions/download-artifact@v3 with: name: built-docs path: ./docs/.vuepress/public/docs-rs/bdk/nightly/latest - name: Configure git run: git config user.email "github-actions@github.com" && git config user.name "github-actions" - name: Commit - continue-on-error: true # If there's nothing to commit this step fails, but it's fine + continue-on-error: true # If there's nothing to commit this step fails, but it's fine run: git add ./docs/.vuepress/public/docs-rs && git commit -m "Publish autogenerated nightly docs" - name: Push run: git push origin master diff --git a/crates/bdk/src/keys/mod.rs b/crates/bdk/src/keys/mod.rs index b47c4b86d4..8c1949c2ed 100644 --- a/crates/bdk/src/keys/mod.rs +++ b/crates/bdk/src/keys/mod.rs @@ -413,7 +413,7 @@ impl From for ExtendedKey { /// } /// ``` /// -/// Types that don't internally encode the [`Network`](bitcoin::Network) in which they are valid need some extra +/// Types that don't internally encode the [`Network`] in which they are valid need some extra /// steps to override the set of valid networks, otherwise only the network specified in the /// [`ExtendedPrivKey`] or [`ExtendedPubKey`] will be considered valid. /// diff --git a/crates/bdk/src/wallet/tx_builder.rs b/crates/bdk/src/wallet/tx_builder.rs index 37e85a1240..ea61894567 100644 --- a/crates/bdk/src/wallet/tx_builder.rs +++ b/crates/bdk/src/wallet/tx_builder.rs @@ -520,7 +520,7 @@ impl<'a, D, Cs: CoinSelectionAlgorithm, Ctx: TxBuilderContext> TxBuilder<'a, D, /// Choose the coin selection algorithm /// - /// Overrides the [`DefaultCoinSelectionAlgorithm`](super::coin_selection::DefaultCoinSelectionAlgorithm). + /// Overrides the [`DefaultCoinSelectionAlgorithm`]. /// /// Note that this function consumes the builder and returns it so it is usually best to put this as the first call on the builder. pub fn coin_selection( diff --git a/flake.nix b/flake.nix index afdf13d0b4..999e6a544c 100644 --- a/flake.nix +++ b/flake.nix @@ -70,6 +70,8 @@ rustLLVMTarget = pkgs.rust-bin.stable.latest.default.override { extensions = [ "llvm-tools" ]; }; + # Nighly Docs + rustNightlyTarget = pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.default); # Rust configs craneLib = (crane.mkLib pkgs).overrideToolchain rustTarget; @@ -83,6 +85,7 @@ craneWASMLib = ((crane.mkLib pkgs).overrideToolchain rustWASMTarget).overrideScope' (final: prev: { inherit (craneLib) craneUtils; }); # LLVM code coverage craneLLVMLib = (crane.mkLib pkgs).overrideToolchain rustLLVMTarget; + craneNightlyLib = (crane.mkLib pkgs).overrideToolchain rustNightlyTarget; # Common inputs for all derivations buildInputs = [ @@ -376,6 +379,12 @@ lcov = pkgs.mkShell { buildInputs = [ pkgs.lcov ]; }; + docsNightly = craneNightlyLib.devShell { + packages = buildInputs ++ [ rustNightlyTarget ]; + RUSTDOCFLAGS = "--cfg docsrs -Dwarnings"; + BITCOIND_EXEC = commonArgs.BITCOIND_EXEC; + ELECTRS_EXEC = commonArgs.ELECTRS_EXEC; + }; }; } );