Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
name: lua-resty-netacea-build
on: [push, pull_request]
on:
pull_request:
branches:
- master
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 60
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
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

32 changes: 25 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,42 @@
FROM openresty/openresty:xenial
FROM openresty/openresty:xenial AS base

LABEL author="Curtis Johnson <curtis.johnson@netacea.com>"
LABEL maintainer="Curtis Johnson <curtis.johnson@netacea.com>"

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"]
7 changes: 0 additions & 7 deletions Dockerfile.test

This file was deleted.

14 changes: 4 additions & 10 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 6 additions & 4 deletions test/lua_resty_netacea.test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '_/@#/'

Expand Down
Loading