From 2b42e2568f355d67140873822f700f109143e12e Mon Sep 17 00:00:00 2001 From: chonghe Date: Mon, 7 Aug 2023 09:01:47 +0800 Subject: [PATCH] modified test-suite --- .github/workflows/test-suite.yml | 8 +++++ Makefile | 2 +- scripts/cli.sh | 61 ++++++++++++-------------------- 3 files changed, 32 insertions(+), 39 deletions(-) diff --git a/.github/workflows/test-suite.yml b/.github/workflows/test-suite.yml index a296cc8491..c6836f26a5 100644 --- a/.github/workflows/test-suite.yml +++ b/.github/workflows/test-suite.yml @@ -387,3 +387,11 @@ jobs: run: rustup override set beta - name: Run make run: make + cli-check: + name: cli-check + runs-on: ubuntu-latest + needs: cargo-fmt + steps: + - uses: actions/checkout@v3 + - name: Run Makefile to trigger the bash script + run: make cli diff --git a/Makefile b/Makefile index 73fe96d7cc..739dff8d71 100644 --- a/Makefile +++ b/Makefile @@ -189,7 +189,7 @@ test: test-release cli: ./lighthouse/scripts/cli.sh # Runs the entire test suite, downloading test vectors if required. -test-full: cargo-fmt test-release test-debug test-ef test-exec-engine cli +test-full: cargo-fmt test-release test-debug test-ef test-exec-engine # Lints the code for bad style and potentially unsafe arithmetic using Clippy. diff --git a/scripts/cli.sh b/scripts/cli.sh index 5b46f38d11..9eb5a24f0c 100644 --- a/scripts/cli.sh +++ b/scripts/cli.sh @@ -1,44 +1,29 @@ #! /bin/bash +# Check if a lighthouse binary exists in the current branch. +maxperf=./target/maxperf/lighthouse +release=./target/release/lighthouse +debug=./target/debug/lighthouse -#read version -read -p "Enter Lighthouse version: " version +if [[ -f "$maxperf" ]]; then + CMD="$maxperf" +elif [[ -f "$release" ]]; then + CMD="$release" +elif [[ -f "$debug" ]]; then + CMD="$debug" +else + # No binary exists, build it. + cargo build --locked + CMD="$debug" +fi -#download lighthouse binary -binary="curl -LO https://github.com/sigp/lighthouse/releases/download/v$version/lighthouse-v$version-x86_64-unknown-linux-gnu.tar.gz" +# Remove the existing help text file if it exists. +rm -f -- cli.txt -#download the binary to the present working directory -cd ./lighthouse/scripts -$binary +# Store all help strings in variables. +bn=$($CMD bn --help) +vc=$($CMD vc --help) +wallet=$($CMD a wallet --help) -#extract -tar xvf lighthouse-v$version-x86_64-unknown-linux-gnu.tar.gz - -#remove -rm lighthouse-v$version-x86_64-unknown-linux-gnu.tar.gz - -#outputs help text. the "&& echo >> cli.txt is to create a line space between the next output" -./lighthouse --help | tee cli.txt && echo >> cli.txt - -# account manager, the -a option means append, i.e., append the output so that all outputs are in a single file -./lighthouse a --help | tee -a cli.txt && echo >> cli.txt -# subcommand under account -./lighthouse a validator --help | tee -a cli.txt && echo >> cli.txt -./lighthouse a validator modify --help | tee -a cli.txt && echo >> cli.txt -./lighthouse a validator slashing-protection --help | tee -a cli.txt && echo >> cli.txt - -./lighthouse a wallet --help | tee -a cli.txt && echo >> cli.txt - -# beacon node -./lighthouse bn --help | tee -a cli.txt && echo >> cli.txt -# boot-node -./lighthouse boot_node --help | tee -a cli.txt && echo >> cli.txt - -# database manager -./lighthouse db --help | tee -a cli.txt && echo >> cli.txt - -# validator client -./lighthouse vc --help | tee -a cli.txt && echo >> cli.txt - -# remove binary file -rm lighthouse +# Print all help strings to the cli.txt file. +printf "%s\n\n" "$bn" "$vc" "$wallet" >> cli.txt \ No newline at end of file