From 3f9f219e2d609055822dca344976298bf52daaa6 Mon Sep 17 00:00:00 2001 From: Mykhailo Lohachov Date: Wed, 27 Nov 2024 19:47:18 +0900 Subject: [PATCH] ci: link checking (#5252) Signed-off-by: Lohachov Mykhailo --- .github/workflows/iroha2-doc-links.yml | 30 ++++++++++++++++++++++++++ CONTRIBUTING.md | 6 ++---- crates/iroha/examples/tutorial.rs | 1 - crates/iroha_wasm_builder/src/lib.rs | 2 +- lychee.toml | 16 ++++++++++++++ wasm/libs/default_executor/README.md | 2 +- 6 files changed, 50 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/iroha2-doc-links.yml create mode 100644 lychee.toml diff --git a/.github/workflows/iroha2-doc-links.yml b/.github/workflows/iroha2-doc-links.yml new file mode 100644 index 00000000000..d9bc2bbf242 --- /dev/null +++ b/.github/workflows/iroha2-doc-links.yml @@ -0,0 +1,30 @@ +name: I2::Doc::Links + +# Verify all links in text files and generated documentation +# from source files are valid (return 200-like http code). +# https://github.com/lycheeverse/lychee + +on: + pull_request: + branches: [main, stable, lts] + paths: + - '**/*.md' + - '**/*.txt' + - '**/*.html' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + link_checker: + runs-on: [ubuntu-latest] + steps: + - uses: actions/checkout@v4 + + - name: Link Checker + id: lychee + uses: lycheeverse/lychee-action@v2 + with: + args: "'**/*.rs' ." # Check rust source and default text files + fail: true diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 120d232b999..a79912111f3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -171,7 +171,7 @@ To pass the *`check-PR-title`* check, the pull request title must adhere to the ### Git Workflow - [Fork](https://docs.github.com/en/get-started/quickstart/fork-a-repo) the [repository](https://github.com/hyperledger-iroha/iroha/tree/main) and [create a feature branch](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-and-deleting-branches-within-your-repository) for your contributions. -- [Configure the remote](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/configuring-a-remote-for-a-fork) to sync your fork with the [Hyperledger Iroha repository](https://github.com/hyperledger-iroha/iroha/tree/main). +- [Configure the remote](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/configuring-a-remote-repository-for-a-fork) to sync your fork with the [Hyperledger Iroha repository](https://github.com/hyperledger-iroha/iroha/tree/main). - Use the [Git Rebase Workflow](https://git-rebase.io/). Avoid using `git pull`. Use `git pull --rebase` instead. - Use the provided [git hooks](./hooks/) to ease the development process. @@ -317,11 +317,9 @@ Code guidelines: - Use a domain-first modules structure. Example: don't do `constants::logger`. Instead, invert the hierarchy, putting the object for which it is used first: `iroha_logger::constants`. -- Use [`expect`](https://learning-rust.github.io/docs/e4.unwrap_and_expect.html) with an explicit error message or proof of infallibility instead of `unwrap`. +- Use [`expect`](https://learning-rust.github.io/docs/unwrap-and-expect/) with an explicit error message or proof of infallibility instead of `unwrap`. - Never ignore an error. If you can't `panic` and can't recover, it at least needs to be recorded in the log. - Prefer to return a `Result` instead of `panic!`. - - Exception: when implementing something that uses `issue_send` instead of `send` ([more about actors](docs/source/guides/actor.md)). Actors and parallelism don't mix; you could deadlock the entire peer, so it's better to `panic!` if something goes wrong. This is a necessary concession for asynchronous programming. - Group related functionality spatially, preferably inside appropriate modules. For example, instead of having a block with `struct` definitions and then `impl`s for each individual struct, it is better to have the `impl`s related to that `struct` next to it. diff --git a/crates/iroha/examples/tutorial.rs b/crates/iroha/examples/tutorial.rs index 5867bd15fb5..8ce941f4619 100644 --- a/crates/iroha/examples/tutorial.rs +++ b/crates/iroha/examples/tutorial.rs @@ -1,5 +1,4 @@ //! This file contains examples from the Rust tutorial. -//! use eyre::{Error, WrapErr}; use iroha::{config::Config, data_model::prelude::Numeric}; diff --git a/crates/iroha_wasm_builder/src/lib.rs b/crates/iroha_wasm_builder/src/lib.rs index ae088d1c916..529ff7fe31c 100644 --- a/crates/iroha_wasm_builder/src/lib.rs +++ b/crates/iroha_wasm_builder/src/lib.rs @@ -368,7 +368,7 @@ fn cargo_command() -> Command { if value.contains(INSTRUMENT_COVERAGE_FLAG) { eprintln!("WARNING: found `{INSTRUMENT_COVERAGE_FLAG}` rustc flag in `{var}` environment variable\n \ This directly interferes with `-Z build-std` flag set by `iroha_wasm_builder`\n \ - See https://github.com/rust-lang/wg-cargo-std-aware/issues/68\n \ + See https://github.com/rust-lang/wg-cargo-std-aware/issues/68 \n \ Further execution of `cargo` will most probably fail with `could not find profiler-builtins` error"); } } diff --git a/lychee.toml b/lychee.toml new file mode 100644 index 00000000000..f2589874adb --- /dev/null +++ b/lychee.toml @@ -0,0 +1,16 @@ +verbose = "error" +no_progress = true +cache = false + +timeout = 20 +max_retries = 2 + +exclude_path = [ + "target" +] + +exclude = [ + "^http[s]?://127.0.0.1", + "^http[s]?://localhost", + "^http[s]?://iroha" +] diff --git a/wasm/libs/default_executor/README.md b/wasm/libs/default_executor/README.md index c41a648adf1..d646e872ed7 100644 --- a/wasm/libs/default_executor/README.md +++ b/wasm/libs/default_executor/README.md @@ -1,6 +1,6 @@ # `iroha_default_executor` -Use the [Wasm Builder CLI](../../crates/iroha_wasm_builder) in order to build it: +Use the [Wasm Builder CLI](../../../crates/iroha_wasm_builder) in order to build it: ```bash cargo run --bin iroha_wasm_builder -- \