hprof-analyzer 0.2.0

Fast, low-memory Java HPROF heap-dump analyzer with Eclipse MAT-parity reports (System Overview, Leak Suspects, Top Consumers).
name: CI

on:
  push:
    branches: [main]
  pull_request:

permissions:
  contents: read
  pages: write
  id-token: write

env:
  CARGO_TERM_COLOR: always

jobs:
  # Lint + full test suite (unit + integration + parity). Ubuntu only: the tests
  # are platform-independent and the parity fixtures are the same everywhere.
  build-test:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v7

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@master
        with:
          toolchain: "1.97.1"
          components: rustfmt, clippy

      # build.rs bundles web/ (esbuild) into the git-ignored web/dist/bundle.js
      # that src/html.rs embeds, so node/npm are required to compile the crate.
      - name: Setup Node
        uses: actions/setup-node@v7
        with:
          node-version: 22
          cache: npm
          cache-dependency-path: web/package-lock.json

      - name: Cache cargo
        uses: Swatinem/rust-cache@v2

      - name: Format check
        run: cargo fmt --all -- --check

      - name: Clippy (deny warnings)
        run: cargo clippy --release --all-targets -- -D warnings

      - name: Build
        run: cargo build --release

      - name: Test (unit + integration + parity)
        run: cargo test --release

      - name: Upload binary artifact
        if: github.ref == 'refs/heads/main' && github.event_name == 'push'
        uses: actions/upload-artifact@v4
        with:
          name: hprof-analyzer-linux
          path: target/release/hprof-analyzer
          retention-days: 1

  # Deploy GitHub Pages only on main push, after build-test passes.
  # Re-uses the binary artifact from build-test to avoid a second full Rust build.
  deploy:
    if: github.ref == 'refs/heads/main' && github.event_name == 'push'
    needs: build-test
    runs-on: ubuntu-latest
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    concurrency:
      group: pages
      cancel-in-progress: false
    steps:
      - uses: actions/checkout@v4

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable

      - name: Setup Node
        uses: actions/setup-node@v7
        with:
          node-version: 22
          cache: npm
          cache-dependency-path: web/package-lock.json

      - name: Cache cargo
        uses: Swatinem/rust-cache@v2

      # Download AFTER cache restore — rust-cache restores target/ and would
      # overwrite the artifact if this step came first.
      - name: Download binary artifact
        uses: actions/download-artifact@v4
        with:
          name: hprof-analyzer-linux
          path: target/release

      - name: Make binary executable
        run: chmod +x target/release/hprof-analyzer

      - name: Generate sample reports
        run: BIN=$(pwd)/target/release/hprof-analyzer ./scripts/gen-samples.sh

      - name: Install wasm-pack
        run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

      - name: Build browser REPL
        run: bash scripts/build-browser.sh

      - name: Install browser REPL as homepage
        run: cp dist/hprof-analyzer-browser.html docs/index.html

      - name: Copy sample hprof fixtures
        run: |
          cp tests/fixtures/dump_1_mnemonics.hprof    docs/samples/dump_1_mnemonics.hprof
          cp tests/fixtures/dump_2_scala-doku.hprof   docs/samples/dump_2_scala-doku.hprof
          cp tests/fixtures/dump_4_philosophers.hprof docs/samples/dump_4_philosophers.hprof
          cp tests/fixtures/dump_7_gauss-mix.hprof    docs/samples/dump_7_gauss-mix.hprof

      - name: Build OQL guide
        run: bash scripts/build-oql-guide.sh

      - uses: actions/configure-pages@v5
        with:
          enablement: true
      - uses: actions/upload-pages-artifact@v3
        with:
          path: docs
      - id: deployment
        uses: actions/deploy-pages@v4