From 35f38b0feb40dc4a3b9a1e226490c9d752c5e174 Mon Sep 17 00:00:00 2001 From: RJ Rybarczyk Date: Fri, 5 Jul 2024 15:29:45 -0400 Subject: [PATCH 01/12] Rm act + call fmt bash only --- .githooks/pre-push | 43 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/.githooks/pre-push b/.githooks/pre-push index f74e29cc8..9b3e12271 100755 --- a/.githooks/pre-push +++ b/.githooks/pre-push @@ -1,31 +1,28 @@ #!/bin/sh -# An example hook script to verify what is about to be pushed. Called by "git -# push" after it has checked the remote status, but before anything has been -# pushed. If this script exits with a non-zero status nothing will be pushed. -# -# This hook is called with the following parameters: -# -# $1 -- Name of the remote to which the push is being done -# $2 -- URL to which the push is being done -# -# If pushing without using a named remote those arguments will be equal. -# -# Information about the commits which are being pushed is supplied as lines to -# the standard input in the form: -# -# +# Pre-push hook script to run code quality checks and ensure consistency. # +# This script will execute two custom scripts located in the `scripts/` directory: +# 1. clippy-on-all-workspaces.sh: Runs Clippy, tests, and formatting on all specified workspaces. +# 2. sv2-header-check.sh: Ensures the `sv2.h` file generated by `build_header.sh` matches the +# committed version. +# Exit immediately if any command exits with a non-zero status and print each command before +# executing it. set -xe -remote="$1" -url="$2" - -act --job message_generator_check --reuse -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:rust-latest -act --job sv2_header_check --reuse -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:rust-latest -act --job fmt --reuse -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:rust-latest -act --job clippy-check --reuse -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:rust-latest -act --job ci --reuse -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:rust-latest +# Run clippy, test, and rustfmt on all workspaces +sh ./scripts/clippy-on-all-workspaces.sh +if [ $? -ne 0 ]; then + echo "Clippy checks or tests failed." + exit 1 +fi +# Run sv2 header check +sh ./scripts/sv2-header-check.sh +if [ $? -ne 0 ]; then + echo "SV2 header check failed." + exit 1 +fi +echo "Pre-push checks passed successfully." From bb9e88a91208837f84d52add9dfd167948e0eb24 Mon Sep 17 00:00:00 2001 From: RJ Rybarczyk Date: Fri, 5 Jul 2024 15:31:14 -0400 Subject: [PATCH 02/12] Use /bin/sh instead of /usr/bin/sh --- scripts/sv2-header-check.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/sv2-header-check.sh b/scripts/sv2-header-check.sh index b39b0af54..56f5b719d 100755 --- a/scripts/sv2-header-check.sh +++ b/scripts/sv2-header-check.sh @@ -1,5 +1,5 @@ -#! /usr/bin/sh -# +#!/bin/sh + # This program ensures that the `sv2.h` file generated by `build_header.sh` for the submitted PR is # in sync with the `sv2.h` file committed to `protocols/v2/sv2-ffi`. If they are out of sync, the # GitHub Action will fail, preventing the PR from being merged. From 8e153234ff0e6bbac8a5dfd449fc15e21211f91d Mon Sep 17 00:00:00 2001 From: RJ Rybarczyk Date: Fri, 5 Jul 2024 15:32:37 -0400 Subject: [PATCH 03/12] Rm generated sv2 header if exists before run --- scripts/sv2-header-check.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/sv2-header-check.sh b/scripts/sv2-header-check.sh index 56f5b719d..65c467c4b 100755 --- a/scripts/sv2-header-check.sh +++ b/scripts/sv2-header-check.sh @@ -22,6 +22,7 @@ set -ex # cbindgen -V echo $PWD +rm -f scripts/sv2.h cd protocols/v2/sv2-ffi SHA1_1=$(sha1sum sv2.h) cd ../../../scripts From 223157cd6a6b1f4bee873943f8d434d1f7827949 Mon Sep 17 00:00:00 2001 From: RJ Rybarczyk Date: Fri, 5 Jul 2024 15:33:28 -0400 Subject: [PATCH 04/12] sv2-header-check cmts --- scripts/sv2-header-check.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/sv2-header-check.sh b/scripts/sv2-header-check.sh index 65c467c4b..96ee6bf0e 100755 --- a/scripts/sv2-header-check.sh +++ b/scripts/sv2-header-check.sh @@ -9,11 +9,11 @@ # (2) takes the SHA1 hash of the `sv2.h` file in `protocols/v2/sv2-ffi` # (3) executes `build_header.sh` to generate the `sv2.h` based on the contents of the PR # (4) takes the SHA1 hash of the `sv2.h` file generated by `build_header.sh` -# (5) compares the hashes of each `sv2.h`, if they are equal then the GitHub Action passes, otherwise -# the GitHub Action fails -# -# This script is called by `.github/workflows/sv2-header-check.yaml` on every PR onto the main branch. +# (5) compares the hashes of each `sv2.h`, if they are equal then the GitHub Action passes, +# otherwise the GitHub Action fails # +# This script is called by `.github/workflows/sv2-header-check.yaml` on every PR onto the main +# branch. cargo install --version 0.20.0 cbindgen @@ -22,7 +22,9 @@ set -ex # cbindgen -V echo $PWD +# Remove the sv2.h generated from previous runs if exists rm -f scripts/sv2.h + cd protocols/v2/sv2-ffi SHA1_1=$(sha1sum sv2.h) cd ../../../scripts From cc4668becad83d7177b1b103ab2a50191199d87c Mon Sep 17 00:00:00 2001 From: RJ Rybarczyk Date: Fri, 5 Jul 2024 15:34:56 -0400 Subject: [PATCH 05/12] Ignore generated sv2 header --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 6121487a2..af4c21e3e 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ lcov.info cobertura.xml /roles/*/*-config.toml /examples/*/Cargo.lock +/scripts/sv2.h From 7df5df772eaebe8dde4123105d6002f4fd20807e Mon Sep 17 00:00:00 2001 From: RJ Rybarczyk Date: Fri, 9 Aug 2024 12:04:39 -0400 Subject: [PATCH 06/12] Rename to clippy-fmt-and-test sh --- .githooks/pre-push | 2 +- scripts/{clippy-on-all-workspaces.sh => clippy-fmt-and-test.sh} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename scripts/{clippy-on-all-workspaces.sh => clippy-fmt-and-test.sh} (100%) diff --git a/.githooks/pre-push b/.githooks/pre-push index 9b3e12271..756537ca2 100755 --- a/.githooks/pre-push +++ b/.githooks/pre-push @@ -12,7 +12,7 @@ set -xe # Run clippy, test, and rustfmt on all workspaces -sh ./scripts/clippy-on-all-workspaces.sh +sh ./scripts/clippy-fmt-and-test.sh if [ $? -ne 0 ]; then echo "Clippy checks or tests failed." exit 1 diff --git a/scripts/clippy-on-all-workspaces.sh b/scripts/clippy-fmt-and-test.sh similarity index 100% rename from scripts/clippy-on-all-workspaces.sh rename to scripts/clippy-fmt-and-test.sh From 3fce388601a017f86a8212342051b9e186a7c4ef Mon Sep 17 00:00:00 2001 From: RJ Rybarczyk Date: Fri, 9 Aug 2024 12:26:42 -0400 Subject: [PATCH 07/12] Enforce cargo v1.75 --- .githooks/pre-push | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.githooks/pre-push b/.githooks/pre-push index 756537ca2..189dabfcf 100755 --- a/.githooks/pre-push +++ b/.githooks/pre-push @@ -3,14 +3,24 @@ # Pre-push hook script to run code quality checks and ensure consistency. # # This script will execute two custom scripts located in the `scripts/` directory: -# 1. clippy-on-all-workspaces.sh: Runs Clippy, tests, and formatting on all specified workspaces. -# 2. sv2-header-check.sh: Ensures the `sv2.h` file generated by `build_header.sh` matches the +# 1. Enforce cargo version 1.75. +# 2. clippy-on-all-workspaces.sh: Runs Clippy, tests, and formatting on all specified workspaces. +# 3. sv2-header-check.sh: Ensures the `sv2.h` file generated by `build_header.sh` matches the # committed version. # Exit immediately if any command exits with a non-zero status and print each command before # executing it. set -xe +# Enforce cargo version 1.75 +REQUIRED_CARGO_VERSION="1.75.0" +INSTALLED_CARGO_VERSION=$(cargo --version | awk '{print $2}') + +if [ "$INSTALLED_CARGO_VERSION" != "$REQUIRED_CARGO_VERSION" ]; then + echo "Error: Cargo version $REQUIRED_CARGO_VERSION is required. Installed version is $INSTALLED_CARGO_VERSION." + exit 1 +fi + # Run clippy, test, and rustfmt on all workspaces sh ./scripts/clippy-fmt-and-test.sh if [ $? -ne 0 ]; then From 8e35dbacc6aea7a74b9af2f26da13163496c3b47 Mon Sep 17 00:00:00 2001 From: RJ Rybarczyk Date: Thu, 15 Aug 2024 13:36:15 -0400 Subject: [PATCH 08/12] Add sha1sum on system check Co-authored-by: plebhash <147345153+plebhash@users.noreply.github.com> --- scripts/sv2-header-check.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/sv2-header-check.sh b/scripts/sv2-header-check.sh index 96ee6bf0e..7464009eb 100755 --- a/scripts/sv2-header-check.sh +++ b/scripts/sv2-header-check.sh @@ -15,6 +15,12 @@ # This script is called by `.github/workflows/sv2-header-check.yaml` on every PR onto the main # branch. +# Check if sha1sum is available on the system +if ! command -v sha1sum >/dev/null 2>&1; then + echo "Warning: sha1sum is not installed on this system." + exit 1 +fi + cargo install --version 0.20.0 cbindgen set -ex From 5072c344729829c2746956c893eeb396638caa90 Mon Sep 17 00:00:00 2001 From: RJ Rybarczyk Date: Thu, 15 Aug 2024 13:46:34 -0400 Subject: [PATCH 09/12] Enforce minimum version --- .githooks/pre-push | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.githooks/pre-push b/.githooks/pre-push index 189dabfcf..3a2ca0712 100755 --- a/.githooks/pre-push +++ b/.githooks/pre-push @@ -12,12 +12,17 @@ # executing it. set -xe -# Enforce cargo version 1.75 +# Enforce minimum cargo version 1.75 REQUIRED_CARGO_VERSION="1.75.0" INSTALLED_CARGO_VERSION=$(cargo --version | awk '{print $2}') -if [ "$INSTALLED_CARGO_VERSION" != "$REQUIRED_CARGO_VERSION" ]; then - echo "Error: Cargo version $REQUIRED_CARGO_VERSION is required. Installed version is $INSTALLED_CARGO_VERSION." +# Function to compare version numbers +version_ge() { + [ "$(printf '%s\n' "$@" | sort -V | head -n 1)" = "$2" ] +} + +if ! version_ge "$INSTALLED_CARGO_VERSION" "$REQUIRED_CARGO_VERSION"; then + echo "Error: Cargo version $REQUIRED_CARGO_VERSION or higher is required. Installed version is $INSTALLED_CARGO_VERSION." exit 1 fi From 390b201448be57a114783ed56cc98517095e722c Mon Sep 17 00:00:00 2001 From: RJ Rybarczyk Date: Thu, 15 Aug 2024 14:45:10 -0400 Subject: [PATCH 10/12] Enforce no change in lock files --- .githooks/pre-push | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.githooks/pre-push b/.githooks/pre-push index 3a2ca0712..5599ffba9 100755 --- a/.githooks/pre-push +++ b/.githooks/pre-push @@ -26,6 +26,24 @@ if ! version_ge "$INSTALLED_CARGO_VERSION" "$REQUIRED_CARGO_VERSION"; then exit 1 fi +# Enforce lock files are not changed during clippy, test, and rustfmt +if ! cargo build --manifest-path=benches/Cargo.toml --locked; then + echo "Error: Cargo.lock file in benches crate is out of date. Please run 'cargo update' in the benches crate." + exit 1 +fi + +if ! cargo build --manifest-path=roles/Cargo.toml --locked; then + echo "Error: Cargo.lock file in roles crate is out of date. Please run 'cargo update' in the roles crate." + exit 1 +fi + +if ! cargo build --manifest-path=utils/Cargo.toml --locked; then + echo "Error: Cargo.lock file in utils crate is out of date. Please run 'cargo update' in the utils crate." + exit 1 +fi + +echo "All builds succeeded with up-to-date Cargo.lock files." + # Run clippy, test, and rustfmt on all workspaces sh ./scripts/clippy-fmt-and-test.sh if [ $? -ne 0 ]; then From 7221aa0b3be6ecf028f3e0c47f597ff4f9fe6246 Mon Sep 17 00:00:00 2001 From: RJ Rybarczyk Date: Thu, 15 Aug 2024 14:56:26 -0400 Subject: [PATCH 11/12] Only roles + utils have binaries w lock files --- .githooks/pre-push | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.githooks/pre-push b/.githooks/pre-push index 5599ffba9..e9a8df417 100755 --- a/.githooks/pre-push +++ b/.githooks/pre-push @@ -27,11 +27,6 @@ if ! version_ge "$INSTALLED_CARGO_VERSION" "$REQUIRED_CARGO_VERSION"; then fi # Enforce lock files are not changed during clippy, test, and rustfmt -if ! cargo build --manifest-path=benches/Cargo.toml --locked; then - echo "Error: Cargo.lock file in benches crate is out of date. Please run 'cargo update' in the benches crate." - exit 1 -fi - if ! cargo build --manifest-path=roles/Cargo.toml --locked; then echo "Error: Cargo.lock file in roles crate is out of date. Please run 'cargo update' in the roles crate." exit 1 From 43bd3b741762db904c827218ff9b6ee153d61f57 Mon Sep 17 00:00:00 2001 From: plebhash Date: Fri, 23 Aug 2024 16:57:00 -0300 Subject: [PATCH 12/12] stop publishing some crates --- .github/workflows/release-libs.yaml | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/.github/workflows/release-libs.yaml b/.github/workflows/release-libs.yaml index 24e925196..49418675d 100644 --- a/.github/workflows/release-libs.yaml +++ b/.github/workflows/release-libs.yaml @@ -138,29 +138,4 @@ jobs: continue-on-error: true run: | cd roles/roles-utils/rpc - cargo publish - - name: Publish crate jd_client - continue-on-error: true - run: | - cd roles/jd-client - cargo publish - - name: Publish crate jd_server - continue-on-error: true - run: | - cd roles/jd-server - cargo publish - - name: Publish crate mining_proxy_sv2 - continue-on-error: true - run: | - cd roles/mining-proxy - cargo publish - - name: Publish crate pool_sv2 - continue-on-error: true - run: | - cd roles/pool - cargo publish - - name: Publish crate translator_sv2 - continue-on-error: true - run: | - cd roles/translator cargo publish \ No newline at end of file