---
- name: Run unit tests on OpenXLA
  hosts: localhost
  vars_files:
    ../vars/vars.yml

  tasks:
    - name: Cleanup after previous build
      ansible.builtin.file:
        path: "{{ build_dir }}/{{ item }}"
        state: absent
      loop:
        - xla

    - name: Create cache dirs
      ansible.builtin.file:
        path: "{{ build_dir }}/{{ item }}"
        state: directory
        mode: 0777
      loop:
        - bazel-cache

    - name: Go through each OpenXLA version
      ansible.builtin.include_role:
        name: xla
        tasks_from: loop.yml
      loop: "{{ versions | dict2items }}"
      loop_control:
        loop_var: xla_ver
      when: xla_ver.key in to_be_built
