when:
  event:
  - push
  - tag
  - pull_request
  - deployment
  - cron
  - manual

steps:
  - name: check formatting
    image: nixpkgs/nix:nixos-22.05
    commands:
      - nix-shell --attr devShell --run "cargo fmt -- --check"

  - name: build
    image: nixpkgs/nix:nixos-22.05
    commands:
      - nix-build -j4 --attr flakePackages.dev

  - name: unit + func tests (lmdb)
    image: nixpkgs/nix:nixos-22.05
    commands:
      - nix-build -j4 --attr flakePackages.tests-lmdb

  - name: unit + func tests (sqlite)
    image: nixpkgs/nix:nixos-22.05
    commands:
      - nix-build -j4 --attr flakePackages.tests-sqlite

  - name: integration tests
    image: nixpkgs/nix:nixos-22.05
    commands:
      - nix-build -j4 --attr flakePackages.dev
      - nix-shell --attr ci --run ./script/test-smoke.sh || (cat /tmp/garage.log; false)
    depends_on: [ build ]
