device_type: "avh"

{% if tests %}
job_name: "tuxrun@{{ device.name }}: {{ tests|map(attribute="name")|join(", ")}}"
{% else %}
job_name: "tuxrun@{{ device.name }}: boot"
{% endif %}
priority: "medium"
visibility: "public"

{%- set deploy_timeout = timeouts.deploy|default(15) %}
{%- set boot_timeout = timeouts.boot|default(15) %}

{% block timeouts %}
timeouts:
  job:
    minutes: {{ deploy_timeout + boot_timeout + tests_timeout }}
  action:
    minutes: 10
  connection:
    minutes: 10
{% endblock %}

secrets:
  avh_api_token: {{ secrets.get("avh_api_token") }}

actions:
- deploy:
    to: avh
    options:
      api_endpoint: {{ api_endpoint }}
      project: {{ project_name }}
      model: {{ model }}
    timeout:
      minutes: {{ deploy_timeout }}
    images:
      kernel:
        url: "{{ kernel }}"
{% if compression(kernel)[1] is not none %}
        compression: {{ compression(kernel)[1] }}
{% endif %}
{% if dtb %}
      dtb:
        url: "{{ dtb }}"
{% endif %}
      rootfs:
        url: "{{ rootfs }}"
{% if compression(rootfs)[1] is not none %}
        compression: {{ compression(rootfs)[1] }}
{% endif %}
        format: ext4
        root_partition: {{ rootfs_partition }}
        partition: {{ rootfs_partition }}
{% if overlays %}
        overlays:
{% for name, overlay, dst in overlays %}
          {{ name }}:
            url: "{{ overlay }}"
            path: "{{ dst }}"
            format: tar
            compression: {{ compression(overlay)[1] }}
{% endfor %}
{% elif tests %}
        overlays:
          lava: true
{% endif %}
- boot:
    method: avh
{% if boot_args %}
    bootargs:
      normal: {{ boot_args }}
{% endif %}
    docker:
      image: "ghcr.io/vi/websocat:1.12.0"
      local: true
    timeout:
      minutes: {{ boot_timeout }}
    auto_login:
      login_prompt: 'login:'
      username: root
    prompts:
    - 'root@(.*):[/~]#'
{% for prompt in tux_prompt %}
    - "{{ prompt }}"{% endfor %}
