From 5104c82310f9ab49d2c177cc90c2468def420992 Mon Sep 17 00:00:00 2001
From: Wei Fu <fuweid89@gmail.com>
Date: Tue, 3 Jan 2023 15:26:31 +0800
Subject: [PATCH] .github: split test job into test-{linux/windows}

Signed-off-by: Wei Fu <fuweid89@gmail.com>
---
 .github/workflows/tests.yaml | 56 +++++++++++++++++++++++++++++-------
 1 file changed, 46 insertions(+), 10 deletions(-)

diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml
index f4b6c69..c2a0283 100644
--- a/.github/workflows/tests.yaml
+++ b/.github/workflows/tests.yaml
@@ -1,16 +1,15 @@
 name: Tests
 on: [push, pull_request]
 jobs:
-  test:
+  test-linux:
     strategy:
       fail-fast: false
       matrix:
-        os: [ubuntu-latest, windows-latest]
         target:
-        - unit-test-2-cpu
-        - unit-test-4-cpu
-        - unit-test-4-cpu-race
-    runs-on: ${{ matrix.os }}
+        - linux-amd64-unit-test-2-cpu
+        - linux-amd64-unit-test-4-cpu
+        - linux-amd64-unit-test-4-cpu-race
+    runs-on: ubuntu-latest
     steps:
     - uses: actions/checkout@v3
     - uses: actions/setup-go@v3
@@ -21,15 +20,15 @@ jobs:
         TARGET: ${{ matrix.target }}
       run: |
         case "${TARGET}" in
-          unit-test-2-cpu)
+          linux-amd64-unit-test-2-cpu)
             CPU=2 make test-simulate
             CPU=2 make test
             ;;
-          unit-test-4-cpu)
+          linux-amd64-unit-test-4-cpu)
             CPU=4 make test-simulate
             CPU=4 make test
             ;;
-          unit-test-4-cpu-race)
+          linux-amd64-unit-test-4-cpu-race)
             CPU=4 ENABLE_RACE=true make test-simulate
             CPU=4 ENABLE_RACE=true make test
             ;;
@@ -38,12 +37,49 @@ jobs:
             exit 1
             ;;
         esac
+    - name: golangci-lint
+      uses: golangci/golangci-lint-action@0ad9a0988b3973e851ab0a07adf248ec2e100376 # v3.3.1
+
+  test-windows:
+    strategy:
+      fail-fast: false
+      matrix:
+        target:
+        - windows-amd64-unit-test-4-cpu
+        # FIXME(fuweid):
+        #
+        # The windows will throws the following error when enable race.
+        # We skip it until we have solution.
+        #
+        #   ThreadSanitizer failed to allocate 0x000200000000 (8589934592) bytes at 0x0400c0000000 (error code: 1455)
+        #
+        #- windows-amd64-unit-test-4-cpu-race
+    runs-on: windows-latest
+    steps:
+    - uses: actions/checkout@v3
+    - uses: actions/setup-go@v3
+      with:
+        go-version: "1.17.13"
+    - run: make fmt
+    - env:
+        TARGET: ${{ matrix.target }}
+      run: |
+        case "${TARGET}" in
+          windows-amd64-unit-test-4-cpu)
+            CPU=4 make test-simulate
+            CPU=4 make test
+            ;;
+          *)
+            echo "Failed to find target"
+            exit 1
+            ;;
+        esac
       shell: bash
     - name: golangci-lint
       uses: golangci/golangci-lint-action@0ad9a0988b3973e851ab0a07adf248ec2e100376 # v3.3.1
 
   coverage:
-    needs: ["test"]
+    needs: ["test-linux", "test-windows"]
     strategy:
       matrix:
         os: [ubuntu-latest, windows-latest]