proc-maps 0.5.0

Helper crate for getting virtual memory maps from processes
Documentation
name: CI
on:
  pull_request:
    branches: [ main ]
  push:
    branches: [ main ]
  schedule:
  - cron: '0 0 * * 0'
  workflow_dispatch:

jobs:
  format:
    name: Check code formatting
    runs-on: ubuntu-24.04
    steps:
    - name: Checkout repository
      uses: actions/checkout@v7
    - name: Install Rust
      uses: dtolnay/rust-toolchain@984d158d699777abbaa79de23de3134e60c187fa # stable branch
    - name: Run cargo fmt
      run: |
        cargo fmt --all -- --check

  build:
    name: Build and test
    env:
      CARGO: cargo
      TARGET_FLAGS: --target ${{ matrix.target }}
      RUST_BACKTRACE: 1
    timeout-minutes: 30
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        build:
        - linux-x86_64
        - linux-aarch64
        - macos-15-intel
        - macos-15-arm
        - windows
        include:
        - build: linux-x86_64
          os: ubuntu-24.04
          run-tests: 'true'
          target: x86_64-unknown-linux-gnu
        - build: linux-aarch64
          os: ubuntu-24.04-arm
          run-tests: 'true'
          target: aarch64-unknown-linux-gnu
        - build: macos-15-intel
          os: macos-15-intel
          run-tests: 'true'
          target: x86_64-apple-darwin
        - build: macos-15-arm
          os: macos-15
          run-tests: 'true'
          target: aarch64-apple-darwin
        - build: windows
          os: windows-2022
          run-tests: 'true'
          target: x86_64-pc-windows-msvc
    steps:
    - name: Checkout repository
      uses: actions/checkout@v7
    - name: Install Rust
      uses: dtolnay/rust-toolchain@984d158d699777abbaa79de23de3134e60c187fa # stable branch
    - name: Install Rust toolchain target
      run: |
        rustup target add ${{ matrix.target }}
    - name: Cargo Cache
      uses: actions/cache@v6
      with:
        path: |
          ~/.cargo/registry
          ~/.cargo/git
        key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
        restore-keys: |
          ${{ runner.os }}-${{ matrix.target }}-cargo-
    - name: Build
      run: ${{ env.CARGO }} build --release --verbose --workspace --all-targets ${{ env.TARGET_FLAGS }}
    - name: Run tests
      timeout-minutes: 5
      run: ${{ env.CARGO }} test --release --verbose  ${{ env.TARGET_FLAGS }}
      if: runner.os != 'macOS' && matrix.run-tests == 'true'
    - name: Run tests
      timeout-minutes: 5
      run: sudo ${{ env.CARGO }} test --release --verbose  ${{ env.TARGET_FLAGS }} -- --skip tests::test_map_from_invoked_binary_present
      if: runner.os == 'macOS' && matrix.run-tests == 'true'

  build-freebsd:
    name: Build and test (freebsd-x86_64)
    runs-on: ubuntu-24.04
    timeout-minutes: 30
    steps:
      - uses: actions/checkout@v7

      - name: Install Rust
        uses: dtolnay/rust-toolchain@984d158d699777abbaa79de23de3134e60c187fa # stable branch

      - uses: Swatinem/rust-cache@v2.7.8

      - name: Cache cross binary
        id: cache-cross
        uses: actions/cache@v6
        with:
          path: |
            ~/.cargo/bin/cross
          key: ${{ runner.os }}-cross-${{ hashFiles('**/Cargo.toml') }}
          restore-keys: |
            ${{ runner.os }}-cross-

      - name: Install cross
        if: steps.cache-cross.outputs.cache-hit != 'true'
        run: |
          if [ ! -f "$HOME/.cargo/bin/cross" ]; then
            cargo install cross --git https://github.com/cross-rs/cross --rev 51f46f296253d8122c927c5bb933e3c4f27cc317
          fi
          cross --version

      - name: Cargo Cache
        uses: actions/cache@v6
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
          key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}
          restore-keys: |
            ${{ runner.os }}-cargo-

      - name: Cross-compile proc-maps
        run: |
          cross build --no-default-features --release --workspace --all-targets --target x86_64-unknown-freebsd
          cross test --no-default-features --release --no-run --target x86_64-unknown-freebsd

      - name: Launch Firecracker VM
        uses: acj/freebsd-firecracker-action@v0.10.1
        with:
          verbose: false
          pre-run: |
            include_path="$(mktemp)"
            cat <<EOF > "$include_path"
            target
            target/x86_64-unknown-freebsd
            target/x86_64-unknown-freebsd/release
            target/x86_64-unknown-freebsd/release/deps
            target/x86_64-unknown-freebsd/release/deps/*
            EOF

            rsync -r -e "ssh" \
              --relative \
              --copy-links \
              --include-from "$include_path" \
              --exclude "*" \
              . firecracker:
            rm -f "$include_path"
          run-in-vm: |
            failed=0
            for testbin in $(find target/x86_64-unknown-freebsd/release/deps -type f -perm -u+x ! -name "*.d" -print); do
              if ! "$testbin"; then
                failed=1
              fi
            done

            if [ "$failed" -ne 0 ]; then
              exit 1
            fi
          post-run: ""