feat: add run_until_blocked_or_time to pure-stage #1445
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Continuous Integration | |
on: | |
workflow_dispatch: | |
push: | |
branches: ["main"] | |
pull_request: | |
types: [opened, synchronize, reopened, converted_to_draft, ready_for_review] | |
branches: ["*"] | |
env: | |
CARGO_TERM_COLOR: always | |
RUST_CACHE_PATH: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
target/ | |
jobs: | |
sanity: | |
name: Sanity | |
timeout-minutes: 30 | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/cache/restore@v4 | |
with: | |
path: ${{ env.RUST_CACHE_PATH }} | |
key: cargo-x86_64-unknown-linux-gnu | |
restore-keys: | | |
cargo-x86_64-unknown-linux-gnu | |
- name: Check format | |
run: cargo fmt-amaru | |
- name: Run clippy | |
run: cargo clippy-amaru | |
build: | |
name: Build on ${{ matrix.environments.runner }} with target ${{ matrix.environments.target }} | |
strategy: | |
fail-fast: false | |
matrix: | |
environments: | |
- runner: ubuntu-latest | |
target: x86_64-unknown-linux-gnu | |
- runner: macos-latest | |
target: aarch64-apple-darwin | |
- runner: windows-latest | |
target: x86_64-pc-windows-msvc | |
command: test --profile dev-debug | |
- runner: ubuntu-latest | |
target: wasm32-unknown-unknown | |
packages: -p amaru-consensus -p amaru-ledger -p amaru-ouroboros -p slot-arithmetic | |
command: build | |
setup: rustup target add wasm32-unknown-unknown | |
- runner: ubuntu-latest | |
target: riscv32im-risc0-zkvm-elf | |
packages: -p amaru-ledger -p slot-arithmetic | |
extra-args: +nightly -Zbuild-std=std,panic_abort | |
command: build | |
setup: | | |
curl -L https://risczero.com/install | bash | |
/home/runner/.risc0/bin/rzup install | |
rustup toolchain add nightly-x86_64-unknown-linux-gnu | |
rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu | |
- runner: ubuntu-24.04 | |
target: aarch64-unknown-linux-musl | |
command: test | |
setup: rustup target add aarch64-unknown-linux-musl && sudo apt-get install -y pkg-config libssl-dev | |
cross-compile: true | |
timeout-minutes: 30 | |
runs-on: ${{ matrix.environments.runner }} | |
steps: | |
- uses: actions/checkout@v4 | |
- id: timestamp | |
shell: bash | |
run: | | |
echo "value=$(/bin/date -u '+%Y%m%d-%H%M%S')" >> $GITHUB_OUTPUT | |
# Cache dependencies when pushing (i.e. merging into allowed branch). | |
- uses: actions/cache@v4 | |
if: github.event_name == 'push' | |
with: | |
path: ${{ env.RUST_CACHE_PATH }} | |
key: cargo-${{ matrix.environments.target }}-${{ steps.timestamp.outputs.value }} | |
restore-keys: | | |
cargo-${{ matrix.environments.target }} | |
# Only restore cache for other types of events (e.g. Pull requests). | |
- uses: actions/cache/restore@v4 | |
if: github.event_name != 'push' | |
with: | |
path: ${{ env.RUST_CACHE_PATH }} | |
key: cargo-${{ matrix.environments.target }} | |
restore-keys: | | |
cargo-${{ matrix.environments.target }} | |
- name: Run tests | |
run: | | |
set +e | |
EXTRA_ARGS="${{ matrix.environments.extra-args || '' }}" | |
SCOPE="${{ matrix.environments.packages || '' }}" | |
COMMAND="${{ matrix.environments.command || 'test-amaru' }}" | |
if [[ -n "${{ matrix.environments.setup }}" ]]; then | |
echo "Running setup command: ${{ matrix.environments.setup }}" | |
${{ matrix.environments.setup }} | |
fi | |
if [[ "${{ matrix.environments.cross-compile }}" == "true" ]] ; then | |
cargo install cross --git https://github.com/cross-rs/cross | |
# cross doesn't load .cargo/config.toml, see https://github.com/cross-rs/cross/issues/562 | |
$HOME/.cargo/bin/cross $COMMAND --locked --all-features $SCOPE --target ${{ matrix.environments.target }} | |
else | |
if [[ "${{ matrix.environments.target }}" == "x86_64-unknown-linux-gnu" ]] ; then | |
cargo $EXTRA_ARGS $COMMAND $SCOPE --locked | |
else | |
cargo $EXTRA_ARGS $COMMAND $SCOPE --locked --target ${{ matrix.environments.target }} | |
fi | |
fi | |
exitcode="$?" | |
if [[ "${{ matrix.environments.optional }}" == "true" && "$exitcode" != "0" ]] ; then | |
# Propagate failure as a warning | |
# but do not fail the job | |
echo "::warning::Tests failed with exit code $exitcode" | |
exit 0 | |
else | |
exit "$exitcode" | |
fi | |
shell: bash | |
coverage: | |
name: Coverage | |
runs-on: ubuntu-latest | |
if: ${{ !github.event.pull_request.draft }} | |
env: | |
CARGO_TERM_COLOR: always | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/cache/restore@v4 | |
with: | |
path: ${{ env.RUST_CACHE_PATH }} | |
key: cargo-x86_64-unknown-linux-gnu | |
restore-keys: | | |
cargo-x86_64-unknown-linux-gnu | |
- name: Install cargo-llvm-cov | |
uses: taiki-e/install-action@cargo-llvm-cov | |
- name: Generate code coverage | |
run: make coverage-lconv | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v3 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
files: lcov.info | |
snapshots: | |
name: Snapshots | |
runs-on: ubuntu-latest | |
if: ${{ !github.event.pull_request.draft }} | |
env: | |
AMARU_PEER_ADDRESS: 127.0.0.1:3001 | |
strategy: | |
matrix: | |
network: | |
- name: preprod | |
magic: 1 | |
cardano_node_version: [10.1.4] | |
continue-on-error: true | |
steps: | |
- uses: actions/checkout@v4 | |
- id: timestamp | |
shell: bash | |
run: | | |
echo "value=$(/bin/date -u '+%Y%m%d-%H%M%S')" >> $GITHUB_OUTPUT | |
- name: Restore cardano-node DB | |
id: cache-cardano-node-db | |
uses: actions/cache/restore@v4 | |
with: | |
# The path should match the one used for the 'Nightly Sync' workflow. | |
path: ${{ runner.temp }}/db-${{ matrix.network.name }} | |
# The key should also match | |
key: cardano-node-ogmios-${{ matrix.network.name }} | |
restore-keys: | | |
cardano-node-ogmios-${{ matrix.network.name }} | |
- name: Check if cardano-node-db is available | |
if: steps.cache-cardano-node-db.outputs.cache-hit == '' | |
run: | | |
echo "Haskell node db not available, aborting job." | |
exit 1 | |
- name: Spawn Haskell Node | |
id: spawn-cardano-node | |
shell: bash | |
run: | | |
docker pull ghcr.io/intersectmbo/cardano-node:${{ matrix.cardano_node_version }} | |
make HASKELL_NODE_CONFIG_DIR=cardano-node-config NETWORK=${{ matrix.network.name }} download-haskell-config | |
docker run -d --name cardano-node \ | |
-v ${{ runner.temp }}/db-${{ matrix.network.name }}:/db \ | |
-v ${{ runner.temp }}/ipc:/ipc \ | |
-v ./cardano-node-config:/config \ | |
-v ./cardano-node-config:/genesis \ | |
-p 3001:3001 \ | |
ghcr.io/intersectmbo/cardano-node:${{ matrix.cardano_node_version }} run \ | |
--config /config/config.json \ | |
--database-path /db \ | |
--socket-path /ipc/node.socket \ | |
--topology /config/topology.json | |
- uses: actions/cache/restore@v4 | |
with: | |
path: ${{ env.RUST_CACHE_PATH }} | |
key: cargo-x86_64-unknown-linux-gnu | |
restore-keys: | | |
cargo-x86_64-unknown-linux-gnu | |
- name: Build Amaru | |
run: | | |
cargo test --no-run -p amaru | |
- name: Cache Amaru's ledger.${{ matrix.network.name }}.db | |
id: cache-ledger-db | |
uses: actions/cache/restore@v4 | |
with: | |
path: ./ledger.${{ matrix.network.name }}.db | |
# If the ledger store serialisation format changes and become | |
# incompatible, it is necessary to bump the index below to invalidate | |
# the cached ledger snapshots, and recompute them from the CBOR ones | |
# (i.e. Full bootstrap below) | |
key: ${{ runner.OS }}-ledger-cache-v6-${{ steps.timestamp.outputs.value }} | |
restore-keys: | | |
${{ runner.OS }}-ledger-cache-v6 | |
- name: Full bootstrap amaru | |
if: steps.cache-ledger-db.outputs.cache-hit == '' | |
run: | | |
make BUILD_PROFILE=test NETWORK=${{ matrix.network.name }} bootstrap | |
- name: Light bootstrap amaru | |
if: steps.cache-ledger-db.outputs.cache-hit != '' | |
run: | | |
make BUILD_PROFILE=test NETWORK=${{ matrix.network.name }} import-headers | |
make BUILD_PROFILE=test NETWORK=${{ matrix.network.name }} import-nonces | |
- uses: actions/cache/save@v4 | |
if: github.event_name == 'push' || steps.cache-ledger-db.outputs.cache-hit == '' | |
with: | |
path: ./ledger.${{ matrix.network.name }}.db | |
key: ${{ runner.OS }}-ledger-cache-v6-${{ steps.timestamp.outputs.value }} | |
- name: Install Cardano CLI | |
if: github.event_name != 'pull_request' | |
run: | | |
set -eux | |
VERSION="10.11.0.0" | |
curl -L -o cardano-cli.tar.gz \ | |
"https://github.com/IntersectMBO/cardano-cli/releases/download/cardano-cli-${VERSION}/cardano-cli-${VERSION}-x86_64-linux.tar.gz" | |
mkdir -p cardano-cli-bin | |
tar -xzf cardano-cli.tar.gz -C cardano-cli-bin | |
mv cardano-cli-bin/cardano-cli* cardano-cli-bin/cardano-cli | |
ls $PWD/cardano-cli-bin/ | |
chmod +x cardano-cli-bin/cardano-cli | |
- name: Run node | |
timeout-minutes: 30 | |
shell: bash | |
run: | | |
set -eux | |
if [[ "${{ github.event_name }}" != "pull_request" ]]; then | |
# If this is a push event, we want to test all revolut epochs | |
export DEMO_TARGET_EPOCH=$(sudo $PWD/cardano-cli-bin/cardano-cli query tip --socket-path ${{ runner.temp }}/ipc/node.socket --testnet-magic ${{ matrix.network.magic }} | jq '.epoch - 1') | |
fi | |
make BUILD_PROFILE=test demo | |
- name: Run tests | |
run: | | |
make BUILD_PROFILE=test NETWORK=${{ matrix.network.name }} test-e2e | |
- name: Teardown haskell node | |
shell: bash | |
run: | | |
docker stop cardano-node | |
docker rm cardano-node | |
- uses: actions/cache/save@v4 | |
if: github.event_name == 'push' | |
with: | |
path: ${{ runner.temp }}/db-${{ matrix.network.name }} | |
key: cardano-node-ogmios-${{ matrix.network.name }}-${{ steps.timestamp.outputs.value }} | |
examples: | |
name: Examples | |
strategy: | |
fail-fast: false | |
matrix: | |
projects: | |
- ledger-in-nodejs | |
defaults: | |
run: | |
working-directory: examples/${{ matrix.projects }} | |
timeout-minutes: 30 | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/cache/restore@v4 | |
with: | |
path: ${{ env.RUST_CACHE_PATH }} | |
key: cargo-wasm32-unknown-unknown | |
restore-keys: | | |
cargo-wasm32-unknown-unknown | |
- name: Run make | |
run: make |