diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e0fa65c..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 @@ -7,9 +13,12 @@ jobs: steps: - name: Checkout uses: actions/checkout@master - - name: Build Image - run: docker-compose build - - name: Lint - run: docker-compose run lint - name: Test - run: docker-compose run test \ No newline at end of file + run: | + docker build --target test -t lua-resty-netacea-test . + docker run --rm lua-resty-netacea-test + - name: Lint + run: | + docker build --target lint -t lua-resty-netacea-lint . + docker run --rm lua-resty-netacea-lint + \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 9cb1c11..21361b3 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 ["bash", "-c", "luacheck --no-self -- ./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/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: diff --git a/test/lua_resty_netacea.test.lua b/test/lua_resty_netacea.test.lua index 189bba9..95db198 100644 --- a/test/lua_resty_netacea.test.lua +++ b/test/lua_resty_netacea.test.lua @@ -2,10 +2,12 @@ require 'busted.runner'() package.path = "../src/?.lua;" .. package.path -local runner = require 'luacov.runner' -runner.tick = true -runner.init({savestepsize = 3}) -jit.off() +-- 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}) +-- jit.off() local COOKIE_DELIMITER = '_/@#/'