Skip to content

Commit

Permalink
Merge pull request #11 from Ismoh/unit-testing
Browse files Browse the repository at this point in the history
Unit testing
  • Loading branch information
Ismoh authored Dec 17, 2021
2 parents 42a6070 + 68c02bc commit c0f17a5
Show file tree
Hide file tree
Showing 13 changed files with 3,531 additions and 200 deletions.
8 changes: 0 additions & 8 deletions .github/workflows/adjust_package_paths.lua

This file was deleted.

23 changes: 0 additions & 23 deletions .github/workflows/adjust_package_paths.sh

This file was deleted.

110 changes: 22 additions & 88 deletions .github/workflows/lua-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,113 +12,47 @@ jobs:
steps:
- uses: actions/checkout@main

- name: Install lua 5.1.5
- name: Install luaJIT 2.0.4
#if: ${{ false }} to disable a step
run: |
################ install lua manually: https://github.com/luarocks/luarocks/wiki/Installation-instructions-for-Unix
echo "> sudo apt install build-essential libreadline-dev unzip"
sudo apt install build-essential libreadline-dev unzip
echo "> curl -R -O http://www.lua.org/ftp/lua-5.1.5.tar.gz"
curl -R -O http://www.lua.org/ftp/lua-5.1.5.tar.gz
echo "> tar -zxf lua-5.1.5.tar.gz"
tar -zxf lua-5.1.5.tar.gz
echo "> cd lua-5.1.5"
cd lua-5.1.5
echo "> make linux test"
make linux test
echo "> make install INSTALL_TOP=${{ github.workspace }}/lua51"
make install INSTALL_TOP=${{ github.workspace }}/lua51
cd ${{ github.workspace }}/.building/LuaJIT-2.0.4
make PREFIX=${{ github.workspace }}/luajit
make install PREFIX=${{ github.workspace }}/luajit
echo "> ls -R ${{ github.workspace }}/lua51"
ls -R ${{ github.workspace }}/lua51
- name: Run LuaUnit 3.4
run: |
######## copy luaunit.lua to package directory, because I don't want to mess around with lua pathes again
cp ${{ github.workspace }}/.testing/luaunit.lua ${{ github.workspace }}/luajit/share/lua/5.1/
######## run all lua test files with one command: https://stackoverflow.com/a/10523492/3493998
sudo find ${{ github.workspace }}/.testing/tests -name "*.lua" -type f -exec ${{ github.workspace }}/luajit/bin/luajit {} -o text --verbose --failure --error \; > ${{ github.workspace }}/.testing/testresult.log
cat ${{ github.workspace }}/.testing/testresult.log
- name: Install luarocks 3.8.0
run: |
################ install lua rocks manually: https://github.com/luarocks/luarocks/wiki/Installation-instructions-for-Unix
echo "> wget https://luarocks.github.io/luarocks/releases/luarocks-3.8.0.tar.gz"
######## install lua rocks manually: https://github.com/luarocks/luarocks/wiki/Installation-instructions-for-Unix
wget https://luarocks.github.io/luarocks/releases/luarocks-3.8.0.tar.gz
echo "> tar zxpf luarocks-3.8.0.tar.gz"
tar zxpf luarocks-3.8.0.tar.gz
echo "> cd luarocks-3.8.0"
cd luarocks-3.8.0
echo "> ./configure --prefix=${{ github.workspace }}/luarocks --with-lua-include=${{ github.workspace }}/lua51/include --with-lua=${{ github.workspace }}/lua51"
./configure --prefix=${{ github.workspace }}/luarocks --with-lua-include=${{ github.workspace }}/lua51/include --with-lua=${{ github.workspace }}/lua51
echo "> make"
######## set luajit pathes to luarocks
./configure --prefix=${{ github.workspace }}/luarocks --with-lua=${{ github.workspace }}/luajit --with-lua-include=${{ github.workspace }}/luajit/include/luajit-2.0 --with-lua-lib=${{ github.workspace }}/luajit/lib
make
echo "> make install"
make install
echo "> ls -R ${{ github.workspace }}/luarocks"
ls -R ${{ github.workspace }}/luarocks
- name: Install dependencies
run: |
echo "> luarocks install luacov"
${{ github.workspace }}/luarocks/bin/luarocks install luacov
echo "> luarocks install busted"
${{ github.workspace }}/luarocks/bin/luarocks install busted
echo "> luarocks install --server=https://luarocks.org/dev luaffi"
${{ github.workspace }}/luarocks/bin/luarocks install --server=https://luarocks.org/dev luaffi
#echo "> luarocks install luasystem" # https://githubmemory.com/repo/Olivine-Labs/busted/issues/650
#${{ github.workspace }}/luarocks/bin/luarocks install luasystem
######## Use --tree to define the installation path of the module, which is luajit/share/lua/5.1/ although only the 'root' directory is set
${{ github.workspace }}/luarocks/bin/luarocks --tree=${{ github.workspace }}/luajit install luacov
echo "> ls -R ${{ github.workspace }}/luarocks"
ls -R ${{ github.workspace }}/luarocks
- name: Install luaJIT 2.0.4
#if: ${{ false }} # https://code-maven.com/slides/github-ci/disable-step-in-github-action
run: |
echo "> cd ${{ github.workspace }}/.building/LuaJIT-2.0.4"
cd ${{ github.workspace }}/.building/LuaJIT-2.0.4
echo "> make PREFIX=${{ github.workspace }}/luajit"
make PREFIX=${{ github.workspace }}/luajit
echo "> make install PREFIX=${{ github.workspace }}/luajit"
make install PREFIX=${{ github.workspace }}/luajit
echo "> ls -R ${{ github.workspace }}/luajit"
ls -R ${{ github.workspace }}/luajit
- name: Generate coverage report with busted and luacov
- name: Generate coverage report with luacov
run: |
# Go back to workspace dir of runner, otherwise busted won't find spec dir oder *_spec files
echo "> cd ${{ github.workspace }}"
cd ${{ github.workspace }}
sudo chmod 744 ${{ github.workspace }}/.github/workflows/adjust_package_paths.sh
ls -lsa ${{ github.workspace }}/.github/workflows/
echo "> ${{ github.workspace }}/.github/workflows/adjust_package_paths.sh"
${{ github.workspace }}/.github/workflows/adjust_package_paths.sh
sudo chmod 744 ${{ github.workspace }}/.github/workflows/return_lua_path.sh
echo "LUA_PATH=$(${{ github.workspace }}/.github/workflows/return_lua_path.sh)" >> $GITHUB_ENV
sudo chmod 744 ${{ github.workspace }}/.github/workflows/return_lua_cpath.sh
echo "LUA_CPATH=$(${{ github.workspace }}/.github/workflows/return_lua_cpath.sh)" >> $GITHUB_ENV
echo "> ${{ github.workspace }}/luarocks/bin/busted --lua=${{ github.workspace }}/luajit/bin/luajit --lpath=${{ env.LUA_PATH }} --cpath=${{ env.LUA_CPATH }} -v -o utfTerminal"
${{ github.workspace }}/luarocks/bin/busted --lua=${{ github.workspace }}/luajit/bin/luajit --lpath=${{ env.LUA_PATH }} --cpath=${{ env.LUA_CPATH }} -v -o utfTerminal
echo "> luacov ./spec/luacov/.luacov"
${{ github.workspace }}/luarocks/bin/luacov ./spec/luacov/.luacov
sudo find ${{ github.workspace }}/.testing/tests -name "*.lua" -type f -exec ${{ github.workspace }}/luajit/bin/luajit -lluacov {} \;
${{ github.workspace }}/luajit/bin/luacov
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: ./spec/luacov/luacov.report.out
path_to_write_report: ./coverage/codecov_report.txt
directory: ${{ github.workspace }}
#path_to_write_report: ./codecov_report.txt https://github.com/codecov/codecov-action/issues/476
verbose: true

11 changes: 0 additions & 11 deletions .github/workflows/return_lua_cpath.sh

This file was deleted.

14 changes: 0 additions & 14 deletions .github/workflows/return_lua_path.sh

This file was deleted.

Loading

0 comments on commit c0f17a5

Please sign in to comment.