Add a testing step

This commit is contained in:
Omar Abdulla
2025-11-10 11:17:25 +03:00
parent b444279a4c
commit 063336da4b
+96 -4
View File
@@ -75,6 +75,98 @@ jobs:
uses: davidB/rust-cargo-make@v1
- name: Run Cargo Clippy
run: cargo make clippy
test:
name: Unit Tests
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-24.04, macos-14]
env:
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
POLKADOT_SDK_COMMIT_HASH: "30cda2aad8612a10ff729d494acd9d5353294d63"
steps:
- name: Checkout This Repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Run Sccache
uses: mozilla-actions/sccache-action@v0.0.9
- name: Install the Rust Toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: "wasm32-unknown-unknown"
components: "rust-src"
- name: Install the Cargo Make Binary
uses: davidB/rust-cargo-make@v1
- name: Run Cargo Clippy
run: cargo make clippy
- name: Caching Step
id: cache-step
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/polkadot
~/.cargo/bin/polkadot-parachain
~/.cargo/bin/polkadot-prepare-worker
~/.cargo/bin/polkadot-execute-worker
~/.cargo/bin/eth-rpc
~/.cargo/bin/revive-dev-node
key: polkadot-binaries-${{ env.POLKADOT_SDK_COMMIT_HASH }}-${{ matrix.os }}
- 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: Install Kurtosis on macOS
if: matrix.os == 'macos-14'
run: brew install kurtosis-tech/tap/kurtosis-cli
- name: Install Kurtosis on Ubuntu
if: matrix.os == 'ubuntu-24.04'
run: |
echo "deb [trusted=yes] https://apt.fury.io/kurtosis-tech/ /" | sudo tee /etc/apt/sources.list.d/kurtosis.list
sudo apt update
sudo apt install kurtosis-cli
- name: Run Tests
run: cargo make test
cache-polkadot:
name: Build and Cache Polkadot Binaries on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
@@ -120,7 +212,7 @@ jobs:
~/.cargo/bin/polkadot-execute-worker
~/.cargo/bin/eth-rpc
~/.cargo/bin/revive-dev-node
key: polkadot-binaries-${{ env.POLKADOT_SDK_COMMIT_HASH }}
key: polkadot-binaries-${{ env.POLKADOT_SDK_COMMIT_HASH }}-${{ matrix.os }}
- name: Build Polkadot Dependencies
if: steps.cache-step.outputs.cache-hit != 'true'
@@ -138,12 +230,12 @@ jobs:
--bin polkadot \
--bin polkadot-prepare-worker \
--bin polkadot-execute-worker;
mv ./target/production/revive-dev-node ~/.cargo/bin
mv ./target/production/eth-rpc ~/.cargo/bin
mv ./target/production/polkadot-parachain ~/.cargo/bin
mv ./target/testnet/polkadot ~/.cargo/bin
mv ./target/production/polkadot-parachain ~/.cargo/bin
mv ./target/testnet/polkadot-prepare-worker ~/.cargo/bin
mv ./target/testnet/polkadot-execute-worker ~/.cargo/bin
mv ./target/production/revive-dev-node ~/.cargo/bin
mv ./target/production/eth-rpc ~/.cargo/bin
chmod +x ~/.cargo/bin/*
# name: Test workflow