From 57b5f5a6b47b80a7a6eca1592bbbb9e419e8e72d Mon Sep 17 00:00:00 2001
From: tzssangglass <tzssangglass@gmail.com>
Date: Thu, 13 Jan 2022 11:02:18 +0800
Subject: [PATCH 1/7] ci: run lua test cases with luajit

since lua-cjson 2.1.0-1 may fail to install, ref
https://github.com/openresty/lua-cjson/issues/21, so use lua-cjson2,
ref: https://github.com/leafo/lapis/issues/539#issuecomment-319393395

Signed-off-by: tzssangglass <tzssangglass@gmail.com>
---
 .github/workflows/ci.yaml | 24 +++++++++---------------
 1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index e551ac7..c4c43ff 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -43,23 +43,17 @@ jobs:
         uses: apache/skywalking-eyes@main
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-      - name: 'Install Lua'
-        shell: bash
-        run: |
-          sudo apt-get update -y
-          sudo apt-get install -y lua5.3 lua5.3-dev
-          sudo ln /usr/bin/lua5.3 /usr/bin/lua
       - name: 'Install LuaRocks'
         run: |
-          wget https://luarocks.org/releases/luarocks-3.3.0.tar.gz
-          tar zxpf luarocks-3.3.0.tar.gz
-          cd luarocks-3.3.0
+          wget https://luarocks.org/releases/luarocks-3.8.0.tar.gz
+          tar zxpf luarocks-3.8.0.tar.gz
+          cd luarocks-3.8.0
           ./configure && make && sudo make install
           cd ..
       - name: 'Install Dependencies'
         run: |
           sudo luarocks install luaunit
-          sudo luarocks install lua-cjson 2.1.0-1
+          sudo luarocks install lua-cjson2
           sudo luarocks install lua-resty-jit-uuid
       - name: "Install OpenResty"
         run: |
@@ -77,11 +71,11 @@ jobs:
       - name: 'Run Lua Tests'
         run: |
           cd lib
-          lua skywalking/util_test.lua
-          lua skywalking/span_test.lua
-          lua skywalking/tracing_context_test.lua
-          lua skywalking/segment_ref_test.lua
-          lua skywalking/correlation_context_test.lua
+          /usr/local/openresty-debug/luajit/bin/luajit skywalking/util_test.lua
+          /usr/local/openresty-debug/luajit/bin/luajit skywalking/span_test.lua
+          /usr/local/openresty-debug/luajit/bin/luajit skywalking/tracing_context_test.lua
+          /usr/local/openresty-debug/luajit/bin/luajit skywalking/segment_ref_test.lua
+          /usr/local/openresty-debug/luajit/bin/luajit skywalking/correlation_context_test.lua
           cd ..
       - name: 'Run Nginx Lua Tests'
         run: |

From 74a1ea38ab5526de25f4ba6ef416b693555fe77c Mon Sep 17 00:00:00 2001
From: tzssangglass <tzssangglass@gmail.com>
Date: Thu, 13 Jan 2022 11:04:32 +0800
Subject: [PATCH 2/7] recover install lua5.3

Signed-off-by: tzssangglass <tzssangglass@gmail.com>
---
 .github/workflows/ci.yaml | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index c4c43ff..94aec57 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -43,6 +43,12 @@ jobs:
         uses: apache/skywalking-eyes@main
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+      - name: 'Install Lua'
+        shell: bash
+        run: |
+          sudo apt-get update -y
+          sudo apt-get install -y lua5.3 lua5.3-dev
+          sudo ln /usr/bin/lua5.3 /usr/bin/lua
       - name: 'Install LuaRocks'
         run: |
           wget https://luarocks.org/releases/luarocks-3.8.0.tar.gz

From 54fd8e9d8d86b7711ed080919463016016e8b34a Mon Sep 17 00:00:00 2001
From: tzssangglass <tzssangglass@gmail.com>
Date: Thu, 13 Jan 2022 11:14:24 +0800
Subject: [PATCH 3/7] install lua5.1 instead of lua5.3

Signed-off-by: tzssangglass <tzssangglass@gmail.com>
---
 .github/workflows/ci.yaml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index 94aec57..e025108 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -47,8 +47,8 @@ jobs:
         shell: bash
         run: |
           sudo apt-get update -y
-          sudo apt-get install -y lua5.3 lua5.3-dev
-          sudo ln /usr/bin/lua5.3 /usr/bin/lua
+          sudo apt-get install -y lua5.1 lua5.1-dev
+          sudo ln /usr/bin/lua5.1 /usr/bin/lua
       - name: 'Install LuaRocks'
         run: |
           wget https://luarocks.org/releases/luarocks-3.8.0.tar.gz

From 85a7bd270ace42c59683bc9777198e6ac4c2107d Mon Sep 17 00:00:00 2001
From: tzssangglass <tzssangglass@gmail.com>
Date: Thu, 13 Jan 2022 11:16:53 +0800
Subject: [PATCH 4/7] remove install lua5.1(CI env already has)

Signed-off-by: tzssangglass <tzssangglass@gmail.com>
---
 .github/workflows/ci.yaml | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index e025108..c4c43ff 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -43,12 +43,6 @@ jobs:
         uses: apache/skywalking-eyes@main
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-      - name: 'Install Lua'
-        shell: bash
-        run: |
-          sudo apt-get update -y
-          sudo apt-get install -y lua5.1 lua5.1-dev
-          sudo ln /usr/bin/lua5.1 /usr/bin/lua
       - name: 'Install LuaRocks'
         run: |
           wget https://luarocks.org/releases/luarocks-3.8.0.tar.gz

From cbce1df69c7276cd72807d346ecf0d141d759c4a Mon Sep 17 00:00:00 2001
From: tzssangglass <tzssangglass@gmail.com>
Date: Thu, 13 Jan 2022 11:22:41 +0800
Subject: [PATCH 5/7] debug

Signed-off-by: tzssangglass <tzssangglass@gmail.com>
---
 .github/workflows/ci.yaml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index c4c43ff..e6f2525 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -43,6 +43,8 @@ jobs:
         uses: apache/skywalking-eyes@main
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+      - name: Setup tmate session
+        uses: mxschmitt/action-tmate@v3
       - name: 'Install LuaRocks'
         run: |
           wget https://luarocks.org/releases/luarocks-3.8.0.tar.gz

From 4acb8d59ffb51b58f8414a564236b5a6a44ae67d Mon Sep 17 00:00:00 2001
From: tzssangglass <tzssangglass@gmail.com>
Date: Thu, 13 Jan 2022 11:34:42 +0800
Subject: [PATCH 6/7] remove debug and restore install lua 5.1

Signed-off-by: tzssangglass <tzssangglass@gmail.com>
---
 .github/workflows/ci.yaml | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index e6f2525..c33c63c 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -43,8 +43,11 @@ jobs:
         uses: apache/skywalking-eyes@main
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-      - name: Setup tmate session
-        uses: mxschmitt/action-tmate@v3
+      - name: 'Install Lua'
+        shell: bash
+        run: |
+          sudo apt-get update -y
+          sudo apt-get install -y lua5.1 lua5.1-dev
       - name: 'Install LuaRocks'
         run: |
           wget https://luarocks.org/releases/luarocks-3.8.0.tar.gz

From c5f094208664628547ab695e59c3d7cf7a0b0eba Mon Sep 17 00:00:00 2001
From: tzssangglass <tzssangglass@gmail.com>
Date: Thu, 13 Jan 2022 11:44:14 +0800
Subject: [PATCH 7/7] modify the dependency file description

Signed-off-by: tzssangglass <tzssangglass@gmail.com>
---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 1f09aac..026cf41 100644
--- a/README.md
+++ b/README.md
@@ -117,7 +117,7 @@ All codes in the `lib/skywalking` require the `*_test.lua` to do the UnitTest. T
 - LuaRocks
 
 The following libs are required in runtime or test cases, please use `LuaRocks` to install them.
-- lua-cjson. NOTICE, some platforms such as MacOS 10.15 may have issue with the latest release of this lib, consider to install an old release.(`luarocks install lua-cjson 2.1.0-1`)
+- lua-cjson2. NOTICE, lua-cjson2 is to fix the bug in lua-cjson 2.1.0-1. ref to: https://github.com/apache/skywalking-nginx-lua/pull/94
 - luaunit
 - lua-resty-jit-uuid
 
