From 107cd79721041c7bae807748eff5ee97706924ef Mon Sep 17 00:00:00 2001 From: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com> Date: Tue, 19 Dec 2023 09:22:28 +1000 Subject: [PATCH] Update readme from code (#1188) ### What Update readme using make target and add a CI job to check its updated. ### Why Noticed our readme is out of date with the code it is generated from. --- .github/workflows/rust.yml | 11 ++++++++++- soroban-sdk/README.md | 11 +++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 6e7ce7805..bc8fe0865 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -17,7 +17,7 @@ jobs: complete: if: always() - needs: [fmt, check-git-rev-deps, build-and-test, docs] + needs: [fmt, check-git-rev-deps, build-and-test, docs, readme] runs-on: ubuntu-latest steps: - if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') @@ -132,6 +132,15 @@ jobs: - run: rustup install nightly - run: make doc + readme: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: stellar/actions/rust-cache@main + - run: rustup install nightly + - run: make readme + - run: git add -N . && git diff HEAD --exit-code + publish-dry-run: if: github.event_name == 'push' || startsWith(github.head_ref, 'release/') strategy: diff --git a/soroban-sdk/README.md b/soroban-sdk/README.md index f707b12d5..2aef6d4c3 100644 --- a/soroban-sdk/README.md +++ b/soroban-sdk/README.md @@ -8,8 +8,9 @@ See [soroban.stellar.org](https://soroban.stellar.org) for documentation. ### Examples ```rust -use soroban_sdk::{contractimpl, vec, BytesN, Env, Symbol, Vec}; +use soroban_sdk::{contract, contractimpl, vec, symbol_short, BytesN, Env, Symbol, Vec}; +#[contract] pub struct HelloContract; #[contractimpl] @@ -21,6 +22,9 @@ impl HelloContract { #[test] fn test() { +# } +# #[cfg(feature = "testutils")] +# fn main() { let env = Env::default(); let contract_id = env.register_contract(None, HelloContract); let client = HelloContractClient::new(&env, &contract_id); @@ -29,6 +33,9 @@ fn test() { assert_eq!(words, vec![&env, symbol_short!("Hello"), symbol_short!("Dev"),]); } +# #[cfg(not(feature = "testutils"))] +# fn main() { } ``` -More examples are available at . +More examples are available at +and .