- name: "OpenStack integration (Yoga)"
  run:
    when: "${FORCE_RUN} or change_in(['/networking-calico/'])"
  dependencies:
    - Prerequisites
  task:
    agent:
      machine:
        type: f1-standard-2
        os_image: ubuntu2004
    prologue:
      commands:
        - cd networking-calico
    jobs:
      - name: "Unit and FV tests (tox) on Yoga"
        commands:
          - ../.semaphore/run-and-monitor tox.log make tox-yoga
      - name: "Mainline ST (DevStack + Tempest) on Yoga"
        commands:
          # For some reason python3-wrapt is pre-installed on a Semaphore ubuntu2004 node, but with
          # a version (1.11.2) that is different from the version that OpenStack needs (1.13.3), and
          # this was causing the DevStack setup to fail, because pip doesn't know how to uninstall
          # or replace the existing version.  Happily we do know that, so let's do it upfront here.
          - sudo apt-get remove -y python3-wrapt || true
          # Install all the packages that would trigger an initramfs update using a workaround
          # for limited /boot partition space in the ubuntu2004 image
          - sudo apt update
          - sudo rsync -av /boot/ /boot2/
          - sudo mount --bind /boot2 /boot
          - sudo apt install -y cryptsetup lsscsi open-iscsi thin-provisioning-tools
          - sudo umount /boot
          - sudo rsync -av /boot2/ /boot/ --exclude "*.new" --exclude "*.dpkg-bak" --delete --inplace
          - sudo rm -rf /boot2/
          - git checkout -b devstack-test
          - export LIBVIRT_TYPE=qemu
          - export UPPER_CONSTRAINTS_FILE=https://releases.openstack.org/constraints/upper/yoga
          - export NC_PLUGIN_REPO=$(dirname $(pwd))
          - export NC_PLUGIN_REF=$(git rev-parse --abbrev-ref HEAD)
          - sudo git config --system --add safe.directory ${NC_PLUGIN_REPO}/.git
          - TEMPEST=true DEVSTACK_BRANCH=unmaintained/yoga ./devstack/bootstrap.sh
    epilogue:
      on_fail:
        commands:
          - mkdir logs
          - sudo journalctl > logs/journalctl.txt
          - artifact push job --expire-in 1d logs
