name: Test workflow on: push: branches: - main pull_request: branches: - main types: [opened, synchronize] concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true env: CARGO_TERM_COLOR: always jobs: cache-polkadot: name: Build and cache Polkadot binaries on ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: matrix: os: [ubuntu-24.04, macos-14] steps: - name: Checkout repo and submodules uses: actions/checkout@v4 with: submodules: recursive - name: Install dependencies (Linux) if: matrix.os == 'ubuntu-24.04' run: | sudo apt-get update sudo apt-get install -y protobuf-compiler clang libclang-dev rustup target add wasm32-unknown-unknown rustup component add rust-src - name: Install dependencies (macOS) if: matrix.os == 'macos-14' run: | brew install protobuf rustup target add wasm32-unknown-unknown rustup component add rust-src - name: Cache binaries id: cache uses: actions/cache@v3 with: path: | ~/.cargo/bin/substrate-node ~/.cargo/bin/eth-rpc key: polkadot-binaries-${{ matrix.os }}-${{ hashFiles('polkadot-sdk/.git') }} - name: Build substrate-node if: steps.cache.outputs.cache-hit != 'true' run: | cd polkadot-sdk cargo install --locked --force --profile=production --path substrate/bin/node/cli --bin substrate-node --features cli - name: Build eth-rpc if: steps.cache.outputs.cache-hit != 'true' run: | cd polkadot-sdk cargo install --path substrate/frame/revive/rpc --bin eth-rpc ci: name: CI on ${{ matrix.os }} needs: cache-polkadot runs-on: ${{ matrix.os }} strategy: matrix: os: [ubuntu-24.04, macos-14] steps: - name: Checkout repo uses: actions/checkout@v4 - name: Restore binaries from cache uses: actions/cache@v3 with: path: | ~/.cargo/bin/substrate-node ~/.cargo/bin/eth-rpc key: polkadot-binaries-${{ matrix.os }}-${{ hashFiles('polkadot-sdk/.git') }} - name: Setup Rust toolchain uses: actions-rust-lang/setup-rust-toolchain@v1 with: rustflags: "" - name: Add wasm32 target run: | rustup target add wasm32-unknown-unknown rustup component add rust-src - name: Install Geth on Ubuntu if: matrix.os == 'ubuntu-24.04' run: | sudo add-apt-repository -y ppa:ethereum/ethereum sudo apt-get update sudo apt-get install -y protobuf-compiler sudo apt-get install -y solc # We were facing some issues in CI with the 1.16.* versions of geth, and specifically on # Ubuntu. Eventually, we found out that the last version of geth that worked in our CI was # version 1.15.11. Thus, this is the version that we want to use in CI. The PPA sadly does # not have historic versions of Geth and therefore we need to resort to downloading pre # built binaries for Geth and the surrounding tools which is what the following parts of # the script do. sudo apt-get install -y wget ca-certificates tar ARCH=$(uname -m) if [ "$ARCH" = "x86_64" ]; then URL="https://gethstore.blob.core.windows.net/builds/geth-alltools-linux-amd64-1.15.11-36b2371c.tar.gz" elif [ "$ARCH" = "aarch64" ]; then URL="https://gethstore.blob.core.windows.net/builds/geth-alltools-linux-arm64-1.15.11-36b2371c.tar.gz" else echo "Unsupported architecture: $ARCH" exit 1 fi wget -qO- "$URL" | sudo tar xz -C /usr/local/bin --strip-components=1 geth --version curl -sL https://github.com/paritytech/revive/releases/download/v0.3.0/resolc-x86_64-unknown-linux-musl -o resolc chmod +x resolc sudo mv resolc /usr/local/bin - name: Install Geth on macOS if: matrix.os == 'macos-14' run: | brew tap ethereum/ethereum brew install ethereum protobuf brew install solidity curl -sL https://github.com/paritytech/revive/releases/download/v0.3.0/resolc-universal-apple-darwin -o resolc chmod +x resolc sudo mv resolc /usr/local/bin - name: Machete uses: bnjbvr/cargo-machete@v0.7.1 - name: Format run: make format - name: Clippy run: make clippy - name: Check substrate-node version run: substrate-node --version - name: Check eth-rpc version run: eth-rpc --version - name: Check resolc version run: resolc --version - name: Test cargo workspace run: make test