ciruela 0.6.11

A peer-to-peer synchronization software for servers in datacenters.
Documentation
commands:

  make: !Command
    description: Build the library and executables
    container: xenial
    run: [cargo, build]

  cargo: !Command
    description: Run arbitrary cargo command
    container: xenial
    symlink-name: cargo
    run: [cargo]

  test: !Command
    description: Run tests
    container: xenial
    run: [cargo, test]

  server: !Command
    description: Run the server
    container: xenial
    run: [cargo, run, --bin, ciruela-server, "--"]

  client: !Command
    description: Run the client
    container: xenial
    run: [cargo, run, --bin, ciruela, "--"]

  _example-server-dirs: !Command
    description: Create dirs for example server
    container: xenial
    run: |
      mkdir -p ./tmp/db
      mkdir -p ./tmp/dest/dir1

  example-server: !Command
    description: Run the server
    container: xenial
    prerequisites: [make, _example-server-dirs]
    environ: &exenv
      RUST_LOG: "info,tokio_core=warn,\
        tokio_reactor=warn,\
        ciruela_server::proto=info,\
        ciruela_server::peers::gossip=warn,\
        ciruela_server::named_mutex=info,\
        ciruela_server::tracking=trace,\
        ciruela_server::metadata::upload=debug,\
        tk_http::websocket::dispatcher=info"
    run:
    - ./target/debug/ciruela-server
    - --config-base-dir=./example-configs
    - --db-dir=./tmp/db
    - --override-machine-id=77985419c732412ea38b94db00000001

  example-upload: !Command
    description: Run the upload command with example key
    container: xenial
    prerequisites: [make]
    environ: *exenv
    run:
    - ./target/debug/ciruela
    - upload
    - --identity=ciruela-example.key

  example-sync: !Command
    description: Run the sync command with example key
    container: xenial
    prerequisites: [make]
    environ: *exenv
    run:
    - ./target/debug/ciruela
    - sync
    - --identity=ciruela-example.key

  example-edit: !Command
    description: Run the edit command with example key
    container: xenial
    prerequisites: [make]
    environ: *exenv
    run:
    - ./target/debug/ciruela
    - edit
    - --identity=ciruela-example.key

  example-put-file: !Command
    description: Run the put-file command with example key
    container: xenial
    prerequisites: [make]
    environ: *exenv
    run:
    - ./target/debug/ciruela
    - put-file
    - --identity=ciruela-example.key

  trio-sync: !Command
    description: Run the sync command with example key to
      an example cluster run with `vagga trio`
    container: xenial
    prerequisites: [make]
    environ: *exenv
    run:
    - ./target/debug/ciruela
    - --port=20001
    - sync
    - --identity=ciruela-example.key
    - gw.mglawica.org

  example-upload-with-env-key: !Command
    description: Run the upload command with example key
    container: xenial
    prerequisites: [make]
    accepts-arguments: true
    environ: *exenv
    run: |
      export CIRUELA_KEY="$(cat ciruela-example.key)"
      exec ./target/debug/ciruela upload "$@"

  doc: !Command
    description: Build documentation
    container: doc
    run: [make, html]
    work-dir: doc
    epilog: |
      --------------------------------------------------------
        xdg-open doc/_build/html/index.html

  _bulk: !Command
    description: Run any bulk command
    container: xenial
    run: [bulk]

  _package-trusty: !Command
    container: trusty
    run: &package |
      set -e
      version=$(git describe --dirty)
      codename=$(lsb_release --codename --short)
      rm -rf pkg
      rm -rf target/release/ciruela*
      bulk with-version "${version}" cargo install --root=/work/pkg/usr --path=.
      rm pkg/usr/.crates.toml
      bulk pack --package-version="${version}+${codename}1"

  _package-xenial: !Command
    container: xenial
    run: *package

  _package-bionic: !Command
    container: bionic
    run: *package

  packages: !Command
    container: xenial
    description: Build packages and repostories (mostly for CI)
    prerequisites: [_package-trusty, _package-xenial, _package-bionic]
    accepts_arguments: true
    run: |
      bulk repo-add --config bulk.yaml --repository-base dist/repos \
        dist/ciruela-[0-9]*.deb "$@"

  _trio-dirs: !Command
    description: Create dirs for example server
    container: xenial
    run: |
      mkdir -p ./tmp/db1
      mkdir -p ./tmp/dest1/dir1 ./tmp/dest1/dir2
      mkdir -p ./tmp/db2
      mkdir -p ./tmp/dest2/dir1 ./tmp/dest2/dir2
      mkdir -p ./tmp/db3
      mkdir -p ./tmp/dest3/dir1 ./tmp/dest3/dir2

  trio: !Supervise
    description: Runs three ciruela servers to simulate cluster
    prerequisites: [make, _trio-dirs]
    children:
      n1: !Command
        container: xenial
        environ: *exenv
        work-dir: tmp/dest1
        network:
          ip: 172.23.0.1
          ports: {20001: 24783}
        run:
        - "/work/target/debug/ciruela-server"
        - --config-base-dir=/work/example-configs3
        - --db-dir=/work/tmp/db1
        - --override-machine-id=77985419c732412ea38b94db00000001
        - --override-hostname=n1
        - --log-machine-id
        - --aggressive-index-gc
      n2: !Command
        container: xenial
        environ: *exenv
        work-dir: tmp/dest2
        network:
          ip: 172.23.0.2
          ports: {20002: 24783}
        run:
        - "/work/target/debug/ciruela-server"
        - --config-base-dir=/work/example-configs3
        - --db-dir=/work/tmp/db2
        - --override-machine-id=77985419c732412ea38b94db00000002
        - --override-hostname=n2
        - --log-machine-id
      n3: !Command
        container: xenial
        environ: *exenv
        work-dir: tmp/dest3
        network:
          ip: 172.23.0.3
          ports: {20003: 24783}
        run:
        - "/work/target/debug/ciruela-server"
        - --config-base-dir=/work/example-configs3
        - --db-dir=/work/tmp/db3
        - --override-machine-id=77985419c732412ea38b94db00000003
        - --override-hostname=n3
        - --log-machine-id

containers:

  xenial:
    setup:
    - !Ubuntu xenial
    - &pkgs !Install
      - ca-certificates
      - git
      - build-essential
      - git  # to build package
      - lsb-release  # to build package
      - vim  # to edit release notes
    - &rust !TarInstall
      url: "https://static.rust-lang.org/dist/rust-1.26.0-x86_64-unknown-linux-gnu.tar.gz"
      script: "./install.sh --prefix=/usr \
                --components=rustc,rust-std-x86_64-unknown-linux-gnu,cargo"
    - &bulk !Tar
      url: "https://github.com/tailhook/bulk/releases/download/v0.4.11/bulk-v0.4.11.tar.gz"
      sha256: b718bb8448e726690c94d98d004bf7575f7a429106ec26ad3faf11e0fd9a7978
      path: /
    - !EnsureDir /cargo

    environ: &environ
      CARGO_HOME: /cargo
      RUST_BACKTRACE: 1
    volumes: &volumes
      /cargo: !Persistent cargo

  trusty:
    setup:
    - !Ubuntu trusty
    - *pkgs
    - *rust
    - *bulk
    - !EnsureDir /cargo
    environ: *environ
    volumes: *volumes

  bionic:
    setup:
    - !Ubuntu bionic
    - *pkgs
    - *rust
    - *bulk
    - !EnsureDir /cargo
    environ: *environ
    volumes: *volumes

  doc:
    setup:
    - !Alpine v3.7
    - !Install [alpine-base, py-sphinx, py-requests, make]