runlikers 0.1.2

Reverse-engineer docker run command line arguments based on running containers
Documentation
name: CI

"on":
  push:
    branches: ["main"]
    tags-ignore: ["v*"]
    paths-ignore:
      - "README.md"
  pull_request:
    branches: ["main"]
    paths-ignore:
      - "README.md"

env:
  CARGO_TERM_COLOR: always

jobs:
  # ---- Lint & Format ----
  lint:
    name: Lint & fmt
    runs-on: ubuntu-24.04
    steps:
      - name: Checkout
        uses: actions/checkout@v4

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

      - name: Cache cargo
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: lint-cargo-${{ hashFiles('Cargo.lock') }}

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

      - name: Clippy
        run: cargo clippy --all-targets -- -D warnings

  # ---- Build & test ----
  build:
    name: Build (${{ matrix.target }})
    runs-on: ${{ matrix.os }}
    needs: lint
    strategy:
      fail-fast: false
      matrix:
        include:
          # Linux x86_64 (glibc)
          - os: ubuntu-24.04
            target: x86_64-unknown-linux-gnu
            cross: false

          # Linux x86_64 static (musl)
          - os: ubuntu-24.04
            target: x86_64-unknown-linux-musl
            cross: true

          # Linux aarch64 static (musl)
          - os: ubuntu-24.04
            target: aarch64-unknown-linux-musl
            cross: true

          # Linux aarch64 (glibc)
          - os: ubuntu-24.04
            target: aarch64-unknown-linux-gnu
            cross: true

          # Linux armv7 static (musl)
          - os: ubuntu-24.04
            target: armv7-unknown-linux-musleabihf
            cross: true

          # macOS x86_64 (cross-compiled from Apple Silicon)
          - os: macos-14
            target: x86_64-apple-darwin
            cross: false

          # macOS aarch64 (Apple Silicon)
          - os: macos-14
            target: aarch64-apple-darwin
            cross: false

          # Windows x86_64 (MSVC)
          - os: windows-2022
            target: x86_64-pc-windows-msvc
            cross: false

          # Windows x86_64 (MinGW)
          - os: windows-2022
            target: x86_64-pc-windows-gnu
            cross: false

    steps:
      - name: Checkout
        uses: actions/checkout@v4

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

      - name: Install NASM (Windows MSVC)
        if: matrix.target == 'x86_64-pc-windows-msvc'
        uses: ilammy/setup-nasm@v1

      - name: Install cross (for cross-compilation)
        if: matrix.cross
        run: cargo install cross --git https://github.com/cross-rs/cross

      - name: Install musl tools (Linux musl)
        if: matrix.target == 'x86_64-unknown-linux-musl'
        run: |
          sudo apt-get update
          sudo apt-get install -y musl-tools

      - name: Cache cargo
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ matrix.target }}-cargo-${{ hashFiles('Cargo.lock') }}

      - name: Build (native)
        if: ${{ !matrix.cross }}
        run: cargo build --release --target ${{ matrix.target }}

      - name: Build (cross)
        if: matrix.cross
        run: cross build --release --target ${{ matrix.target }}

      - name: Run unit tests (native)
        if: ${{ !matrix.cross }}
        run: cargo test --release --lib

      - name: Run integration tests (Linux)
        if: ${{ !matrix.cross && matrix.os == 'ubuntu-24.04' }}
        run: |
          ./tests/fixtures.sh
          cargo test --test integration --release

  # ---- Docker image ----
  docker:
    name: Docker Image
    runs-on: ubuntu-24.04
    needs: lint
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Set up QEMU
        uses: docker/setup-qemu-action@v3

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3

      # ghcr.io — using docker/build-push-action
      - name: Log in to GitHub Container Registry
        uses: docker/login-action@v3
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: Build and push to ghcr.io
        uses: docker/build-push-action@v6
        with:
          context: .
          push: true
          platforms: linux/amd64,linux/arm64,linux/arm/v7
          tags: ghcr.io/${{ github.repository }}:main
          cache-from: type=gha
          cache-to: type=gha,mode=max

      # Docker Hub — using buildx.sh
      - name: Build dockerfile (without push)
        run: |
          chmod +x ./buildx.sh
          ./buildx.sh --push false --repo ${{ secrets.DOCKER_USERNAME }} --tag main

      - name: Login to DockerHub
        uses: docker/login-action@v3
        with:
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_PASSWORD }}

      - name: Build dockerfile (with push)
        run: |
          chmod +x ./buildx.sh
          ./buildx.sh --push true --repo ${{ secrets.DOCKER_USERNAME }} --tag main