freebsd_instance:
  image_family: freebsd-14-1

build_task:
  # Don't change this name without adjusting .github/workflows/build.yaml
  name: Build FreeBSD (Stack)
  install_script: pkg install -y postgresql16-client hs-stack git

  only_if: |
    $CIRRUS_TAG != '' || $CIRRUS_BRANCH == 'main' || $CIRRUS_BRANCH =~ 'v*' ||
    changesInclude(
      '.github/workflows/build.yaml',
      '.github/actions/artifact-from-cirrus/**',
      '.cirrus.yml',
      'postgrest.cabal',
      'stack.yaml*',
      '**.hs'
    )

  stack_cache:
    folders: /.stack
    fingerprint_script:
      - echo $CIRRUS_OS
      - stack --version
      - md5sum postgrest.cabal
      - md5sum stack.yaml.lock

  stack_work_cache:
    folders: .stack-work
    fingerprint_script:
      - echo $CIRRUS_OS
      - stack --version
      - md5sum postgrest.cabal
      - md5sum stack.yaml.lock
      - find main src -type f -iname '*.hs' -exec md5sum "{}" +

  build_script: |
    stack build -j 1 --local-bin-path . --copy-bins --stack-yaml stack-21.7.yaml
    strip postgrest

  bin_artifacts:
    path: postgrest
