From 7e5047cfb073281bf6b59958dd2427ae5b3b2ea6 Mon Sep 17 00:00:00 2001 From: Lazarev Date: Wed, 20 Oct 2021 15:56:21 +0300 Subject: [PATCH 01/10] Use docker for testing --- .gitignore | 1 + docker-compose.yml | 9 ++++++++ dockerfiles/Dockerfile | 46 +++++++++++++++++++++++++++++++++++++ dockerfiles/bin/do_tests.sh | 9 ++++++++ 4 files changed, 65 insertions(+) create mode 100644 docker-compose.yml create mode 100644 dockerfiles/Dockerfile create mode 100644 dockerfiles/bin/do_tests.sh diff --git a/.gitignore b/.gitignore index a4fd3586..abc29753 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ Settings.xml # Testing luajit/ +spec/test_results.log # Release manifest-updated.xml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..231ef1dd --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,9 @@ +version: "3.8" +services: + + busted: + build: + context: . + dockerfile: dockerfiles/Dockerfile + container_name: busted + command: busted --lua=luajit \ No newline at end of file diff --git a/dockerfiles/Dockerfile b/dockerfiles/Dockerfile new file mode 100644 index 00000000..a882f537 --- /dev/null +++ b/dockerfiles/Dockerfile @@ -0,0 +1,46 @@ +FROM ubuntu:latest + +# First, ensure that you have development tools installed on your system, otherwise run the command below to install them. +RUN apt update && \ + apt install -y --no-install-recommends \ + build-essential \ + libreadline-dev \ + unzip \ + curl \ + wget \ + git \ + ca-certificates + +RUN cd /home + +# Then to build and install Lua, run the following commands to download the package tar ball, extract, build and install it. +RUN curl -R -O http://www.lua.org/ftp/lua-5.1.5.tar.gz && \ + tar -zxf lua-5.1.5.tar.gz && \ + cd lua-5.1.5 && \ + make linux test && \ + make install + +# Download and unpack the LuaRocks tarball using following commands. +RUN wget https://luarocks.org/releases/luarocks-3.7.0.tar.gz && \ + tar zxpf luarocks-3.7.0.tar.gz && \ + cd luarocks-3.7.0 && \ + ./configure --with-lua-include=/usr/local/include && \ + make && \ + make install + +# Install luajit +RUN cd /home && \ + git clone https://luajit.org/git/luajit.git && \ + cd luajit \ + make && \ + make install && \ + ln -sf luajit-2.1.0-beta3 /usr/local/bin/luajit + +# Setupping test enviroment +RUN luarocks install busted && \ + luarocks install cluacov + +RUN cd /root +COPY . . + +ENTRYPOINT [] \ No newline at end of file diff --git a/dockerfiles/bin/do_tests.sh b/dockerfiles/bin/do_tests.sh new file mode 100644 index 00000000..e5b363d1 --- /dev/null +++ b/dockerfiles/bin/do_tests.sh @@ -0,0 +1,9 @@ +#!/bin/sh +docker-compose up -d +while [ $(docker ps -q -f name=busted) ] +do + sleep 1s +done +LOGS_LENGTH=$(docker logs -f busted | wc -l) +LAST_START=$(docker logs -f busted | grep -n "Loading main script..." | tail -1 | cut -d : -f 1) +docker logs --tail $((LOGS_LENGTH - LAST_START + 1)) -f busted > spec/test_results.log \ No newline at end of file From 7c355aa7c43b02701cc52d309bece15c3ac16d9f Mon Sep 17 00:00:00 2001 From: Lazarev Date: Wed, 20 Oct 2021 16:48:05 +0300 Subject: [PATCH 02/10] Use docker for generating builds --- CONTRIBUTING.md | 12 ++++++++ dockerfiles/Dockerfile_generation | 45 ++++++++++++++++++++++++++++++ dockerfiles/bin/generate_builds.sh | 5 ++++ 3 files changed, 62 insertions(+) create mode 100644 dockerfiles/Dockerfile_generation create mode 100644 dockerfiles/bin/generate_builds.sh diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9a9510e9..789c22af 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -115,6 +115,11 @@ More tests can be added to this folder to test specific functionality, or new te 2. Run `luarocks install busted` 3. Run `busted --lua=luajit` from the command line. You may need to add `luajit` to your PATH +Or + +1. Run `dockerfiles/bin/do_tests.sh` from the command line +2. View last results in `spec/test_results.log` + ### Creating new test builds or fixing an existing build Sometimes a change will be made that intends to change the stats garnered by PoB, which will break our tests. @@ -122,6 +127,13 @@ Sometimes a change will be made that intends to change the stats garnered by PoB 2. Run `busted --lua=luajit -r generate` to generate a LUA file that contains the current stats of that build 3. Run `busted --lua=luajit` and the tests should pass +Or + +1. Add the new build XML (if applicable) to the `TestBuilds` folder +2. Run `dockerfiles/bin/generate_builds.sh` from the command line +3. Run `dockerfiles/bin/do_tests.sh` from the command line +4. View last results in `spec/test_results.log` + ## Keeping your fork up to date Note: This tutorial assumes that you are already familiar with Git and basic command line tools. diff --git a/dockerfiles/Dockerfile_generation b/dockerfiles/Dockerfile_generation new file mode 100644 index 00000000..f0177e37 --- /dev/null +++ b/dockerfiles/Dockerfile_generation @@ -0,0 +1,45 @@ +FROM ubuntu:latest + +# First, ensure that you have development tools installed on your system, otherwise run the command below to install them. +RUN apt update && \ + apt install -y --no-install-recommends \ + build-essential \ + libreadline-dev \ + unzip \ + curl \ + wget \ + git \ + ca-certificates + +RUN cd /home + +# Then to build and install Lua, run the following commands to download the package tar ball, extract, build and install it. +RUN curl -R -O http://www.lua.org/ftp/lua-5.1.5.tar.gz && \ + tar -zxf lua-5.1.5.tar.gz && \ + cd lua-5.1.5 && \ + make linux test && \ + make install + +# Download and unpack the LuaRocks tarball using following commands. +RUN wget https://luarocks.org/releases/luarocks-3.7.0.tar.gz && \ + tar zxpf luarocks-3.7.0.tar.gz && \ + cd luarocks-3.7.0 && \ + ./configure --with-lua-include=/usr/local/include && \ + make && \ + make install + +# Install luajit +RUN cd /home && \ + git clone https://luajit.org/git/luajit.git && \ + cd luajit \ + make && \ + make install && \ + ln -sf luajit-2.1.0-beta3 /usr/local/bin/luajit + +# Setupping test enviroment +RUN luarocks install busted && \ + luarocks install cluacov + +WORKDIR /root + +ENTRYPOINT [] \ No newline at end of file diff --git a/dockerfiles/bin/generate_builds.sh b/dockerfiles/bin/generate_builds.sh new file mode 100644 index 00000000..518d0983 --- /dev/null +++ b/dockerfiles/bin/generate_builds.sh @@ -0,0 +1,5 @@ +#!/bin/sh +cd dockerfiles +docker build -t busted:generation -f Dockerfile_generation . +cd .. +docker run -v $(pwd):/root --rm -i busted:generation busted --lua=luajit -r generate \ No newline at end of file From 5ddad3cd5eb67000dcd9c5f92a1ecae9167a3365 Mon Sep 17 00:00:00 2001 From: Lazarev Date: Wed, 20 Oct 2021 17:08:35 +0300 Subject: [PATCH 03/10] Optimize dockerfiles --- docker-compose.yml | 4 ++- dockerfiles/Dockerfile | 3 +- dockerfiles/Dockerfile_generation | 45 ------------------------------ dockerfiles/bin/do_tests.sh | 4 ++- dockerfiles/bin/generate_builds.sh | 2 +- 5 files changed, 8 insertions(+), 50 deletions(-) delete mode 100644 dockerfiles/Dockerfile_generation diff --git a/docker-compose.yml b/docker-compose.yml index 231ef1dd..d1fc1200 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,4 +6,6 @@ services: context: . dockerfile: dockerfiles/Dockerfile container_name: busted - command: busted --lua=luajit \ No newline at end of file + command: busted --lua=luajit + volumes: + - ./:/root \ No newline at end of file diff --git a/dockerfiles/Dockerfile b/dockerfiles/Dockerfile index a882f537..f0177e37 100644 --- a/dockerfiles/Dockerfile +++ b/dockerfiles/Dockerfile @@ -40,7 +40,6 @@ RUN cd /home && \ RUN luarocks install busted && \ luarocks install cluacov -RUN cd /root -COPY . . +WORKDIR /root ENTRYPOINT [] \ No newline at end of file diff --git a/dockerfiles/Dockerfile_generation b/dockerfiles/Dockerfile_generation deleted file mode 100644 index f0177e37..00000000 --- a/dockerfiles/Dockerfile_generation +++ /dev/null @@ -1,45 +0,0 @@ -FROM ubuntu:latest - -# First, ensure that you have development tools installed on your system, otherwise run the command below to install them. -RUN apt update && \ - apt install -y --no-install-recommends \ - build-essential \ - libreadline-dev \ - unzip \ - curl \ - wget \ - git \ - ca-certificates - -RUN cd /home - -# Then to build and install Lua, run the following commands to download the package tar ball, extract, build and install it. -RUN curl -R -O http://www.lua.org/ftp/lua-5.1.5.tar.gz && \ - tar -zxf lua-5.1.5.tar.gz && \ - cd lua-5.1.5 && \ - make linux test && \ - make install - -# Download and unpack the LuaRocks tarball using following commands. -RUN wget https://luarocks.org/releases/luarocks-3.7.0.tar.gz && \ - tar zxpf luarocks-3.7.0.tar.gz && \ - cd luarocks-3.7.0 && \ - ./configure --with-lua-include=/usr/local/include && \ - make && \ - make install - -# Install luajit -RUN cd /home && \ - git clone https://luajit.org/git/luajit.git && \ - cd luajit \ - make && \ - make install && \ - ln -sf luajit-2.1.0-beta3 /usr/local/bin/luajit - -# Setupping test enviroment -RUN luarocks install busted && \ - luarocks install cluacov - -WORKDIR /root - -ENTRYPOINT [] \ No newline at end of file diff --git a/dockerfiles/bin/do_tests.sh b/dockerfiles/bin/do_tests.sh index e5b363d1..584c7958 100644 --- a/dockerfiles/bin/do_tests.sh +++ b/dockerfiles/bin/do_tests.sh @@ -6,4 +6,6 @@ do done LOGS_LENGTH=$(docker logs -f busted | wc -l) LAST_START=$(docker logs -f busted | grep -n "Loading main script..." | tail -1 | cut -d : -f 1) -docker logs --tail $((LOGS_LENGTH - LAST_START + 1)) -f busted > spec/test_results.log \ No newline at end of file +docker logs --tail $((LOGS_LENGTH - LAST_START + 1)) -f busted > spec/test_results.log +echo Finished with results: +echo $(grep "[0-9] successes" spec/test_results.log) \ No newline at end of file diff --git a/dockerfiles/bin/generate_builds.sh b/dockerfiles/bin/generate_builds.sh index 518d0983..840f3228 100644 --- a/dockerfiles/bin/generate_builds.sh +++ b/dockerfiles/bin/generate_builds.sh @@ -1,5 +1,5 @@ #!/bin/sh cd dockerfiles -docker build -t busted:generation -f Dockerfile_generation . +docker build -t busted:generation -f Dockerfile . cd .. docker run -v $(pwd):/root --rm -i busted:generation busted --lua=luajit -r generate \ No newline at end of file From e823f796911176131a658bc9f4e13f2ddbd37dee Mon Sep 17 00:00:00 2001 From: Lazarev Date: Wed, 20 Oct 2021 17:11:36 +0300 Subject: [PATCH 04/10] Fix readme wording --- CONTRIBUTING.md | 9 ++++----- dockerfiles/Dockerfile | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 789c22af..1807436a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -115,7 +115,7 @@ More tests can be added to this folder to test specific functionality, or new te 2. Run `luarocks install busted` 3. Run `busted --lua=luajit` from the command line. You may need to add `luajit` to your PATH -Or +Docker alternative: 1. Run `dockerfiles/bin/do_tests.sh` from the command line 2. View last results in `spec/test_results.log` @@ -127,12 +127,11 @@ Sometimes a change will be made that intends to change the stats garnered by PoB 2. Run `busted --lua=luajit -r generate` to generate a LUA file that contains the current stats of that build 3. Run `busted --lua=luajit` and the tests should pass -Or +Docker alternative: 1. Add the new build XML (if applicable) to the `TestBuilds` folder -2. Run `dockerfiles/bin/generate_builds.sh` from the command line -3. Run `dockerfiles/bin/do_tests.sh` from the command line -4. View last results in `spec/test_results.log` +2. Run `dockerfiles/bin/generate_builds.sh` to generate a LUA file that contains the current stats of that build +3. Run `dockerfiles/bin/do_tests.sh` and the tests should pass ## Keeping your fork up to date diff --git a/dockerfiles/Dockerfile b/dockerfiles/Dockerfile index f0177e37..3e810590 100644 --- a/dockerfiles/Dockerfile +++ b/dockerfiles/Dockerfile @@ -36,7 +36,7 @@ RUN cd /home && \ make install && \ ln -sf luajit-2.1.0-beta3 /usr/local/bin/luajit -# Setupping test enviroment +# Setup test enviroment RUN luarocks install busted && \ luarocks install cluacov From 16b2aee642edff07cc72a47a59c3e69f818772e5 Mon Sep 17 00:00:00 2001 From: Lazarev Date: Wed, 20 Oct 2021 17:18:57 +0300 Subject: [PATCH 05/10] Fixes --- dockerfiles/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/dockerfiles/Dockerfile b/dockerfiles/Dockerfile index 3e810590..8e8d25c7 100644 --- a/dockerfiles/Dockerfile +++ b/dockerfiles/Dockerfile @@ -13,6 +13,7 @@ RUN apt update && \ RUN cd /home + # Then to build and install Lua, run the following commands to download the package tar ball, extract, build and install it. RUN curl -R -O http://www.lua.org/ftp/lua-5.1.5.tar.gz && \ tar -zxf lua-5.1.5.tar.gz && \ From d380310cae2e3c9f4915e6a61cf93d49af8257a9 Mon Sep 17 00:00:00 2001 From: Lazarev Date: Fri, 22 Oct 2021 00:22:22 +0300 Subject: [PATCH 06/10] Now docker compose do both things: generate builds and run tests --- docker-compose.yml | 22 +++++++++----- dockerfiles/Dockerfile | 46 ------------------------------ dockerfiles/bin/do_tests.sh | 11 ------- dockerfiles/bin/generate_builds.sh | 5 ---- 4 files changed, 15 insertions(+), 69 deletions(-) delete mode 100644 dockerfiles/Dockerfile delete mode 100644 dockerfiles/bin/do_tests.sh delete mode 100644 dockerfiles/bin/generate_builds.sh diff --git a/docker-compose.yml b/docker-compose.yml index d1fc1200..693c447c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,11 +1,19 @@ version: "3.8" services: - busted: - build: - context: . - dockerfile: dockerfiles/Dockerfile - container_name: busted - command: busted --lua=luajit + busted-tests: + image: summ1else/poe-busted-image + container_name: busted-tests + command: bash -c "rm -f spec/test_results.log && busted --lua=luajit > spec/test_results.log" volumes: - - ./:/root \ No newline at end of file + - ./:/root + depends_on: + - busted-generate-build + + busted-generate-build: + image: summ1else/poe-busted-image + container_name: busted-generate-build + command: bash -c "busted --lua=luajit -r generate" + restart: "no" + volumes: + - ./:/root diff --git a/dockerfiles/Dockerfile b/dockerfiles/Dockerfile deleted file mode 100644 index 8e8d25c7..00000000 --- a/dockerfiles/Dockerfile +++ /dev/null @@ -1,46 +0,0 @@ -FROM ubuntu:latest - -# First, ensure that you have development tools installed on your system, otherwise run the command below to install them. -RUN apt update && \ - apt install -y --no-install-recommends \ - build-essential \ - libreadline-dev \ - unzip \ - curl \ - wget \ - git \ - ca-certificates - -RUN cd /home - - -# Then to build and install Lua, run the following commands to download the package tar ball, extract, build and install it. -RUN curl -R -O http://www.lua.org/ftp/lua-5.1.5.tar.gz && \ - tar -zxf lua-5.1.5.tar.gz && \ - cd lua-5.1.5 && \ - make linux test && \ - make install - -# Download and unpack the LuaRocks tarball using following commands. -RUN wget https://luarocks.org/releases/luarocks-3.7.0.tar.gz && \ - tar zxpf luarocks-3.7.0.tar.gz && \ - cd luarocks-3.7.0 && \ - ./configure --with-lua-include=/usr/local/include && \ - make && \ - make install - -# Install luajit -RUN cd /home && \ - git clone https://luajit.org/git/luajit.git && \ - cd luajit \ - make && \ - make install && \ - ln -sf luajit-2.1.0-beta3 /usr/local/bin/luajit - -# Setup test enviroment -RUN luarocks install busted && \ - luarocks install cluacov - -WORKDIR /root - -ENTRYPOINT [] \ No newline at end of file diff --git a/dockerfiles/bin/do_tests.sh b/dockerfiles/bin/do_tests.sh deleted file mode 100644 index 584c7958..00000000 --- a/dockerfiles/bin/do_tests.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -docker-compose up -d -while [ $(docker ps -q -f name=busted) ] -do - sleep 1s -done -LOGS_LENGTH=$(docker logs -f busted | wc -l) -LAST_START=$(docker logs -f busted | grep -n "Loading main script..." | tail -1 | cut -d : -f 1) -docker logs --tail $((LOGS_LENGTH - LAST_START + 1)) -f busted > spec/test_results.log -echo Finished with results: -echo $(grep "[0-9] successes" spec/test_results.log) \ No newline at end of file diff --git a/dockerfiles/bin/generate_builds.sh b/dockerfiles/bin/generate_builds.sh deleted file mode 100644 index 840f3228..00000000 --- a/dockerfiles/bin/generate_builds.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -cd dockerfiles -docker build -t busted:generation -f Dockerfile . -cd .. -docker run -v $(pwd):/root --rm -i busted:generation busted --lua=luajit -r generate \ No newline at end of file From 123166b50e30f4c77e719f76d46d517ccd8f7516 Mon Sep 17 00:00:00 2001 From: Lazarev Date: Fri, 22 Oct 2021 00:22:37 +0300 Subject: [PATCH 07/10] Fixed command --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 693c447c..626e6408 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,7 +13,7 @@ services: busted-generate-build: image: summ1else/poe-busted-image container_name: busted-generate-build - command: bash -c "busted --lua=luajit -r generate" + command: busted --lua=luajit -r generate restart: "no" volumes: - ./:/root From b2414b190f8fe8fb350fa718af6e8dcc795a7509 Mon Sep 17 00:00:00 2001 From: summ1else Date: Thu, 21 Oct 2021 17:47:44 -0500 Subject: [PATCH 08/10] Minor tweak to docker compose and ignore files to be able to view test results during build and to output the test generation logs as well. --- .gitignore | 2 ++ docker-compose.yml | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index abc29753..51786895 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,8 @@ Settings.xml # Testing luajit/ spec/test_results.log +spec/test_generation.log +src/luacov.stats.out # Release manifest-updated.xml diff --git a/docker-compose.yml b/docker-compose.yml index 626e6408..ebb2a04a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,7 +4,7 @@ services: busted-tests: image: summ1else/poe-busted-image container_name: busted-tests - command: bash -c "rm -f spec/test_results.log && busted --lua=luajit > spec/test_results.log" + command: bash -c "rm -f spec/test_results.log && busted --lua=luajit | tee spec/test_results.log" volumes: - ./:/root depends_on: @@ -13,7 +13,7 @@ services: busted-generate-build: image: summ1else/poe-busted-image container_name: busted-generate-build - command: busted --lua=luajit -r generate + command: bash -c "rm -f spec/test_generation.log && busted --lua=luajit -r generate | tee spec/test_generation.log" restart: "no" volumes: - ./:/root From c1c094700c40e8e0fda9f603295fa0a9657cf74d Mon Sep 17 00:00:00 2001 From: SaloEater Date: Fri, 22 Oct 2021 09:39:05 +0300 Subject: [PATCH 09/10] Edit contributing --- CONTRIBUTING.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1807436a..e0e78464 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -117,8 +117,9 @@ More tests can be added to this folder to test specific functionality, or new te Docker alternative: -1. Run `dockerfiles/bin/do_tests.sh` from the command line -2. View last results in `spec/test_results.log` +1. Install [Docker](https://www.docker.com/get-started) +2. Run `docker-compose up -d` from the command line +3. View last results in `spec/test_results.log` ### Creating new test builds or fixing an existing build @@ -130,8 +131,8 @@ Sometimes a change will be made that intends to change the stats garnered by PoB Docker alternative: 1. Add the new build XML (if applicable) to the `TestBuilds` folder -2. Run `dockerfiles/bin/generate_builds.sh` to generate a LUA file that contains the current stats of that build -3. Run `dockerfiles/bin/do_tests.sh` and the tests should pass +2. Run `docker-compose up -d` to generate a LUA file that contains the current stats of that build +3. Run `docker-compose up -d` and the tests should pass ## Keeping your fork up to date From 05e664544042953020ab46f7688e6fee62d553df Mon Sep 17 00:00:00 2001 From: Trevor Lund Date: Thu, 20 Jan 2022 12:18:14 -0600 Subject: [PATCH 10/10] Apply suggestions from code review Co-authored-by: summ1else --- CONTRIBUTING.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e0e78464..cbea1fd4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -131,8 +131,7 @@ Sometimes a change will be made that intends to change the stats garnered by PoB Docker alternative: 1. Add the new build XML (if applicable) to the `TestBuilds` folder -2. Run `docker-compose up -d` to generate a LUA file that contains the current stats of that build -3. Run `docker-compose up -d` and the tests should pass +2. Run `docker-compose up -d` to generate a LUA file that contains the current stats of that build and run the tests ## Keeping your fork up to date