From d2bd5586c6b2c45652ac9cfd62999d9d7f7ab131 Mon Sep 17 00:00:00 2001 From: Zach Mandeville Date: Thu, 8 Aug 2024 15:12:00 +1200 Subject: [PATCH 1/9] Add analogous gh jobs for .circleci/then.yml jobs --- .../actions/install-dependencies/action.yaml | 20 ++++++++++ .../workflows/build-and-run-node-test.yaml | 40 +++++++++++++++++++ .github/workflows/check-chainspecs.yaml | 17 ++++++++ .github/workflows/check-doc-build.yaml | 14 +++++++ .../workflows/lint-and-check-licenses.yaml | 27 +++++++++++++ .../workflows/test-runtime-benchmarks.yaml | 14 +++++++ 6 files changed, 132 insertions(+) create mode 100644 .github/actions/install-dependencies/action.yaml create mode 100644 .github/workflows/build-and-run-node-test.yaml create mode 100644 .github/workflows/check-chainspecs.yaml create mode 100644 .github/workflows/check-doc-build.yaml create mode 100644 .github/workflows/lint-and-check-licenses.yaml create mode 100644 .github/workflows/test-runtime-benchmarks.yaml diff --git a/.github/actions/install-dependencies/action.yaml b/.github/actions/install-dependencies/action.yaml new file mode 100644 index 000000000..919595097 --- /dev/null +++ b/.github/actions/install-dependencies/action.yaml @@ -0,0 +1,20 @@ +--- +name: 'Install Dependencies' +description: 'Install the dependencies and rust components used across jobs' +runs: + using: "composite" + steps: + - name: Install dependencies + run: | + sudo sed -i "/#\$nrconf{restart} = 'i';/s/.*/\$nrconf{restart} = 'a';/" /etc/needrestart/needrestart.conf + sudo apt-get update + sudo apt install -y libssl-dev clang libclang-dev protobuf-compiler + shell: bash + - name: Add rust components + run: | + rustup target add wasm32-unknown-unknown + rustup component add rust-src + shell: bash + - name: Install wasm-pack + run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh + shell: bash diff --git a/.github/workflows/build-and-run-node-test.yaml b/.github/workflows/build-and-run-node-test.yaml new file mode 100644 index 000000000..2a09d0c0b --- /dev/null +++ b/.github/workflows/build-and-run-node-test.yaml @@ -0,0 +1,40 @@ +--- +name: "Build and run node-test" +on: + push: + paths: + - "node/**" + - "crates/**" + - "pallets/*" + - "runtime/*" + +jobs: + node-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Increase swap + run: | + sudo swapoff -a + sudo dd if=/dev/zero of=/swapfile bs=1G count=8 + sudo chmod 0600 /swapfile + sudo mkswap /swapfile + sudo swapon /swapfile + grep Swap /proc/meminfo + - name: Install dependencies + uses: ./.github/actions/install-dependencies/ + - name: Build entropy-protocol nodejs package + run: | + cd crates/protocol + make build-nodejs-testing + cd nodejs-test + yarn + cd ../../.. + - name: Run cargo test + timeout-minutes: 45 + run: | + pushd node + cargo build --all-targets --release -j $(nproc) + cargo test --all-targets --release + yarn --cwd ../crates/protocol/nodejs-test test + cargo test -p entropy-tss --release --features=test_helpers -F wasm_test test_wasm diff --git a/.github/workflows/check-chainspecs.yaml b/.github/workflows/check-chainspecs.yaml new file mode 100644 index 000000000..998a127d3 --- /dev/null +++ b/.github/workflows/check-chainspecs.yaml @@ -0,0 +1,17 @@ +--- +name: "Check chainspecs" +on: ["push"] + +jobs: + check-chainspecs: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Install dependencies + uses: ./.github/actions/install-dependencies/ + - name: Check chainspecs + run: | + cargo run -p entropy -- build-spec --raw --chain dev > chainspec-dev-raw.json + cargo run -p entropy -- build-spec --raw --chain integration-tests > chainspec-integration-raw.json + cargo run -p entropy -- build-spec --raw --chain testnet > chainspec-testnet-raw.json diff --git a/.github/workflows/check-doc-build.yaml b/.github/workflows/check-doc-build.yaml new file mode 100644 index 000000000..9dd989e75 --- /dev/null +++ b/.github/workflows/check-doc-build.yaml @@ -0,0 +1,14 @@ +--- +name: "Check documentation build" +on: ["push"] + +jobs: + check-doc-build: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Install dependencies + uses: ./.github/actions/install-dependencies/ + - name: Build documentation + run: cargo doc --no-deps \ No newline at end of file diff --git a/.github/workflows/lint-and-check-licenses.yaml b/.github/workflows/lint-and-check-licenses.yaml new file mode 100644 index 000000000..1fc0144a8 --- /dev/null +++ b/.github/workflows/lint-and-check-licenses.yaml @@ -0,0 +1,27 @@ +--- +name: "Lint and check licenses" +on: ["push"] + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Install dependencies + uses: ./.github/actions/install-dependencies/ + - name: Format and lint + run: | + curl -LsSf https://github.com/tamasfe/taplo/releases/download/0.8.0/taplo-full-linux-x86_64.gz | gunzip -N -d - > ${CARGO_HOME:-~/.cargo}/bin/taplo && chmod +x ${CARGO_HOME:-~/.cargo}/bin/taplo + cargo fmt --check + taplo fmt --check + cargo clippy -- -D warnings + check-licenses: + runs-on: ubuntu-22.04 + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Check licenses with cargo deny + run: | + cargo install --locked cargo-deny + cargo deny --all-features check license diff --git a/.github/workflows/test-runtime-benchmarks.yaml b/.github/workflows/test-runtime-benchmarks.yaml new file mode 100644 index 000000000..c3978a559 --- /dev/null +++ b/.github/workflows/test-runtime-benchmarks.yaml @@ -0,0 +1,14 @@ +name: "Test: check runtime benchmarks" +on: ["push"] + +jobs: + test-runtime-benchmarks: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Install dependencies + uses: ./.github/actions/install-dependencies/ + - name: Check runtime-benchmarks + run: | + pushd node && cargo check --features=runtime-benchmarks From 79c711745bc0c014d7f9811b4701785c47563dad Mon Sep 17 00:00:00 2001 From: Zach <120055804+cooldracula@users.noreply.github.com> Date: Fri, 9 Aug 2024 10:30:54 +1200 Subject: [PATCH 2/9] Update .github/actions/install-dependencies/action.yaml Co-authored-by: Hernando Castano --- .github/actions/install-dependencies/action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/install-dependencies/action.yaml b/.github/actions/install-dependencies/action.yaml index 919595097..e8752c96a 100644 --- a/.github/actions/install-dependencies/action.yaml +++ b/.github/actions/install-dependencies/action.yaml @@ -1,6 +1,6 @@ --- name: 'Install Dependencies' -description: 'Install the dependencies and rust components used across jobs' +description: 'Install the dependencies and Rust components used across jobs' runs: using: "composite" steps: From f62dcc4aa0060c4181b5a20fb21e4ba54f55c9b9 Mon Sep 17 00:00:00 2001 From: Zach <120055804+cooldracula@users.noreply.github.com> Date: Fri, 9 Aug 2024 10:31:05 +1200 Subject: [PATCH 3/9] Update .github/actions/install-dependencies/action.yaml Co-authored-by: Hernando Castano --- .github/actions/install-dependencies/action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/install-dependencies/action.yaml b/.github/actions/install-dependencies/action.yaml index e8752c96a..d20c73922 100644 --- a/.github/actions/install-dependencies/action.yaml +++ b/.github/actions/install-dependencies/action.yaml @@ -10,7 +10,7 @@ runs: sudo apt-get update sudo apt install -y libssl-dev clang libclang-dev protobuf-compiler shell: bash - - name: Add rust components + - name: Add Rust components run: | rustup target add wasm32-unknown-unknown rustup component add rust-src From 0b8597f6e6b74092a0514e2eeb2a474ae2e8c053 Mon Sep 17 00:00:00 2001 From: Zach <120055804+cooldracula@users.noreply.github.com> Date: Fri, 9 Aug 2024 10:31:25 +1200 Subject: [PATCH 4/9] Update .github/workflows/build-and-run-node-test.yaml Co-authored-by: Hernando Castano --- .github/workflows/build-and-run-node-test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-run-node-test.yaml b/.github/workflows/build-and-run-node-test.yaml index 2a09d0c0b..8b70b1a9a 100644 --- a/.github/workflows/build-and-run-node-test.yaml +++ b/.github/workflows/build-and-run-node-test.yaml @@ -30,7 +30,7 @@ jobs: cd nodejs-test yarn cd ../../.. - - name: Run cargo test + - name: Run `cargo build && cargo test` timeout-minutes: 45 run: | pushd node From f548583d814aa028d2a225a225dd499fc48da683 Mon Sep 17 00:00:00 2001 From: Zach <120055804+cooldracula@users.noreply.github.com> Date: Fri, 9 Aug 2024 10:31:32 +1200 Subject: [PATCH 5/9] Update .github/workflows/build-and-run-node-test.yaml Co-authored-by: Hernando Castano --- .github/workflows/build-and-run-node-test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-run-node-test.yaml b/.github/workflows/build-and-run-node-test.yaml index 8b70b1a9a..fa473c121 100644 --- a/.github/workflows/build-and-run-node-test.yaml +++ b/.github/workflows/build-and-run-node-test.yaml @@ -1,5 +1,5 @@ --- -name: "Build and run node-test" +name: "Build and test" on: push: paths: From b6a3eb2f77424f873526cbf0651d69c13b991e8c Mon Sep 17 00:00:00 2001 From: Zach Mandeville Date: Mon, 12 Aug 2024 09:31:19 +1200 Subject: [PATCH 6/9] remove timeout for cargo test step This was originally added as an analog to the circle-ci's "no_output_timeout", but they are not actually analogs. circle-ci's step measures how long to wait without any output, while gh's timeout is how long to run the step in general before timing out, regardless of output. This could cause the job to timeout when it was still successfully running, and still within github's usage limits. --- .github/workflows/build-and-run-node-test.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build-and-run-node-test.yaml b/.github/workflows/build-and-run-node-test.yaml index fa473c121..7130576f9 100644 --- a/.github/workflows/build-and-run-node-test.yaml +++ b/.github/workflows/build-and-run-node-test.yaml @@ -31,7 +31,6 @@ jobs: yarn cd ../../.. - name: Run `cargo build && cargo test` - timeout-minutes: 45 run: | pushd node cargo build --all-targets --release -j $(nproc) From cf2c3728d87201088417a4ba0880c1aa214eae41 Mon Sep 17 00:00:00 2001 From: Zach Mandeville Date: Mon, 12 Aug 2024 19:08:58 +1200 Subject: [PATCH 7/9] Remove circle-ci jobs All relevant workflows have been ported to github actions. --- .circleci/config.yml | 16 ---- .circleci/then.yml | 192 ------------------------------------------- 2 files changed, 208 deletions(-) delete mode 100644 .circleci/config.yml delete mode 100644 .circleci/then.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 529de50f2..000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,16 +0,0 @@ -orbs: - path-filtering: circleci/path-filtering@0.1.3 -setup: true -version: 2.1 -workflows: - check: - jobs: - - path-filtering/filter: - base-revision: master - config-path: .circleci/then.yml - mapping: | - node/.* node true - crates/.* crates true - pallets/.* pallets true - runtime/.* runtime true - name: check-updated-files diff --git a/.circleci/then.yml b/.circleci/then.yml deleted file mode 100644 index 7d0fd1f4a..000000000 --- a/.circleci/then.yml +++ /dev/null @@ -1,192 +0,0 @@ -commands: - fmt-lint: - steps: - - run: - name: Format and lint. - command: | - curl -LsSf https://github.com/tamasfe/taplo/releases/download/0.8.0/taplo-full-linux-x86_64.gz | gunzip -N -d - > ${CARGO_HOME:-~/.cargo}/bin/taplo && chmod +x ${CARGO_HOME:-~/.cargo}/bin/taplo - cargo fmt --check - taplo fmt --check - cargo clippy -- -D warnings - check-licenses: - steps: - - run: - name: Check licenses (`cargo-deny`). - command: | - cargo install --locked cargo-deny - cargo deny --all-features check license - increase-swap: - steps: - - run: - name: Increase swap. - command: | - sudo swapoff -a - sudo dd if=/dev/zero of=/swapfile bs=1G count=8 - sudo chmod 0600 /swapfile - sudo mkswap /swapfile - sudo swapon /swapfile - grep Swap /proc/meminfo - install-dependencies: - steps: - - run: - name: Install dependencies. - command: | - sudo sed -i "/#\$nrconf{restart} = 'i';/s/.*/\$nrconf{restart} = 'a';/" /etc/needrestart/needrestart.conf - sudo apt-get update - sudo apt install -y libssl-dev clang libclang-dev tor && sudo systemctl start tor && sudo systemctl enable tor - sudo apt install -y yarn - install-rust: - steps: - - run: - name: Install Rust. - command: | - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y - source "$HOME/.cargo/env" - rustup update stable - rustup target add wasm32-unknown-unknown - rustup component add rust-src - install-wasm-pack: - steps: - - run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh - install-dependencies-and-checkout: - steps: - - install-dependencies - - checkout - - install-dependencies - - install-rust - - install-wasm-pack - new-cmd: - steps: - - run: echo test - build: - steps: - - run: cargo build --release - comment-on-pr: - steps: - - run: | - sudo apt-get install jq - pr_response=$(curl --location --request GET "https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pulls?head=$CIRCLE_PROJECT_USERNAME:$CIRCLE_BRANCH&state=open" \ - -u $GH_USER:$GH_TOKEN) - if [ $(echo $pr_response | jq length) -eq 0 ]; then - echo "No PR found to update" - else - pr_comment_url=$(echo $pr_response | jq -r ".[]._links.comments.href") - fi - echo curl --location --request POST "$pr_comment_url" \ - -u $GH_USER:$GH_TOKEN \ - --header 'Content-Type: application/json' \ - --data-raw "'{ - \"body\": \"$(cat pr-comment)\" - }'" - -jobs: - threshold-signature-server: - machine: - image: ubuntu-2204:2022.10.2 - resource_class: xlarge - steps: - - install-dependencies-and-checkout - - run: cd crates/threshold-signature-server && cargo test --release - fmt-lint-all: - machine: - image: ubuntu-2204:2022.10.2 - resource_class: xlarge - steps: - - install-dependencies-and-checkout - - fmt-lint - - check-licenses - node-benchmark: - machine: - image: ubuntu-2204:2022.10.2 - resource_class: xlarge - steps: - - install-dependencies-and-checkout - - run: pushd node && cargo check --features=runtime-benchmarks - node-test: - machine: - image: ubuntu-2204:2022.10.2 - resource_class: xlarge - steps: - - increase-swap - - install-dependencies-and-checkout - - run: - name: Build entropy-protocol nodejs package. - command: | - cd crates/protocol - make build-nodejs-testing - cd nodejs-test - yarn - cd ../../.. - - run: - command: | - pushd node - cargo build --all-targets --release -j $(nproc) - cargo test --all-targets --release - yarn --cwd ../crates/protocol/nodejs-test test - cargo test -p entropy-tss --release --features=test_helpers -F wasm_test test_wasm - no_output_timeout: 45m - build-and-release: - machine: - image: ubuntu-2204:2022.10.2 - resource_class: xlarge - steps: - - increase-swap - - install-dependencies-and-checkout - - build - - release - check-doc-build: - machine: - image: ubuntu-2204:2022.10.2 - resource_class: xlarge - steps: - - install-dependencies-and-checkout - - run: cargo doc --no-deps - check-chainspecs: - machine: - image: ubuntu-2204:2022.10.2 - resource_class: xlarge - steps: - - install-dependencies-and-checkout - - run: - command: | - cargo run -p entropy -- build-spec --raw --chain dev > chainspec-dev-raw.json - cargo run -p entropy -- build-spec --raw --chain integration-tests > chainspec-integration-raw.json - cargo run -p entropy -- build-spec --raw --chain testnet > chainspec-testnet-raw.json - - -parameters: - crates: - default: false - type: boolean - node: - default: false - type: boolean - pallets: - default: false - type: boolean - runtime: - default: false - type: boolean -version: 2.1 -workflows: - lint: - jobs: - - fmt-lint-all - test: - jobs: - - node-benchmark - build: - jobs: - - node-test - when: - or: - - << pipeline.parameters.node >> - - << pipeline.parameters.pallets >> - - << pipeline.parameters.runtime >> - - pipeline.parameters.crates - chainspecs: - jobs: - - check-chainspecs - documentation: - jobs: - - check-doc-build From 35f47d56ec2408b39d02f0a746a2cd7e2eb48154 Mon Sep 17 00:00:00 2001 From: Zach Mandeville Date: Tue, 13 Aug 2024 19:35:41 +1200 Subject: [PATCH 8/9] Run build-test on xl runner + small readme change --- .github/workflows/build-and-run-node-test.yaml | 4 ++-- crates/README.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-and-run-node-test.yaml b/.github/workflows/build-and-run-node-test.yaml index 7130576f9..9d3dd237c 100644 --- a/.github/workflows/build-and-run-node-test.yaml +++ b/.github/workflows/build-and-run-node-test.yaml @@ -9,8 +9,8 @@ on: - "runtime/*" jobs: - node-test: - runs-on: ubuntu-latest + node-test: + runs-on: core-build-runner steps: - uses: actions/checkout@v4 - name: Increase swap diff --git a/crates/README.md b/crates/README.md index e483180d7..217f848f9 100644 --- a/crates/README.md +++ b/crates/README.md @@ -2,7 +2,7 @@ This directory contains the [Threshold Signature Server](https://github.com/entropyxyz/entropy-core/tree/master/crates/threshold-signature-server) and some utility crates related to it: -- [`shared`](https://github.com/entropyxyz/entropy-core/tree/master/crates/shared) - Common types shared by both the chain node and TSS server +- [`shared`](https://github.com/entropyxyz/entropy-core/tree/master/crates/shared) - Common types shared by the chain node and TSS server - [`kvdb`](https://github.com/entropyxyz/entropy-core/tree/master/crates/kvdb) - An encrypted key-value datastore - [`protocol`](https://github.com/entropyxyz/entropy-core/tree/master/crates/protocol) - Transport logic for running the Entropy protocols - [`testing-utils`](https://github.com/entropyxyz/entropy-core/tree/master/crates/testing-utils) - Testing utility methods shared across the workspace From e4d783963a127983a26a482ca6acbd969f39d528 Mon Sep 17 00:00:00 2001 From: Zach <120055804+cooldracula@users.noreply.github.com> Date: Wed, 14 Aug 2024 08:13:12 +1200 Subject: [PATCH 9/9] Update .github/workflows/build-and-run-node-test.yaml Co-authored-by: Hernando Castano --- .github/workflows/build-and-run-node-test.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-run-node-test.yaml b/.github/workflows/build-and-run-node-test.yaml index 9d3dd237c..0c28340f6 100644 --- a/.github/workflows/build-and-run-node-test.yaml +++ b/.github/workflows/build-and-run-node-test.yaml @@ -5,8 +5,8 @@ on: paths: - "node/**" - "crates/**" - - "pallets/*" - - "runtime/*" + - "pallets/**" + - "runtime/**" jobs: node-test: