From 534f9511657c2777e72540ddf7f8fb73366acd41 Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Fri, 29 Jul 2022 09:36:09 -0500 Subject: [PATCH] Consolidate GitHub CI actions, split out Monero (#71) * Consolidate GitHub CI actions, split out Monero build now includes the specified Rust toolchain/components. Added a test dependencies action which grabs Foundry and Monero. Split the Monero v14 job into a matrixed job in its own workflow flow. It's now only run when Monero has changes. * Correct Monero unit/integration tests run timing Additionally tests a feature-less Monero build. Also removes a pointless Monero file, which already should have been removed, causing this workflow to be triggered. * Correct exclusion and paths Updates to FROST should re-run the Monero tests to ensure it didn't introduce API incompatibilities. --- .github/actions/build-dependencies/action.yml | 17 ++++++ .github/actions/cached-rust/action.yml | 2 +- .github/actions/monero/action.yml | 2 +- .github/actions/test-dependencies/action.yml | 24 ++++++++ .github/workflows/monero-tests.yaml | 57 +++++++++++++++++++ .github/workflows/tests.yml | 50 ++-------------- coins/monero/.gitignore | 1 - 7 files changed, 106 insertions(+), 47 deletions(-) create mode 100644 .github/actions/test-dependencies/action.yml create mode 100644 .github/workflows/monero-tests.yaml delete mode 100644 coins/monero/.gitignore diff --git a/.github/actions/build-dependencies/action.yml b/.github/actions/build-dependencies/action.yml index e5520f0e..c60c759e 100644 --- a/.github/actions/build-dependencies/action.yml +++ b/.github/actions/build-dependencies/action.yml @@ -1,6 +1,17 @@ name: build-dependencies description: Installs build dependencies for Serai +inputs: + rust-toolchain: + description: "Rust toolchain to install" + required: false + default: stable + + rust-components: + description: "Rust components to install" + required: false + default: + runs: using: "composite" steps: @@ -11,6 +22,12 @@ runs: solc-select install 0.8.9 solc-select use 0.8.9 + - name: Install Rust + uses: ./.github/actions/cached-rust + with: + toolchain: ${{ inputs.rust-toolchain }} + components: ${{ inputs.rust-components }} + - name: Install WASM toolchain uses: actions-rs/toolchain@v1 with: diff --git a/.github/actions/cached-rust/action.yml b/.github/actions/cached-rust/action.yml index 12ea9a07..7149f78f 100644 --- a/.github/actions/cached-rust/action.yml +++ b/.github/actions/cached-rust/action.yml @@ -15,7 +15,7 @@ inputs: runs: using: "composite" steps: - - name: Rust cache + - name: Rust Cache uses: actions/cache@v3 with: path: | diff --git a/.github/actions/monero/action.yml b/.github/actions/monero/action.yml index cb788f46..10ec5056 100644 --- a/.github/actions/monero/action.yml +++ b/.github/actions/monero/action.yml @@ -10,7 +10,7 @@ inputs: runs: using: "composite" steps: - - name: Monero daemon cache + - name: Monero Daemon Cache id: cache-monerod uses: actions/cache@v3 with: diff --git a/.github/actions/test-dependencies/action.yml b/.github/actions/test-dependencies/action.yml new file mode 100644 index 00000000..60dcc19c --- /dev/null +++ b/.github/actions/test-dependencies/action.yml @@ -0,0 +1,24 @@ +name: test-dependencies +description: Installs test dependencies for Serai + +inputs: + monero-version: + description: "Monero version to download and run as a regtest node" + required: false + default: v0.18.0.0 + +runs: + using: "composite" + steps: + - name: Install Build Dependencies + uses: ./.github/actions/build-dependencies + + - name: Install Foundry + uses: foundry-rs/foundry-toolchain@v1 + with: + version: nightly + + - name: Run a Monero Regtest Node + uses: ./.github/actions/monero + with: + version: ${{ inputs.monero-version }} diff --git a/.github/workflows/monero-tests.yaml b/.github/workflows/monero-tests.yaml new file mode 100644 index 00000000..a8f91e69 --- /dev/null +++ b/.github/workflows/monero-tests.yaml @@ -0,0 +1,57 @@ +name: Monero Tests + +on: + push: + branches: + - develop + paths: + - "coins/monero/**" + + pull_request: + paths: + - "coins/monero/**" + +jobs: + # Only run these once since they will be consistent regardless of any node + unit-tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + submodules: "recursive" + + - name: Test Dependencies + uses: ./.github/actions/test-dependencies + + - name: Run Unit Tests Without Features + run: cargo test --package monero-serai --lib + + - name: Run Unit Tests + run: cargo test --package monero-serai --all-features --lib + + integration-tests: + runs-on: ubuntu-latest + # Test against all supported protocol versions + strategy: + matrix: + version: [v0.17.3.2, v0.18.0.0] + + steps: + - uses: actions/checkout@v3 + with: + submodules: "recursive" + + - name: Test Dependencies + uses: ./.github/actions/test-dependencies + with: + monero-version: ${{ matrix.version }} + + - name: Run Integration Tests Without Features + run: cargo test --package monero-serai --test '*' + + - name: Run Integration Tests + # https://github.com/rust-lang/cargo/issues/8396 + run: cargo test --package monero-serai --all-features --test '*' + + - name: Run Processor's Monero Tests + run: cargo test --package serai-processor monero diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9b44b567..32b8626d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -16,13 +16,10 @@ jobs: - name: Build Dependencies uses: ./.github/actions/build-dependencies - - - name: Install Rust - uses: ./.github/actions/cached-rust with: # Clippy requires nightly for some reason - toolchain: nightly - components: clippy + rust-toolchain: nightly + rust-components: clippy - name: Run Clippy run: cargo clippy --all-features -- -D warnings -A clippy::type_complexity -A dead_code @@ -34,53 +31,18 @@ jobs: with: submodules: "recursive" - - name: Build Dependencies - uses: ./.github/actions/build-dependencies + - name: Test Dependencies + uses: ./.github/actions/test-dependencies - - name: Install Foundry - uses: foundry-rs/foundry-toolchain@v1 - with: - version: nightly - - - name: Monero Regtest Daemon - uses: ./.github/actions/monero - - - name: Install Rust - uses: ./.github/actions/cached-rust - - - name: Run tests + - name: Run Tests run: cargo test --all-features - # Test the Monero code against protocol v14 (node v17) as well - test-monero14: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - submodules: "recursive" - - - name: Build Dependencies - uses: ./.github/actions/build-dependencies - - - name: Monero Regtest Daemon - uses: ./.github/actions/monero - with: - version: v0.17.3.2 - - - name: Install Rust - uses: ./.github/actions/cached-rust - - - name: Run tests - run: | - (cd coins/monero && cargo test --all-features) - (cd processor && cargo test --all-features monero) - fmt: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - # Doesn't grab the cache because it doesn't need it + # Doesn't grab the cache as it's not needed - name: Install rustfmt uses: actions-rs/toolchain@v1 with: diff --git a/coins/monero/.gitignore b/coins/monero/.gitignore deleted file mode 100644 index 9871762c..00000000 --- a/coins/monero/.gitignore +++ /dev/null @@ -1 +0,0 @@ -c/.build