pkq 0.2.7

Unified package query CLI for DEB/RPM Linux distros (dpkg/apt, rpm/dnf)
Documentation
name: CI

on:
  push:
    branches: [master, main]
  pull_request:

env:
  CARGO_TERM_COLOR: always

jobs:
  ci:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7

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

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

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

      - name: Tests
        run: cargo test --all-targets

      - name: Build release
        run: cargo build --release

      - name: Smoke test
        run: ./target/release/pkq --version

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

      - name: Install Rust 1.89
        uses: dtolnay/rust-toolchain@1.89.0

      - name: Check (MSRV)
        run: cargo check --all-targets

  audit:
    name: Security audit
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7

      - name: Install cargo-audit
        uses: taiki-e/install-action@cargo-audit

      - name: Run cargo audit
        run: cargo audit

  e2e-deb:
    name: E2E matrix (DEB)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7

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

      - name: Build release
        run: cargo build --release

      # 环境诊断 + 元数据预热:cache update 的逐源输出(quiet=false)会把
      # 每个源的在线/回退/失败原因打到日志,仓库查询类用例失败时据此定位;
      # 预热的元数据被后续测试矩阵复用,不增加净耗时
      - name: Environment diagnostics & metadata warmup
        run: |
          echo "== apt sources.list =="
          cat /etc/apt/sources.list 2>/dev/null || echo "(not found)"
          for f in /etc/apt/sources.list.d/*; do echo "--- $f"; cat "$f" 2>/dev/null; done
          echo "== apt lists (head) =="
          ls /var/lib/apt/lists/ 2>/dev/null | head -10
          echo "== dpkg arch =="
          cat /var/lib/dpkg/arch 2>/dev/null || echo "(none)"
          echo "== apt mirror file =="
          cat /etc/apt/apt-mirrors.txt 2>/dev/null || echo "(not found)"
          echo "== pkq cache update (verbose) =="
          RUST_LOG=pkq=debug ./target/release/pkq cache update || true

      - name: Run DEB full test matrix
        run: tests/test_deb_all_cases.sh

  e2e-rpm:
    name: E2E matrix (RPM)
    runs-on: ubuntu-latest
    container:
      image: fedora:latest
    steps:
      - uses: actions/checkout@v7

      - name: Install Rust
        run: dnf install -y rust cargo

      - name: Build release
        run: cargo build --release

      - name: Environment diagnostics & metadata warmup
        run: |
          echo "== rpmdb =="
          rpm --eval '%_dbpath' || true
          ls -la /var/lib/rpm/ 2>/dev/null | head -8 || echo "(no /var/lib/rpm)"
          ls -la /usr/lib/sysimage/rpm/ 2>/dev/null | head -8 || echo "(no /usr/lib/sysimage/rpm)"
          echo "== rpmdb schema dump =="
          command -v python3 >/dev/null || dnf install -y python3
          python3 - <<'EOF' || true
          import sqlite3
          c = sqlite3.connect("file:/usr/lib/sysimage/rpm/rpmdb.sqlite?mode=ro", uri=True)
          tables = [t[0] for t in c.execute("select name from sqlite_master where type='table'")]
          print("tables:", tables)
          if "Packages" in tables:
              cur = c.execute("select * from Packages limit 1")
              print("Packages cols:", [d[0] for d in cur.description])
              row = cur.fetchone()
              if row:
                  blob = next((v for v in row if isinstance(v, bytes)), None)
                  print("row types:", [type(v).__name__ for v in row],
                        "blob head:", blob[:16].hex() if blob else None)
          EOF
          echo "== pkq local load (verbose) =="
          RUST_LOG=pkq=debug ./target/release/pkq info bash 2>&1 | head -5 || true
          echo "== pkq cache update (verbose) =="
          RUST_LOG=pkq=debug ./target/release/pkq cache update || true

      - name: Run RPM full test matrix
        run: tests/test_rpm_all_cases.sh