From 1eda94917b72084181613ebe084f6ea15906a3d9 Mon Sep 17 00:00:00 2001
From: Michael An <2331806369@qq.com>
Date: Fri, 9 Aug 2024 12:33:44 +0800
Subject: [PATCH] change node version to 20.x (#6514)

---
 .github/workflows/dist.yml       |  2 +-
 .github/workflows/test.yml       | 10 ++--------
 tests/github_actions_npm_lint.sh |  6 ------
 tests/test_frontend_changes.sh   | 26 ++++++++++++++++++++++++++
 4 files changed, 29 insertions(+), 15 deletions(-)
 create mode 100644 tests/test_frontend_changes.sh

diff --git a/.github/workflows/dist.yml b/.github/workflows/dist.yml
index 147a47615a..b49d1b65b1 100644
--- a/.github/workflows/dist.yml
+++ b/.github/workflows/dist.yml
@@ -21,7 +21,7 @@ jobs:
           python-version: "3.8"
       - uses: actions/setup-node@v3
         with:
-          node-version: "16.x"
+          node-version: "20.x"
 
       - name: gettext for django
         run: |
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 0e24324a70..15f9139280 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -10,11 +10,6 @@ env:
 jobs:
   build:
     runs-on: ubuntu-latest
-
-    strategy:
-      matrix:
-        node-version: [20.x]
-
     steps:
       - uses: actions/checkout@v1
       - uses: actions/setup-python@v1
@@ -51,10 +46,9 @@ jobs:
 
       - uses: actions/setup-node@v2
         with:
-          node-version: ${{ matrix.node-version }}
+          node-version: "20.x"
 
       - name: run npm lint
         run: |
           cd $GITHUB_WORKSPACE/tests/
-          chmod +x github_actions_npm_lint.sh
-          ./github_actions_npm_lint.sh
+          if chmod +x test_frontend_changes.sh && ./test_frontend_changes.sh; then chmod +x github_actions_npm_lint.sh && ./github_actions_npm_lint.sh; else true; fi
diff --git a/tests/github_actions_npm_lint.sh b/tests/github_actions_npm_lint.sh
index cb0fe6ee99..ad464366c2 100644
--- a/tests/github_actions_npm_lint.sh
+++ b/tests/github_actions_npm_lint.sh
@@ -11,16 +11,10 @@ fi
 
 export GITHUB_BRANCH=$branch
 
-echo "GITHUB_BRANCH: $GITHUB_BRANCH"
-
 export PYTHONPATH="${PYTHONPATH}:/tmp/site-packages"
 
-echo "PYTHONPATH: $PYTHONPATH"
-
 echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >~/.npmrc
 
 cd $GITHUB_WORKSPACE
 
-echo "npm run lint on frontend/src files..."
-
 cd ./frontend && npm install && npm run lint
diff --git a/tests/test_frontend_changes.sh b/tests/test_frontend_changes.sh
new file mode 100644
index 0000000000..20e5d129c9
--- /dev/null
+++ b/tests/test_frontend_changes.sh
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+check_path_fn()
+{
+    FN=$1
+    shift
+    patt="frontend*"
+    [[ $FN == $patt ]] && return 1
+    return 0
+}
+
+FILES=`git diff --name-only HEAD~`
+
+for i in $FILES
+do
+    check_path_fn $i
+    retval=$?
+
+    if [ "$retval" == 1 ]; then
+        echo "File changes need to trigger tests."
+        exit 0
+    fi
+
+done
+
+exit 1