- name: cni-plugin
  run:
    when: "${FORCE_RUN} or change_in(['/*', '/cni-plugin/', '/libcalico-go/', '/hack/test/certs/'], {exclude: ['/**/.gitignore', '/**/README.md', '/**/LICENSE']})"
  dependencies:
    - Prerequisites
  task:
    prologue:
      commands:
        - cd cni-plugin
    jobs:
      - name: cni-plugin tests
        commands:
          - ../.semaphore/run-and-monitor ci.log make ci
      - name: build windows cni-plugin images
        commands:
          - ../.semaphore/run-and-monitor ci.log make image-windows
- name: "cni-plugin: Windows"
  run:
    when: "${FORCE_RUN} or change_in(['/*', '/cni-plugin/', '/libcalico-go/', '/process/testing/winfv-cni-plugin/'], {exclude: ['/**/.gitignore', '/**/README.md', '/**/LICENSE']})"
  dependencies:
    - cni-plugin
  task:
    secrets:
      - name: azure-dev-ci
    prologue:
      commands:
        # Prepare azure configuration.
        - az login --service-principal -u "${AZ_USER}" -p "${AZ_PASS}" --tenant "${AZ_TENANT}" --output none
        - export AZURE_SUBSCRIPTION_ID=$AZ_SUBSCRIPTION_ID
        - export AZURE_TENANT_ID=$AZ_TENANT
        - export AZURE_CLIENT_ID=$AZ_USER
        - export AZURE_CLIENT_SECRET=$AZ_PASS
        - export REPORT_DIR=/home/semaphore/calico/process/testing/winfv-cni-plugin/report
        - export LOGS_DIR=~/fv.log
        - export SHORT_WORKFLOW_ID=$(echo ${SEMAPHORE_WORKFLOW_ID} | sha256sum | cut -c -8)
        - export CLUSTER_NAME=sem-${SEMAPHORE_PROJECT_NAME}-pr${SEMAPHORE_GIT_PR_NUMBER}-${SHORT_WORKFLOW_ID}
        - export SUFFIX=${CLUSTER_NAME}
        - 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 --expire-in ${SEMAPHORE_ARTIFACT_EXPIRY} || true
          - artifact push job ${LOGS_DIR} --destination semaphore/logs --expire-in ${SEMAPHORE_ARTIFACT_EXPIRY} || true
          - cd ~/calico/process/testing/winfv-cni-plugin/aso && make dist-clean
    env_vars:
      - name: SEMAPHORE_ARTIFACT_EXPIRY
        value: 2w
      - name: AZURE_LOCATION
        value: eastus2
      - name: KUBE_VERSION
        value: v1.29.4
    jobs:
      - name: Containerd - Windows FV
        execution_time_limit:
          minutes: 60
        commands:
          - ../.semaphore/run-and-monitor win-fv-containerd.log ./.semaphore/run-win-fv.sh
