Skip to content

feat(pop-cli): add global --json flag for structured CLI output #1301

feat(pop-cli): add global --json flag for structured CLI output

feat(pop-cli): add global --json flag for structured CLI output #1301

name: integration tests
permissions:
contents: read
packages: read
on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
paths-ignore:
- '**.md'
- 'docs/**'
- 'LICENSE'
- '.gitignore'
- '.github/**.md'
env:
CARGO_TERM_COLOR: always
GITHUB_ACTOR: pop-cli
CARGO_INCREMENTAL: 1
RUST_BACKTRACE: 1
# It is important to always use the same flags. Otherwise, the cache will not work.
RUSTFLAGS: "-Dwarnings"
RUSTDOCFLAGS: "-Dwarnings"
concurrency:
# Cancel any in-progress jobs for the same pull request or branch
group: integration-tests-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
pop-fork-integration-tests:
strategy:
fail-fast: true
matrix:
os:
- ubuntu-latest
- macos-latest
runs-on: ${{ matrix.os }}
steps:
- name: Free up space on runner (Linux)
if: matrix.os == 'ubuntu-latest'
shell: bash
run: |
set -xeuo pipefail
sudo rm -rf /usr/local/lib/android &
sudo rm -rf /usr/share/dotnet &
sudo rm -rf /usr/share/swift &
if command -v docker &> /dev/null; then
sudo docker image prune -af &
fi
sudo apt-get clean &
wait
- uses: actions/checkout@v4
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
default: true
target: wasm32-unknown-unknown
components: rust-src
- name: Rust Cache Linux
if: matrix.os == 'ubuntu-latest'
uses: Swatinem/rust-cache@v2
with:
cache-all-crates: true
save-if: ${{ github.ref == 'refs/heads/main' }}
shared-key: pop-cache
- name: Rust Cache MacOS
if: matrix.os == 'macos-latest'
uses: Swatinem/rust-cache@v2
with:
cache-all-crates: true
shared-key: pop-cache
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Install packages (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler
protoc --version
- name: Install packages (macOS)
if: matrix.os == 'macos-latest'
run: |
brew install protobuf
protoc --version
- name: Install cargo-nextest
uses: taiki-e/install-action@v2
with:
tool: cargo-nextest
- name: Cache pop binaries
uses: actions/cache@v4
with:
path: |
${{ matrix.os == 'ubuntu-latest' && '~/.cache/pop' || '~/Library/Caches/pop' }}
key: pop-binaries-${{ matrix.os }}-${{ runner.arch }}-${{ hashFiles('.github/workflows/integration-tests.yml', 'crates/pop-chains/src/up/mod.rs', 'crates/pop-common/src/test_env.rs') }}
restore-keys: |
pop-binaries-${{ matrix.os }}-${{ runner.arch }}-
- name: Start detached ink-node
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
set -euo pipefail
TAG="v0.47.0"
if [[ "${{ matrix.os }}" == "macos-latest" ]]; then
CACHE_DIR="${HOME}/Library/Caches/pop"
ARCHIVE="ink-node-mac-universal.tar.gz"
BIN_RELATIVE_PATH="ink-node-mac/ink-node"
else
CACHE_DIR="${HOME}/.cache/pop"
ARCHIVE="ink-node-linux.tar.gz"
BIN_RELATIVE_PATH="ink-node-linux/ink-node"
fi
INK_NODE_BIN="${CACHE_DIR}/${BIN_RELATIVE_PATH}"
if [[ ! -x "${INK_NODE_BIN}" ]]; then
URL="https://github.com/use-ink/ink-node/releases/download/${TAG}/${ARCHIVE}"
curl --fail --show-error --silent --location \
--retry 3 \
--output "/tmp/${ARCHIVE}" \
"${URL}"
mkdir -p "${CACHE_DIR}"
tar -xzf "/tmp/${ARCHIVE}" -C "${CACHE_DIR}"
chmod +x "${INK_NODE_BIN}"
fi
nohup "${INK_NODE_BIN}" --dev --tmp --rpc-port=9944 \
>/tmp/ink-node.log 2>&1 &
- name: Wait for ink-node RPC readiness
shell: bash
run: |
set -euo pipefail
ready=0
for _ in $(seq 1 30); do
if nc -z 127.0.0.1 9944; then
ready=1
break
fi
sleep 1
done
if [[ $ready -ne 1 ]]; then
echo "ink-node RPC did not become ready within 30 seconds" >&2
tail -n 200 /tmp/ink-node.log || true
exit 1
fi
- name: Run pop-fork integration tests
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
POP_FORK_TEST_NODE_WS_URL: ws://127.0.0.1:9944
run: |
cargo nextest run \
--release \
--locked \
-p pop-fork \
--features integration-tests \
--test fork \
-j 8 \
--no-fail-fast \
--status-level all
- name: Stop detached ink-node
if: always()
run: |
pkill ink-node || true
pkill eth-rpc || true
contract-integration-tests:
strategy:
fail-fast: true
matrix:
os:
- ubuntu-latest
- macos-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Free up space on runner
if: matrix.os == 'ubuntu-latest'
shell: bash
run: |
set -xeuo pipefail
sudo rm -rf /usr/local/lib/android &
sudo rm -rf /usr/share/dotnet &
sudo rm -rf /usr/share/swift &
if command -v docker &> /dev/null; then
sudo docker image prune -af &
fi
sudo apt-get clean &
wait
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
default: true
target: wasm32-unknown-unknown
components: rust-src, clippy
- name: Rust Cache Linux
if: matrix.os == 'ubuntu-latest'
uses: Swatinem/rust-cache@v2
with:
cache-all-crates: true
save-if: ${{ github.ref == 'refs/heads/main' }}
shared-key: pop-cache
- name: Rust Cache MacOS
if: matrix.os == 'macos-latest'
uses: Swatinem/rust-cache@v2
with:
cache-all-crates: true
save-if: ${{ github.ref == 'refs/heads/main' }}
shared-key: pop-cache
- name: Install packages (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler
protoc --version
- name: Install packages (macOS)
if: matrix.os == 'macos-latest'
run: |
brew install protobuf
protoc --version
- name: Install cargo-nextest
uses: taiki-e/install-action@v2
with:
tool: cargo-nextest
- name: Cache pop binaries
uses: actions/cache@v4
with:
path: |
${{ matrix.os == 'ubuntu-latest' && '~/.cache/pop' || '~/Library/Caches/pop' }}
key: pop-binaries-${{ matrix.os }}-${{ runner.arch }}-${{ hashFiles('.github/workflows/integration-tests.yml', 'crates/pop-chains/src/up/mod.rs', 'crates/pop-common/src/test_env.rs') }}
restore-keys: |
pop-binaries-${{ matrix.os }}-${{ runner.arch }}-
- name: Run integration tests
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cargo nextest run \
--release \
--locked \
-p pop-contracts \
--features integration-tests \
--test contracts \
-j 8 \
--no-fail-fast \
--nocapture \
--status-level all
chain-integration-tests:
strategy:
fail-fast: true
matrix:
os:
- ubuntu-latest
- macos-latest
runs-on: ${{ matrix.os }}
steps:
- name: Free up space on runner (Linux)
if: matrix.os == 'ubuntu-latest'
shell: bash
run: |
set -xeuo pipefail
sudo rm -rf /usr/local/lib/android &
sudo rm -rf /usr/share/dotnet &
sudo rm -rf /usr/share/swift &
if command -v docker &> /dev/null; then
sudo docker image prune -af &
fi
sudo apt-get clean &
wait
- uses: actions/checkout@v4
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
default: true
target: wasm32-unknown-unknown
components: rust-src
- name: Rust Cache Linux
if: matrix.os == 'ubuntu-latest'
uses: Swatinem/rust-cache@v2
with:
cache-all-crates: true
save-if: ${{ github.ref == 'refs/heads/main' }}
shared-key: pop-cache
- name: Rust Cache MacOS
if: matrix.os == 'macos-latest'
uses: Swatinem/rust-cache@v2
with:
cache-all-crates: true
shared-key: pop-cache
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Install packages (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler
protoc --version
- name: Install packages (macOS)
if: matrix.os == 'macos-latest'
run: |
brew install protobuf
protoc --version
- name: Install cargo-nextest
uses: taiki-e/install-action@v2
with:
tool: cargo-nextest
- name: Cache pop binaries
uses: actions/cache@v4
with:
path: |
${{ matrix.os == 'ubuntu-latest' && '~/.cache/pop' || '~/Library/Caches/pop' }}
key: pop-binaries-${{ matrix.os }}-${{ runner.arch }}-${{ hashFiles('.github/workflows/integration-tests.yml', 'crates/pop-chains/src/up/mod.rs', 'crates/pop-common/src/test_env.rs') }}
restore-keys: |
pop-binaries-${{ matrix.os }}-${{ runner.arch }}-
- name: Run integration tests
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cargo nextest run \
--release \
--locked \
-p pop-chains \
--features integration-tests \
--test chain \
--test metadata \
-j 8 \
--no-fail-fast \
--nocapture \
--status-level all
pop-cli-integration-tests:
strategy:
fail-fast: true
matrix:
os:
- ubuntu-latest
- macos-latest
runs-on: ${{ matrix.os }}
steps:
- name: Free up space on runner (Linux)
if: matrix.os == 'ubuntu-latest'
shell: bash
run: |
set -xeuo pipefail
sudo rm -rf /usr/local/lib/android &
sudo rm -rf /usr/share/dotnet &
sudo rm -rf /usr/share/swift &
if command -v docker &> /dev/null; then
sudo docker image prune -af &
fi
sudo apt-get clean &
wait
- uses: actions/checkout@v4
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
default: true
target: wasm32-unknown-unknown
components: rust-src
- name: Rust Cache Linux
if: matrix.os == 'ubuntu-latest'
uses: Swatinem/rust-cache@v2
with:
cache-all-crates: true
save-if: ${{ github.ref == 'refs/heads/main' }}
shared-key: pop-cache
- name: Rust Cache MacOS
if: matrix.os == 'macos-latest'
uses: Swatinem/rust-cache@v2
with:
cache-all-crates: true
shared-key: pop-cache
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Install packages (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler
protoc --version
- name: Install packages (macOS)
if: matrix.os == 'macos-latest'
run: |
brew install protobuf
protoc --version
- name: Install cargo-nextest
uses: taiki-e/install-action@v2
with:
tool: cargo-nextest
- name: Cache pop binaries
uses: actions/cache@v4
with:
path: |
${{ matrix.os == 'ubuntu-latest' && '~/.cache/pop' || '~/Library/Caches/pop' }}
key: pop-binaries-${{ matrix.os }}-${{ runner.arch }}-${{ hashFiles('.github/workflows/integration-tests.yml', 'crates/pop-chains/src/up/mod.rs', 'crates/pop-common/src/test_env.rs') }}
restore-keys: |
pop-binaries-${{ matrix.os }}-${{ runner.arch }}-
- name: Run pop-cli integration tests
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
extra_nextest_args=()
if [[ "${{ matrix.os }}" == "macos-latest" ]]; then
extra_nextest_args=(-- --skip verifiable_contract_lifecycle)
fi
cargo nextest run \
--release \
--locked \
--no-default-features \
--features "chain,contract,integration-tests" \
-p pop-cli \
--test contract \
--test chain \
--test fork \
-j 8 \
--no-fail-fast \
--nocapture \
--status-level all \
"${extra_nextest_args[@]}"