whamm 0.1.0

A framework for 'Wasm Application Monitoring and Manipulation'
Documentation
name: CI

on:
  push:
    branches: [ "master" ]
  pull_request:
    branches: [ "master" ]

env:
  CARGO_TERM_COLOR: always

jobs:
  lint:
    name: Format + Clippy
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4

      - uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt, clippy

      # Caching to increase performance as dependency tree grows
      - uses: Swatinem/rust-cache@v2

      - name: Build Whamm Core Library
        run: |
          pushd whamm_core
          rustup target add wasm32-wasip1
          cargo build --release --target wasm32-wasip1
          popd

      - name: Check formatting
        run: cargo fmt --all -- --check

      - name: Run clippy
        run: |
          rustup target add wasm32-wasip1
          cargo clippy --all-features --all-targets -- -D warnings

  # Run CLI across OS targets
  build_and_test:
    name: Build + Test (${{ matrix.os }})
    runs-on: ${{ matrix.os }}

    strategy:
      matrix:
        os: [ubuntu-latest]

    steps:
      - uses: actions/checkout@v4

      - uses: dtolnay/rust-toolchain@stable

      # Caching per OS
      - uses: Swatinem/rust-cache@v2

      - uses: plinioh/setup-binary-action@v1.0.0
        with:
          binaryName: wasm2wat
          binaryUrl: https://github.com/WebAssembly/wabt/releases/download/1.0.34/wabt-1.0.34-ubuntu.tar.gz
          binaryPathInArchive: wabt-1.0.34/bin/wasm2wat

      - name: Setup `wasmtime`
        uses: bytecodealliance/actions/wasmtime/setup@v1

      - name: Check `wasmtime`
        run: "wasmtime --version"

      - name: Setup wasm-tools and WASI P1 Target
        run: |
          echo "[INFO] Installing the 'wasm32-wasip1' compilation target..."
          rustup target add wasm32-wasip1
          
          echo "[INFO] Installing the 'wasm-tools' package..."
          cargo install --locked wasm-tools
          
          echo "[INFO] Testing the 'wasm-tools' configuration..."
          wasm-tools --version

      - name: Setup OCaml
        uses: ocaml/setup-ocaml@v3
        with:
          ocaml-compiler: 5
      #          echo "[INFO] Installing OCaml..."
      #          apt-get update -y
      #          apt-get install -y opam

      - name: Setup progress
        run: |
          echo "[INFO] Installing 'progress'..."
          git clone https://github.com/titzer/progress.git
          echo "$GITHUB_WORKSPACE/progress/bin" >> $GITHUB_PATH
      - name: Setup Virgil
        run: |
          echo "[INFO] Testing 'progress' is on PATH..."
          which progress.x86-64-linux
  
          echo "[INFO] Building 'virgil'..."
          git clone https://github.com/titzer/virgil.git
          pushd virgil && make && popd
          echo "$GITHUB_WORKSPACE/virgil/bin" >> $GITHUB_PATH
      - name: Setup Wizard-Engine
        run: |
          echo "[INFO] Testing 'virgil' is on PATH..."
          which v3c
  
          echo "[INFO] Building 'wizeng'..."
          git clone https://github.com/titzer/wizard-engine.git
          pushd wizard-engine
          make -j
          popd
  
          echo "[INFO] Configuring the 'wizeng' spectest interpreter..."
          mkdir -p output/tests/engines
          mv wizard-engine/bin/unittest.x86-linux output/tests/engines/wizard-spectest
  
          echo "[INFO] Testing the 'wizeng' spectest interpreter configuration..."
          ls -al output/tests/engines
          ./output/tests/engines/wizard-spectest --help || [ $? == 1 ]
  
          echo "[INFO] Configuring the 'wizeng' binary..."
          ln -s ${PWD}/wizard-engine/scripts/wizeng output/tests/engines/wizeng
  
          echo "[INFO] Testing the 'wizeng' binary configuration..."
          ./output/tests/engines/wizeng --help
      - name: Setup Wasm Spec Reference Interpreter
        run: |
          echo "[INFO] Configuring OCaml..."
          opam init -y
          eval $(opam env)
          opam install -y dune
          opam install -y menhir
  
          echo "[INFO] Building the wasm ref interpreter..."
          git clone https://github.com/WebAssembly/multi-memory.git
          pushd multi-memory/interpreter
          make
          popd
  
          echo "[INFO] Configuring the wasm ref interpreter..."
          mv multi-memory/interpreter/wasm output/tests/engines
  
          echo "[INFO] Testing the wasm ref interpreter configuration..."
          ./output/tests/engines/wasm --help

      - name: Build main crate
        run: cargo build --locked --verbose

      - name: Run tests
        run: cargo test --locked --all-features --verbose