- name: CNI Plugin
  run:
    when: "${CHANGE_IN(cni-plugin)}"
  dependencies:
    - Prerequisites
  task:
    env_vars:
      - name: BUILD_CACHE_GROUP
        value: "cni-plugin"
    prologue:
      commands:
        - cd cni-plugin
    jobs:
      - name: "CNI Plugin: CI"
        commands:
          - ../.semaphore/run-and-monitor ci.log make ci
        env_vars:
          - name: STORE_BUILD_CACHE
            value: "true"
      - name: "CNI Plugin: build windows images"
        commands:
          - ../.semaphore/run-and-monitor ci.log make image-windows
- name: "CNI Plugin: Windows"
  run:
    when: "false or ${CHANGE_IN(cni-plugin,non-go:/process/testing/aso,non-go:/process/testing/utils,non-go:/process/testing/winfv-cni-plugin)}"
  dependencies:
    - Prerequisites
  task:
    secrets:
      - name: banzai-secrets
    prologue:
      commands:
        # Prepare azure configuration.
        - az login --service-principal -u "${AZ_SP_ID}" -p "${AZ_SP_PASSWORD}" --tenant "${AZ_TENANT_ID}" --output none
        - export AZURE_SUBSCRIPTION_ID=$AZ_SUBSCRIPTION_ID
        - export AZURE_TENANT_ID=$AZ_TENANT_ID
        - export AZURE_CLIENT_ID=$AZ_SP_ID
        - export AZURE_CLIENT_SECRET=$AZ_SP_PASSWORD
        - export REPORT_DIR=/home/semaphore/calico/process/testing/winfv-cni-plugin/report
        - export LOGS_DIR=~/fv.log
        - export RG_PREFIX=${USER}-win-cni-${SEMAPHORE_GIT_SHA:0:4}-pr${SEMAPHORE_GIT_PR_NUMBER}
        - cd cni-plugin
        - ../.semaphore/run-and-monitor build.log make bin/windows/calico.exe bin/windows/calico-ipam.exe bin/windows/win-fv.exe
    epilogue:
      always:
        commands:
          - artifact push job ${REPORT_DIR} --destination semaphore/test-results || true
          - artifact push job ${LOGS_DIR} --destination semaphore/logs || true
          - cd ~/calico/process/testing/aso && make dist-clean
    env_vars:
      - name: BUILD_CACHE_GROUP
        value: "cni-plugin"
      - name: SEMAPHORE_ARTIFACT_EXPIRY
        value: 2w
      - name: AZURE_LOCATION
        value: eastus2
      - name: KUBE_VERSION
        value: v1.33.7
    jobs:
      - name: "CNI Plugin: Windows Containerd FV - overlay"
        execution_time_limit:
          minutes: 60
        commands:
          - export BACKEND=overlay
          - export AZURE_RESOURCE_GROUP=${RG_PREFIX}-${BACKEND}-rg
          - echo AZURE_RESOURCE_GROUP=${AZURE_RESOURCE_GROUP}
          - ../.semaphore/run-and-monitor win-fv-containerd.log ~/calico/process/testing/winfv-cni-plugin/run-win-fv.sh
      - name: "CNI Plugin: Windows Containerd FV - l2bridge"
        execution_time_limit:
          minutes: 60
        commands:
          - export BACKEND=l2bridge
          - export AZURE_RESOURCE_GROUP=${RG_PREFIX}-${BACKEND}-rg
          - echo AZURE_RESOURCE_GROUP=${AZURE_RESOURCE_GROUP}
          - ../.semaphore/run-and-monitor win-fv-containerd.log ~/calico/process/testing/winfv-cni-plugin/run-win-fv.sh
