$if: '(event.event != "push") && (event.event != "tag")'
then:
  taskId: ${taskcluster.taskId}
  provisionerId: ${taskcluster.docker.provisionerId}
  workerType: ${taskcluster.docker.workerTypeWin}
  taskGroupId: ${taskcluster.taskGroupId}
  schedulerId: ${taskcluster.schedulerId}
  dependencies:
    $map: { $eval: build.dependencies }
    each(b):
      $eval: as_slugid(b)
  created: { $fromNow: '0 sec' }
  deadline: { $fromNow: '1 day' }
  expires: { $fromNow: '7 days' }

  extra:
    github:
      { $eval: taskcluster.github_events.pull_request }

  routes:
    - "notify.irc-channel.${notifications.irc}.on-exception"
    - "notify.irc-channel.${notifications.irc}.on-failed"

  scopes: [
    "queue:route:notify.irc-channel.*",
  ]

  payload:
    maxRunTime: { $eval: to_int(build.maxRunTime) }
    mounts:
      - file: msys2-base-x86_64.tar.xz
        content:
          sha256: 4e799b5c3efcf9efcb84923656b7bcff16f75a666911abd6620ea8e5e1e9870c
          url: >-
            https://sourceforge.net/projects/msys2/files/Base/x86_64/msys2-base-x86_64-20180531.tar.xz/download

    env:
      $let:
        training: { $eval: as_slugid("test-training_upstream-linux-amd64-py27mu-opt") }
        win_amd64_build: { $eval: as_slugid("win-amd64-cpu-opt") }
        node_package_cpu: { $eval: as_slugid("node-package-cpu") }
      in:
        DEEPSPEECH_ARTIFACTS_ROOT: https://queue.taskcluster.net/v1/task/${win_amd64_build}/artifacts/public
        DEEPSPEECH_NODEJS: https://queue.taskcluster.net/v1/task/${node_package_cpu}/artifacts/public
        DEEPSPEECH_TEST_MODEL: https://queue.taskcluster.net/v1/task/${training}/artifacts/public/output_graph.pb
        DEEPSPEECH_PROD_MODEL: https://github.com/reuben/DeepSpeech/releases/download/v0.2.0-prod-ctcdecode/output_graph.pb
        DEEPSPEECH_PROD_MODEL_MMAP: https://github.com/reuben/DeepSpeech/releases/download/v0.2.0-prod-ctcdecode/output_graph.pbmm
        EXPECTED_TENSORFLOW_VERSION: "${build.tensorflow_git_desc}"
        TC_MSYS_VERSION: 'MSYS_NT-6.3'
        MSYS: 'winsymlinks:nativestrict'

    command:
      - >-
        "C:\Program Files\7-zip\7z.exe" x -txz -so msys2-base-x86_64.tar.xz |
        "C:\Program Files\7-zip\7z.exe" x -o%USERPROFILE% -ttar -aoa -si
      - .\msys64\usr\bin\bash.exe --login -cx "exit"
      - .\msys64\usr\bin\bash.exe --login -cx "pacman --noconfirm -Syu"
      - $let:
          extraSystemSetup: { $eval: strip(str(build.system_setup)) }
        in: >
          .\msys64\usr\bin\bash.exe --login -cxe "export LC_ALL=C &&
          export PATH=\"/c/builds/tc-workdir/msys64/usr/bin:/c/Python36:/c/Program Files/Git/bin:/c/Program Files/7-Zip/:$PATH\" &&
          export TASKCLUSTER_ARTIFACTS=\"$USERPROFILE/public\" &&
          export TASKCLUSTER_TASK_DIR=\"/c/builds/tc-workdir/\" &&
          export TASKCLUSTER_NODE_DIR=\"$(cygpath -w $TASKCLUSTER_TASK_DIR/bin)\" &&
          export TASKCLUSTER_TMP_DIR="$TASKCLUSTER_TASK_DIR/tmp" &&
          export PIP_DEFAULT_TIMEOUT=60 &&
          (mkdir $TASKCLUSTER_TASK_DIR || rm -fr $TASKCLUSTER_TASK_DIR/*) && cd $TASKCLUSTER_TASK_DIR &&
          env &&
          ln -s $USERPROFILE/msys64 $TASKCLUSTER_TASK_DIR/msys64 &&
          git clone --quiet ${event.head.repo.url} $TASKCLUSTER_TASK_DIR/DeepSpeech/ds/ &&
          cd $TASKCLUSTER_TASK_DIR/DeepSpeech/ds && git checkout --quiet ${event.head.sha} &&
          cd $TASKCLUSTER_TASK_DIR &&
          pacman --noconfirm -R bsdtar &&
          pacman --noconfirm -S tar vim &&
          ${extraSystemSetup} &&
          /bin/bash ${build.args.tests_cmdline} ;
          export TASKCLUSTER_TASK_EXIT_CODE=$? &&
          cd $TASKCLUSTER_TASK_DIR/../ && rm -fr tc-workdir/ && exit $TASKCLUSTER_TASK_EXIT_CODE"

  metadata:
    name: ${build.metadata.name}
    description: ${build.metadata.description}
    owner: ${event.head.user.email}
    source: ${event.head.repo.url}
