domain_name: obs-server
default_job: appliance

jobs:
 appliance:
  -
    use_module: Kanku::Handler::SetJobContext
    options:
      login_user: root
      login_pass: opensuse
  -
    use_module: Kanku::Handler::OBSCheck
    options:
      project: OBS:Server:Unstable
      #project: home:M0ses:branches:OBS:Server:Unstable
      package: OBS-Appliance:qcow2
      repository: images
  -
    use_module: Kanku::Handler::ImageDownload
  -
    use_module: Kanku::Handler::CreateDomain
    options:
      memory: 8G
      vcpu: 4
      use_9p: 1
      template: with-spice
  -
    use_module: Kanku::Handler::PrepareSSH
  -
    use_module: Kanku::Handler::WaitForSystemd
  -
    use_module: Kanku::Handler::Reboot
    options:
      wait_for_console: 1
      login_timeout: 900
  -
    use_module: Kanku::Handler::ExecuteCommandViaSSH
    options:
      username: root
      commands:
        - zypper -n --gpg-auto-import-keys ref -s
        - zypper -n install perl-Test-Most
        - cp -av /tmp/kanku/ .
        - make -C /root/kanku/dist test_system
        - PERL5LIB=/usr/lib/build/ make -C /root/kanku/src/backend test_unit
        - make -C /root/kanku/dist/t/osc test_system
 tumbleweed:
  -
    use_module: Kanku::Handler::SetJobContext
    options:
      login_user: root
      login_pass: kankudai
  -
    use_module: Kanku::Handler::OBSCheck
    options:
      api_url: https://api.opensuse.org/public/
      project: devel:kanku:images
      package: openSUSE-Tumbleweed-JeOS
      repository: images_tumbleweed
  -
    use_module: Kanku::Handler::ImageDownload
  -
    use_module: Kanku::Handler::CreateDomain
    options:
      memory: 6G
      vcpu: 2
      use_9p: 1
      management_interface: eth0
  -
    use_module: Kanku::Handler::PrepareSSH
  -
    use_module: Kanku::Handler::WaitForSystemd
  -
    use_module: Kanku::Handler::ExecuteCommandViaSSH
    options:
      commands:
        - zypper ar https://download.opensuse.org/repositories/OBS:/Server:/Unstable/openSUSE_Factory/OBS:Server:Unstable.repo
        # FIXME: remove home:M0ses:OBS:Server:Unstable
        #- zypper ar https://download.opensuse.org/repositories/home:/M0ses:/branches:/OBS:/Server:/Unstable/openSUSE_Factory/ hMbOSU
        - zypper -n --gpg-auto-import-keys ref -s
        - zypper -n install obs-server obs-api obs-worker obs-signd obs-service-tar_scm obs-service-obs_scm obs-service-set_version obs-service-tar gitea
        - perl -p -i -e 's/^OBS_API_AUTOSETUP=.*/OBS_API_AUTOSETUP="yes"/' /etc/sysconfig/obs-server || exit 1
        - perl -p -i -e 's/^OBS_STORAGE_AUTOSETUP=.*/OBS_STORAGE_AUTOSETUP="yes"/' /etc/sysconfig/obs-server || exit 1
        - perl -p -i -e 's/OBS_USE_SLP="yes"/OBS_USE_SLP="no"/' /etc/sysconfig/obs-server
        - perl -p -i -e "s/^\s*OBS_WORKER_INSTANCES=.*/OBS_WORKER_INSTANCES=1/" /etc/sysconfig/obs-server
        - systemctl start obsstoragesetup || exit 1
        - systemctl start obsrepserver
        - /usr/lib/obs/server/setup-appliance.sh --non-interactive > /tmp/setup-appliance.log 2>&1
        - for i in worker dispatcher deltastore repserver service servicedispatch srcserver signer signd;do systemctl restart obs$i ;done
        - zypper -n in perl-Devel-Cover osc perl-Test-Most
        - echo -en "[client]\nuser = root\npassword = opensuse\n" > /root/.my.cnf
  -
    use_module: Kanku::Handler::Reboot
  -
    use_module: Kanku::Handler::WaitForSystemd
  -
    use_module: Kanku::Handler::ExecuteCommandViaSSH
    options:
      username: root
      commands:
        - cp -av /tmp/kanku/ .
        - make -C /root/kanku/dist test_system
        - PERL5LIB=/usr/lib/build/ make -C /root/kanku/src/backend test_unit
        - make -C /root/kanku/dist/t/osc test_system
 current:
  -
    use_module: Kanku::Handler::SetJobContext
    options:
      login_user: root
      login_pass: kankudai
  -
    use_module: Kanku::Handler::OBSCheck
    options:
      api_url: https://api.opensuse.org/public/
      project: devel:kanku:images
      package: openSUSE-Leap-16.0-JeOS
      repository: images_leap_16_0
      arch: x86_64
  -
    use_module: Kanku::Handler::ImageDownload
  -
    use_module: Kanku::Handler::CreateDomain
    options:
      memory: 6G
      vcpu: 2
      use_9p: 1
      management_interface: eth0
  -
    use_module: Kanku::Handler::PrepareSSH
  -
    use_module: Kanku::Handler::WaitForSystemd
  -
    use_module: Kanku::Handler::ExecuteCommandViaSSH
    options:
      commands:
        - zypper ar https://download.opensuse.org/repositories/OBS:/Server:/Unstable/16.0/OBS:Server:Unstable.repo
        # FIXME: remove home:M0ses:OBS:Server:Unstable
        #- zypper ar https://download.opensuse.org/repositories/home:/M0ses:/branches:/OBS:/Server:/Unstable/16.0/ hMbOSU
        - zypper -n --gpg-auto-import-keys ref -s
        - zypper -n install obs-server obs-api obs-worker obs-signd obs-service-tar_scm obs-service-obs_scm obs-service-set_version obs-service-tar
        - perl -p -i -e 's/^OBS_API_AUTOSETUP=.*/OBS_API_AUTOSETUP="yes"/' /etc/sysconfig/obs-server || exit 1
        - perl -p -i -e 's/^OBS_STORAGE_AUTOSETUP=.*/OBS_STORAGE_AUTOSETUP="yes"/' /etc/sysconfig/obs-server || exit 1
        - perl -p -i -e 's/OBS_USE_SLP="yes"/OBS_USE_SLP="no"/' /etc/sysconfig/obs-server
        - perl -p -i -e "s/^\s*OBS_WORKER_INSTANCES=.*/OBS_WORKER_INSTANCES=1/" /etc/sysconfig/obs-server
        - systemctl start obsstoragesetup || exit 1
        - systemctl start obsrepserver
        - /usr/lib/obs/server/setup-appliance.sh --non-interactive > /tmp/setup-appliance.log 2>&1
        - for i in worker dispatcher deltastore repserver service servicedispatch srcserver signer signd;do systemctl restart obs$i ;done
        - zypper -n in perl-Devel-Cover osc perl-Test-Most
        - echo -en "[client]\nuser = root\npassword = opensuse\n" > /root/.my.cnf
  -
    use_module: Kanku::Handler::Reboot
  -
    use_module: Kanku::Handler::WaitForSystemd
  -
    use_module: Kanku::Handler::ExecuteCommandViaSSH
    options:
      username: root
      commands:
        - cp -av /tmp/kanku/ .
        - make -C /root/kanku/dist test_system
        - PERL5LIB=/usr/lib/build/ make -C /root/kanku/src/backend test_unit
        - make -C /root/kanku/dist/t/osc test_system
