|
| 1 | +#!/usr/bin/env bash |
| 2 | +set -euo pipefail |
| 3 | + |
| 4 | +# Script to validate all examples in the examples/ directory |
| 5 | +# This script can be run locally or in CI |
| 6 | + |
| 7 | +# Add icp binary to PATH (assumes it's in target/debug) |
| 8 | +export PATH="$(pwd)/target/debug:$PATH" |
| 9 | +echo "icp version: $(icp --version)" |
| 10 | +echo "icp path: $(which icp)" |
| 11 | + |
| 12 | +# Get all example directories |
| 13 | +for example_dir in examples/*/; do |
| 14 | + # Skip if not a directory |
| 15 | + if [ ! -d "$example_dir" ]; then |
| 16 | + continue |
| 17 | + fi |
| 18 | + |
| 19 | + example_name=$(basename "$example_dir") |
| 20 | + echo "" |
| 21 | + echo "==========================================" |
| 22 | + echo "Validating example: $example_name" |
| 23 | + echo "==========================================" |
| 24 | + |
| 25 | + pushd "$example_dir" |
| 26 | + |
| 27 | + # Check if test.sh exists |
| 28 | + if [ -f "test.sh" ]; then |
| 29 | + echo "Found test.sh, running it..." |
| 30 | + if ! bash test.sh; then |
| 31 | + echo "❌ test.sh failed in $example_name" |
| 32 | + exit 1 |
| 33 | + fi |
| 34 | + echo "✅ test.sh passed for $example_name" |
| 35 | + else |
| 36 | + # Run icp project show to validate the project |
| 37 | + echo "Running: icp project show" |
| 38 | + if ! icp project show; then |
| 39 | + echo "❌ Failed to validate project in $example_name" |
| 40 | + exit 1 |
| 41 | + fi |
| 42 | + echo "✅ Project validation successful for $example_name" |
| 43 | + fi |
| 44 | + |
| 45 | + popd |
| 46 | +done |
| 47 | + |
| 48 | +echo "" |
| 49 | +echo "==========================================" |
| 50 | +echo "✅ All examples validated successfully!" |
| 51 | +echo "==========================================" |
0 commit comments