Repository: tensorflow/addons

Issue:
Add nightly tests for windows/macos
Currently we only test our nightlies on linux:
https://github.com/tensorflow/addons/blob/master/.travis.yml#L17

It should be relatively simple to enable tests for macos/windows, with the one caveat that `tf-nightly` is not published for windows. 


Discussion:

Resolving patch:
diff --git a/tensorflow_addons/losses/__init__.py b/tensorflow_addons/losses/__init__.py
--- a/tensorflow_addons/losses/__init__.py
+++ b/tensorflow_addons/losses/__init__.py
@@ -22,6 +22,11 @@
 from tensorflow_addons.losses.focal_loss import sigmoid_focal_crossentropy, SigmoidFocalCrossEntropy
 from tensorflow_addons.losses.giou_loss import giou_loss, GIoULoss
 from tensorflow_addons.losses.lifted import lifted_struct_loss, LiftedStructLoss
-from tensorflow_addons.losses.npairs import npairs_loss, NpairsLoss, npairs_multilabel_loss, NpairsMultilabelLoss
 from tensorflow_addons.losses.sparsemax_loss import sparsemax_loss, SparsemaxLoss
 from tensorflow_addons.losses.triplet import triplet_semihard_loss, TripletSemiHardLoss
+
+# Temporarily disable for windows
+# Remove after: https://github.com/tensorflow/addons/issues/838
+import os
+if os.name != 'nt':
+    from tensorflow_addons.losses.npairs import npairs_loss, NpairsLoss, npairs_multilabel_loss, NpairsMultilabelLoss


Test patch:
diff --git a/.github/workflows/ci_test.yml b/.github/workflows/ci_test.yml
--- a/.github/workflows/ci_test.yml
+++ b/.github/workflows/ci_test.yml
@@ -13,11 +13,11 @@ env:
 
 jobs:
   macos-test:
-    name: Test PR on macOS
+    name: MacOS CPU Python3
     runs-on: macos-latest
     strategy:
       matrix:
-        python-version: ['3.7']
+        python-version: ['3.7.5']
     steps:
       - uses: actions/checkout@v1
       - uses: actions/setup-python@v1
@@ -27,8 +27,28 @@ jobs:
         run: |
           set -x -e
           python -m pip install wheel setuptools
-          python --version
           wget --quiet -nc https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/bazel-${BAZEL_VERSION}-installer-darwin-x86_64.sh
           chmod +x bazel-${BAZEL_VERSION}-installer-darwin-x86_64.sh
           ./bazel-${BAZEL_VERSION}-installer-darwin-x86_64.sh --user
           bash -x -e tools/ci_testing/addons_cpu.sh
+  windows-test:
+    name: Windows CPU Python3
+    runs-on: windows-latest
+    strategy:
+      matrix:
+        python-version: ['3.7.5']
+    steps:
+      - uses: actions/checkout@v1
+      - uses: numworks/setup-msys2@v1
+      - uses: actions/setup-python@v1
+        with:
+          python-version: ${{ matrix.python-version }}
+      - name: CI test windows py${{ matrix.python-version }}
+        shell: cmd
+        run: |
+            python -m pip install wheel setuptools
+            curl -sSOL https://github.com/bazelbuild/bazel/releases/download/%BAZEL_VERSION%/bazel-%BAZEL_VERSION%-windows-x86_64.exe
+            echo export BAZEL_VC=/c/Program\ Files\ \(x86\)/Microsoft\ Visual\ Studio/2019/Enterprise/VC/  >>D:\a\_temp\msys\msys64\home\runneradmin\.bash_profile
+            echo export BAZEL_PATH=/d/a/addons/addons/bazel-%BAZEL_VERSION%-windows-x86_64.exe  >>D:\a\_temp\msys\msys64\home\runneradmin\.bash_profile
+            echo export PATH=/c/hostedtoolcache/windows/Python/${{ matrix.python-version }}/x64/:$PATH  >>D:\a\_temp\msys\msys64\home\runneradmin\.bash_profile
+            msys2do ./tools/ci_testing/addons_cpu.sh
diff --git a/tensorflow_addons/activations/rrelu_test.py b/tensorflow_addons/activations/rrelu_test.py
--- a/tensorflow_addons/activations/rrelu_test.py
+++ b/tensorflow_addons/activations/rrelu_test.py
@@ -78,15 +78,15 @@ def inner(x):
                         theoretical, numerical, rtol=5e-4, atol=5e-4)
 
 
-class RreluBenchmarks(tf.test.Benchmark):
-    def benchmarkRreluOp(self):
-        with tf.compat.v1.Session(config=tf.test.benchmark_config()) as sess:
-            x = tf.constant([-2.0, -1.0, 0.0, 1.0, 2.0], dtype=np.float32)
-            lower = 0.1
-            upper = 0.2
-            result = rrelu(x, lower, upper, training=True)
-            self.run_op_benchmark(sess, result.op, min_iters=25)
-
+# TODO: Benchmark fails for windows builds #839
+# class RreluBenchmarks(tf.test.Benchmark):
+#     def benchmarkRreluOp(self):
+#         with tf.compat.v1.Session(config=tf.test.benchmark_config()) as sess:
+#             x = tf.constant([-2.0, -1.0, 0.0, 1.0, 2.0], dtype=np.float32)
+#             lower = 0.1
+#             upper = 0.2
+#             result = rrelu(x, lower, upper, training=True)
+#             self.run_op_benchmark(sess, result.op, min_iters=25)
 
 if __name__ == "__main__":
     tf.test.main()
diff --git a/tensorflow_addons/losses/npairs_dummy_test.py b/tensorflow_addons/losses/npairs_dummy_test.py
new file mode 100644
--- /dev/null
+++ b/tensorflow_addons/losses/npairs_dummy_test.py
@@ -0,0 +1,6 @@
+"""Temporary until SparseMatMul issue is solved for windows."""
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+
+# Remove after: https://github.com/tensorflow/addons/issues/838
diff --git a/tools/ci_testing/addons_cpu.sh b/tools/ci_testing/addons_cpu.sh
--- a/tools/ci_testing/addons_cpu.sh
+++ b/tools/ci_testing/addons_cpu.sh
@@ -25,8 +25,6 @@ if [[ ! -d "tensorflow_addons" ]]; then
     exit 1
 fi
 
-set -x
-
 PLATFORM="$(uname -s | tr 'A-Z' 'a-z')"
 
 if [[ ${PLATFORM} == "darwin" ]]; then
@@ -35,7 +33,6 @@ else
     N_JOBS=$(grep -c ^processor /proc/cpuinfo)
 fi
 
-
 echo ""
 echo "Bazel will use ${N_JOBS} concurrent job(s)."
 echo ""
@@ -47,7 +44,7 @@ export TF_NEED_CUDA=0
 echo 'y' | ./configure.sh
 
 ## Run bazel test command. Double test timeouts to avoid flakes.
-bazel test -c opt -k \
+${BAZEL_PATH:=bazel} test -c opt -k \
     --jobs=${N_JOBS} --test_timeout 300,450,1200,3600 \
     --test_output=errors --local_test_jobs=8 \
     --extra_toolchains=@bazel_tools//tools/python:autodetecting_toolchain_nonstrict \