From 20291ad02621b141beca2007a257ac5d150eca09 Mon Sep 17 00:00:00 2001 From: Mark Greenwood Date: Tue, 25 Nov 2025 12:05:57 +0000 Subject: [PATCH 1/7] Reorganise the docker file, so we don't need compose. Remove coverage check which seems to cause the tests to hang --- Dockerfile | 32 +++++++++++++++++++++++++------- Dockerfile.test | 7 ------- test/lua_resty_netacea.test.lua | 9 +++++---- 3 files changed, 30 insertions(+), 18 deletions(-) delete mode 100644 Dockerfile.test diff --git a/Dockerfile b/Dockerfile index 9cb1c11..24900f9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,42 @@ -FROM openresty/openresty:xenial +FROM openresty/openresty:xenial AS base LABEL author="Curtis Johnson " LABEL maintainer="Curtis Johnson " USER root -ENV HOME=/usr/src +WORKDIR /usr/src +# ENV HOME=/usr/src RUN apt-get update RUN apt-get install -y libssl-dev -RUN cd $HOME - -COPY ./lua_resty_netacea-0.2-2.rockspec ./ -COPY ./src ./src +# RUN cd $HOME RUN curl -L -o /tmp/luarocks-3.12.2-1.src.rock https://luarocks.org/luarocks-3.12.2-1.src.rock &&\ luarocks install /tmp/luarocks-3.12.2-1.src.rock &&\ rm /tmp/luarocks-3.12.2-1.src.rock + +FROM base AS build +COPY ./lua_resty_netacea-0.2-2.rockspec ./ +COPY ./src ./src RUN /usr/local/openresty/luajit/bin/luarocks make ./lua_resty_netacea-0.2-2.rockspec -## https://github.com/luarocks/luarocks/issues/1797 +FROM build AS test + +RUN /usr/local/openresty/luajit/bin/luarocks install busted +RUN /usr/local/openresty/luajit/bin/luarocks install luacov +RUN /usr/local/openresty/luajit/bin/luarocks install cluacov +RUN /usr/local/openresty/luajit/bin/luarocks install require +RUN /usr/local/openresty/luajit/bin/luarocks install luacheck + +COPY ./test ./test +COPY ./run_lua_tests.sh ./run_lua_tests.sh +RUN chmod +x ./run_lua_tests.sh + +CMD ["bash", "-c", "./run_lua_tests.sh"] + +FROM test AS lint + +CMD ["sh", "-c", "\"cd /usr/src && luacheck --no-self -- /usr/src\""] \ No newline at end of file diff --git a/Dockerfile.test b/Dockerfile.test deleted file mode 100644 index c15a701..0000000 --- a/Dockerfile.test +++ /dev/null @@ -1,7 +0,0 @@ -FROM lua_resty_netacea:latest - -RUN /usr/local/openresty/luajit/bin/luarocks install busted -RUN /usr/local/openresty/luajit/bin/luarocks install luacov -RUN /usr/local/openresty/luajit/bin/luarocks install cluacov -RUN /usr/local/openresty/luajit/bin/luarocks install require -RUN /usr/local/openresty/luajit/bin/luarocks install luacheck diff --git a/test/lua_resty_netacea.test.lua b/test/lua_resty_netacea.test.lua index 189bba9..e6b7f66 100644 --- a/test/lua_resty_netacea.test.lua +++ b/test/lua_resty_netacea.test.lua @@ -2,10 +2,11 @@ require 'busted.runner'() package.path = "../src/?.lua;" .. package.path -local runner = require 'luacov.runner' -runner.tick = true -runner.init({savestepsize = 3}) -jit.off() +-- Temporarily disable luacov to check if it's causing the hang +-- local runner = require 'luacov.runner' +-- runner.tick = true +-- runner.init({savestepsize = 3}) +-- jit.off() local COOKIE_DELIMITER = '_/@#/' From f779c8f2780b9c2fb21f52410c69552e601559f7 Mon Sep 17 00:00:00 2001 From: Mark Greenwood Date: Tue, 25 Nov 2025 12:07:42 +0000 Subject: [PATCH 2/7] Switch to plain docker builds --- .github/workflows/build.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e0fa65c..6f07081 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,8 +8,6 @@ jobs: - name: Checkout uses: actions/checkout@master - name: Build Image - run: docker-compose build + run: docker build --target test . - name: Lint - run: docker-compose run lint - - name: Test - run: docker-compose run test \ No newline at end of file + run: docker build --target lint . \ No newline at end of file From 58929f2c2ad8a7916edb96b3d72a925b52e1eb60 Mon Sep 17 00:00:00 2001 From: Mark Greenwood Date: Tue, 25 Nov 2025 12:12:06 +0000 Subject: [PATCH 3/7] Add in run step --- .github/workflows/build.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6f07081..87c22d6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,7 +7,12 @@ jobs: steps: - name: Checkout uses: actions/checkout@master - - name: Build Image - run: docker build --target test . + - name: Test + run: | + docker build --target test -t lua-resty-netacea-test . + docker run --rm lua-resty-netacea-test - name: Lint - run: docker build --target lint . \ No newline at end of file + run: | + docker build --target lint -t lua-resty-netacea-lint . + docker run --rm lua-resty-netacea-lint + \ No newline at end of file From 3a3ac4f7c4486fd1a18b3e9cc6d66a86136b1449 Mon Sep 17 00:00:00 2001 From: Mark Greenwood Date: Tue, 25 Nov 2025 12:17:13 +0000 Subject: [PATCH 4/7] Fix lint command --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 24900f9..21361b3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -39,4 +39,4 @@ CMD ["bash", "-c", "./run_lua_tests.sh"] FROM test AS lint -CMD ["sh", "-c", "\"cd /usr/src && luacheck --no-self -- /usr/src\""] \ No newline at end of file +CMD ["bash", "-c", "luacheck --no-self -- ./src"] \ No newline at end of file From ec55d2dd9777038397f0baa28757cdfcca21b0a3 Mon Sep 17 00:00:00 2001 From: Mark Greenwood Date: Tue, 25 Nov 2025 12:23:25 +0000 Subject: [PATCH 5/7] Fix triggers --- .github/workflows/build.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 87c22d6..3fa090c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,5 +1,11 @@ name: lua-resty-netacea-build -on: [push, pull_request] +on: + pull_request: + branches: + - master + push: + branches: + - master jobs: build: runs-on: ubuntu-latest From 43d2bdcba1bc4a8eeac10745a597f2ef498bbc70 Mon Sep 17 00:00:00 2001 From: Mark Greenwood Date: Tue, 25 Nov 2025 12:29:32 +0000 Subject: [PATCH 6/7] Update comment --- test/lua_resty_netacea.test.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/lua_resty_netacea.test.lua b/test/lua_resty_netacea.test.lua index e6b7f66..95db198 100644 --- a/test/lua_resty_netacea.test.lua +++ b/test/lua_resty_netacea.test.lua @@ -2,7 +2,8 @@ require 'busted.runner'() package.path = "../src/?.lua;" .. package.path --- Temporarily disable luacov to check if it's causing the hang +-- luacov is disabled because this runner causes the test to hang after completion. +-- Need to take another look at this in future. -- local runner = require 'luacov.runner' -- runner.tick = true -- runner.init({savestepsize = 3}) From 19ed4a41453aafb7c854b0a63bc36c5c4b3be770 Mon Sep 17 00:00:00 2001 From: Mark Greenwood Date: Tue, 25 Nov 2025 14:52:35 +0000 Subject: [PATCH 7/7] Fix docker-compose for local use --- docker-compose.yml | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 4c993e1..6e3f0d9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,28 +16,22 @@ services: test: build: - dockerfile: Dockerfile.test + dockerfile: Dockerfile context: . + target: test volumes: - "./src:/usr/src/src" - "./test:/usr/src/test" - - "./run_lua_tests.sh:/usr/src/run_lua_tests.sh" - security_opt: - - seccomp:unconfined - command: bash -c '. /usr/src/run_lua_tests.sh -s; exit $$?' lint: build: - dockerfile: Dockerfile.test + dockerfile: Dockerfile context: . + target: lint volumes: - "./.luacheckrc:/usr/src/.luacheckrc" - "./src:/usr/src/src" - "./test:/usr/src/test" - - "./run_lua_tests.sh:/usr/src/run_lua_tests.sh" - security_opt: - - seccomp:unconfined - command: sh -c 'cd /usr/src && luacheck --no-self -- /usr/src' nginx_lua: build: