dldota 0.1.3

Load shared libraries from statically linked programs by bootstrapping the system's own dynamic loader
Documentation
name: CI

on:
  push:
    branches: [master]
  pull_request:

# A newer push to the same branch (or PR) supersedes this run: cancel the
# older one instead of queueing every intermediate commit.
concurrency:
  group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
  cancel-in-progress: true

permissions:
  contents: read

env:
  CARGO_TERM_COLOR: always

jobs:
  test:
    name: Test & lint (${{ matrix.os }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        # Linux only: dldota boots the system's ELF dynamic loader.
        os: [ubuntu-latest, ubuntu-24.04-arm]
    steps:
      - uses: actions/checkout@v7

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

      - name: Cache
        uses: Swatinem/rust-cache@v2
        with:
          key: ${{ matrix.os }}

      - name: Format
        if: matrix.os == 'ubuntu-latest' # formatting is platform-independent
        run: cargo fmt --all --check

      - name: Clippy (all features, warnings denied)
        run: cargo clippy --all-targets --all-features -- -D warnings

      - name: Test (all features)
        run: cargo test --all-features

  static:
    name: Static library (${{ matrix.target }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - { os: ubuntu-latest, target: x86_64-unknown-linux-musl }
          - { os: ubuntu-24.04-arm, target: aarch64-unknown-linux-musl }
          - { os: ubuntu-latest, target: i686-unknown-linux-musl }
          - { os: ubuntu-latest, target: armv7-unknown-linux-musleabihf }
    steps:
      - uses: actions/checkout@v7

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}

      - name: Cache
        uses: Swatinem/rust-cache@v2
        with:
          key: ${{ matrix.target }}

      - name: Build libdldota.a
        run: cargo build --release --target ${{ matrix.target }}

      - name: Check exported C symbols
        run: |
          nm -g --defined-only target/${{ matrix.target }}/release/libdldota.a 2>/dev/null \
            | grep -E ' T dldota_' | tee /dev/stderr \
            | grep -c ' T dldota_' | grep -qx 11

  cross:
    # The tests built as static musl binaries for each architecture, run
    # against that architecture's glibc (Debian) and musl (Alpine) loaders in
    # containers. Foreign architectures run under qemu-user.
    name: Static host on ${{ matrix.target }} (glibc + musl loaders)
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - { os: ubuntu-24.04-arm, target: aarch64-unknown-linux-musl }
          # 32-bit x86 containers run natively on x86_64.
          - { os: ubuntu-latest, target: i686-unknown-linux-musl }
          # The arm64 runners can't execute 32-bit ARM code: emulate it.
          - { os: ubuntu-latest, target: armv7-unknown-linux-musleabihf, qemu: arm }
    steps:
      - uses: actions/checkout@v7

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}

      - name: Cache
        uses: Swatinem/rust-cache@v2
        with:
          key: cross-${{ matrix.target }}

      - name: Set up qemu-user
        if: matrix.qemu
        uses: docker/setup-qemu-action@v3
        with:
          platforms: ${{ matrix.qemu }}

      - name: Build and run the tests
        run: scripts/cross-tests.sh ${{ matrix.target }}

  fullrust:
    # The tests built as fully static, libc-free binaries with fullrust
    # (https://github.com/KarpelesLab/fullrust), then run against the runner's
    # glibc loader and Alpine's musl loader.
    name: fullrust static host (glibc + musl loaders)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7

      - name: Check the libraries the tests load
        run: dpkg -s zlib1g libzstd1 | grep -E '^(Package|Version):'

      - name: Build with fullrust and run the tests
        run: scripts/fullrust-tests.sh

      # Tests ignored until the loader bootstrap lands. Non-blocking, so their
      # progress is visible here without failing CI; drop once they pass.
      - name: Pending tests (expected to fail for now)
        continue-on-error: true
        env:
          DLDOTA_DEBUG: "1"
        run: scripts/fullrust-tests.sh --include-ignored --test-threads=1

  msrv:
    name: MSRV (1.95)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7

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

      - name: Check
        run: cargo check --all-targets