container:
  image: fedora:35
  cpu: 4
  memory: 8Gb
  kvm: true

env:
  CIRRUS_CLONE_DEPTH: 1
  CI_REPOSITORY_URL: "@CI_REPOSITORY_URL@"
  CI_COMMIT_REF_NAME: "@CI_COMMIT_REF_NAME@"
  CI_COMMIT_SHA: "@CI_COMMIT_SHA@"

@NAME@_task:
  @NAME@_vm_cache:
    folder: $HOME/.cache/qemu-vm
  install_script:
    - dnf update -y
    - dnf install -y git make openssh-clients qemu-img qemu-system-x86 wget
  clone_script:
    - git clone --depth 100 "$CI_REPOSITORY_URL" .
    - git fetch origin "$CI_COMMIT_REF_NAME"
    - git reset --hard "$CI_COMMIT_SHA"
  build_script:
    - if [ -f $HOME/.cache/qemu-vm/images/@NAME@.img ]; then
        make vm-build-@NAME@ J=$(getconf _NPROCESSORS_ONLN)
          EXTRA_CONFIGURE_OPTS="@CONFIGURE_ARGS@"
          BUILD_TARGET="@TEST_TARGETS@" ;
      else
        make vm-build-@NAME@ J=$(getconf _NPROCESSORS_ONLN) BUILD_TARGET=help
          EXTRA_CONFIGURE_OPTS="--disable-system --disable-user --disable-tools" ;
      fi