From ba43bbdd51cf2e7bb44ee705c72022387c4c0ee2 Mon Sep 17 00:00:00 2001 From: David Ansermino <14164624+ansermino@users.noreply.github.com> Date: Wed, 2 Oct 2024 11:50:22 -0700 Subject: [PATCH] CI Checks (#40) --- .github/workflows/lint.yml | 29 +++++++++++++++++++++++++++++ .github/workflows/test.yml | 32 ++++++++++++++++++++++++++++++++ Makefile | 14 +++++++++++++- misc/README.md | 2 +- src/test-suite/README.md | 8 ++++---- src/test-suite/src/main.rs | 5 +++-- src/tool/README.md | 18 +++++++++--------- src/tool/src/main.rs | 5 +++-- src/tool/tests/snapshot.rs | 2 +- 9 files changed, 95 insertions(+), 20 deletions(-) create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..3cbbef0 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,29 @@ +name: Lint + +on: + pull_request: + +jobs: + rustfmt: + runs-on: ubuntu-latest + steps: + - name: Checkout source code + uses: actions/checkout@v4 + + - name: Print toolchain version + run: rustup show active-toolchain + + - name: Run fmt + run: make lint + + clippy: + runs-on: ubuntu-latest + steps: + - name: Checkout source code + uses: actions/checkout@v4 + + - name: Print toolchain version + run: rustup show active-toolchain + + - name: Run clippy + run: make clippy \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..d599e64 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,32 @@ +name: Build and Test + +on: + pull_request: + +env: + SCCACHE_GHA_ENABLED: "true" + RUSTC_WRAPPER: sccache + CC: sccache clang + CXX: sccache clang++ + +jobs: + test: + name: build-and-test + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Print toolchain version + run: rustup show active-toolchain + + - name: Setup sccache + uses: mozilla-actions/sccache-action@v0.0.5 + timeout-minutes: 5 + continue-on-error: true + + - name: Build + run: make check + + - name: Test + run: make test \ No newline at end of file diff --git a/Makefile b/Makefile index 9e38064..d2567c5 100644 --- a/Makefile +++ b/Makefile @@ -5,4 +5,16 @@ release: cargo build --release install: - cargo install \ No newline at end of file + cargo install + +lint: + cargo fmt --all --check + +clippy: + cargo clippy --all-targets --quiet --no-deps + +test: + cargo test + +check: + cargo check \ No newline at end of file diff --git a/misc/README.md b/misc/README.md index 90af54d..a28652a 100644 --- a/misc/README.md +++ b/misc/README.md @@ -1,5 +1,5 @@ [`method-list.json`](./method-list.json) is a JSON list of all the methods to be included in the Common Node API. -It is used by `tool openrpc select` to generate the final schema from source +It is used by `cna-tool openrpc select` to generate the final schema from source schemas in [`/schemas`](../schemas/). diff --git a/src/test-suite/README.md b/src/test-suite/README.md index 551fd3f..ddd2b51 100644 --- a/src/test-suite/README.md +++ b/src/test-suite/README.md @@ -1,16 +1,16 @@ -# `test-suite` +# `cna-test-suite` ``` Filecoin RPC test suite -Usage: test-suite +Usage: cna-test-suite Commands: list Print each test as a line of JSON to stdout run Run the tests, loading the given config file ``` -## `test-suite` `list` +## `cna-test-suite` `list` ``` Print each test as a line of JSON to stdout @@ -18,7 +18,7 @@ Print each test as a line of JSON to stdout Usage: list ``` -## `test-suite` `run` +## `cna-test-suite` `run` ``` Run the tests, loading the given config file diff --git a/src/test-suite/src/main.rs b/src/test-suite/src/main.rs index f15b250..017b9b7 100644 --- a/src/test-suite/src/main.rs +++ b/src/test-suite/src/main.rs @@ -744,6 +744,7 @@ mod harness { #[test] fn doc() { - expect_test::expect_file!["../README.md"] - .assert_eq(&util::markdown(&::command())); + expect_test::expect_file!["../README.md"].assert_eq(&cna_util::markdown( + &::command(), + )); } diff --git a/src/tool/README.md b/src/tool/README.md index fd5c5d8..81ac604 100644 --- a/src/tool/README.md +++ b/src/tool/README.md @@ -1,9 +1,9 @@ -# `tool` +# `cna-tool` ``` Utilities for creating, interacting with, and testing against the Filecoin Common Node API -Usage: tool +Usage: cna-tool Commands: openrpc Subcommands related to processing OpenRPC documents @@ -11,7 +11,7 @@ Commands: json-rpc Subcommands for interacting with JSON-RPC endpoints ``` -## `tool` `openrpc` +## `cna-tool` `openrpc` ``` Subcommands related to processing OpenRPC documents @@ -23,7 +23,7 @@ Commands: select Interpret `select` as a json document of methods to include in `openrpc` ``` -### `tool` `openrpc` `validate` +### `cna-tool` `openrpc` `validate` ``` Performs validation of the spec, including FIP-specific validation. @@ -44,7 +44,7 @@ Arguments: ``` -### `tool` `openrpc` `select` +### `cna-tool` `openrpc` `select` ``` Interpret `select` as a json document of methods to include in `openrpc`. @@ -68,7 +68,7 @@ Options: Specify a new version for the schema ``` -## `tool` `csv2json` +## `cna-tool` `csv2json` ``` Interpret stdin as a `delimiter`-separated series of lines, with a header, and print JSON @@ -80,7 +80,7 @@ Options: [default: "\t"] ``` -## `tool` `json-rpc` +## `cna-tool` `json-rpc` ``` Subcommands for interacting with JSON-RPC endpoints @@ -92,7 +92,7 @@ Commands: play Receive's stdin's concatenated JSON summaries of JSON-RPC dialogue (as output by the `json-rpc capture` command) ``` -### `tool` `json-rpc` `capture` +### `cna-tool` `json-rpc` `capture` ``` Start a HTTP server, forwarding all requests to a single URI. @@ -117,7 +117,7 @@ Options: The remote URI to forward requests to ``` -### `tool` `json-rpc` `play` +### `cna-tool` `json-rpc` `play` ``` Receive's stdin's concatenated JSON summaries of JSON-RPC dialogue (as output by the `json-rpc capture` command). diff --git a/src/tool/src/main.rs b/src/tool/src/main.rs index 6a6718e..96ce775 100644 --- a/src/tool/src/main.rs +++ b/src/tool/src/main.rs @@ -683,6 +683,7 @@ impl FromStr for Header { #[test] fn doc() { - expect_test::expect_file!["../README.md"] - .assert_eq(&util::markdown(&::command())); + expect_test::expect_file!["../README.md"].assert_eq(&cna_util::markdown( + &::command(), + )); } diff --git a/src/tool/tests/snapshot.rs b/src/tool/tests/snapshot.rs index af2e78e..55db633 100644 --- a/src/tool/tests/snapshot.rs +++ b/src/tool/tests/snapshot.rs @@ -3,7 +3,7 @@ use assert_cmd::Command; #[test] fn openrpc_select_is_up_to_date() -> anyhow::Result<()> { let repo_root = concat!(env!("CARGO_MANIFEST_DIR"), "/../.."); - let stdout = Command::cargo_bin("tool")? + let stdout = Command::cargo_bin("cna-tool")? .args(["openrpc", "select"]) .args([ "schemas/forest-6ba5c966097-path-v0.json",