From 62057ed117151695c2740562e57b4f751a42aede Mon Sep 17 00:00:00 2001 From: Philipp Janda Date: Sun, 22 Nov 2020 16:02:44 +0100 Subject: [PATCH] Use the GitHub super linter (#10) --- .github/linters/.markdown-lint.yml | 37 +++++++++ .github/workflows/run-linters.yml | 18 +++++ .github/workflows/run-tests.yml | 5 +- README.md | 4 +- tests/run.sh | 125 ++++++++++++++++++----------- 5 files changed, 138 insertions(+), 51 deletions(-) create mode 100644 .github/linters/.markdown-lint.yml create mode 100644 .github/workflows/run-linters.yml diff --git a/.github/linters/.markdown-lint.yml b/.github/linters/.markdown-lint.yml new file mode 100644 index 0000000..5888963 --- /dev/null +++ b/.github/linters/.markdown-lint.yml @@ -0,0 +1,37 @@ +--- +########################### +########################### +## Markdown Linter rules ## +########################### +########################### + +# Linter rules doc: +# - https://github.com/DavidAnson/markdownlint +# +# Note: +# To comment out a single error: +# +# any violations you want +# +# + +############### +# Rules by id # +############### +MD004: false # Unordered list style +MD007: + indent: 2 # Unordered list indentation +MD013: + line_length: 400 # Line length 80 is far to short +MD026: + punctuation: ".,;:!。,;:" # List of not allowed +MD021: false # Allow centered atx style headers +MD029: false # Ordered list item prefix +MD030: false # Allow spaces after list markers +MD033: false # Allow inline HTML +MD036: false # Emphasis used instead of a heading + +################# +# Rules by tags # +################# +blank_lines: false # Error on blank lines diff --git a/.github/workflows/run-linters.yml b/.github/workflows/run-linters.yml new file mode 100644 index 0000000..9dfd4e4 --- /dev/null +++ b/.github/workflows/run-linters.yml @@ -0,0 +1,18 @@ +name: run-linters +on: + push: + branches: ["master"] + pull_request: +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - uses: github/super-linter@v3 + env: + DEFAULT_BRANCH: master + LOG_LEVEL: NOTICE + GITHUB_TOKEN: ${{ github.token }} + diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 5049315..9a8aadd 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -1,5 +1,8 @@ name: run-tests -on: [push, pull_request] +on: + push: + branches: ["master"] + pull_request: jobs: test: strategy: diff --git a/README.md b/README.md index fc96d67..1054f9f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ +# Amalg -- Amalgamation of Lua Modules/Scripts # + [![Test Status](https://github.com/siffiejoe/lua-amalg/workflows/run-tests/badge.svg)](https://github.com/siffiejoe/lua-amalg/actions?workflow=run-tests) +[![Linter Status](https://github.com/siffiejoe/lua-amalg/workflows/run-linters/badge.svg)](https://github.com/siffiejoe/lua-amalg/actions?workflow=run-linters) -# Amalg -- Amalgamation of Lua Modules/Scripts # ## Introduction ## diff --git a/tests/run.sh b/tests/run.sh index 6c0f824..65d75a1 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -1,90 +1,117 @@ #!/bin/bash -LUAV=$1 -if [ "$1" != 5.1 -a "$1" != 5.2 -a "$1" != 5.3 -a "$1" != 5.4 -a "$1" != "gh" ]; then - LUAV=5.1 -fi - -if [ "$LUAV" == "gh" ]; then - LUAV="" +case "$1" in + 5.[0123456789]*|gh) + LUAV="$1"; shift ;; + *) + LUAV="5.1" ;; +esac + +if [ "$LUAV" = "gh" ]; then + LUA=lua + LUAC=luac INC=../.lua/include set -e -elif [ "$LUAV" == 5.4 ]; then - INC=/home/siffiejoe/.self/programs/lua$LUAV else - INC=/usr/include/lua$LUAV + LUA="lua$LUAV" + LUAC="luac$LUAV" + INC="/usr/include/lua$LUAV" + if [ ! -d "$INC" ]; then + INC="/home/siffiejoe/.self/programs/lua$LUAV" + fi fi +echo -n "Using " +"$LUA" -v + gcc -Wall -Wextra -Os -fpic -I"$INC" -shared -o cmod.so cmod.c gcc -Wall -Wextra -Os -fpic -I"$INC" -shared -o aiomod.so aiomod.c -echo "Using Lua $LUAV ..." -luac$LUAV -o module1.luac module1.lua -luac$LUAV -o module2.luac module2.lua +"$LUAC" -o module1.luac module1.lua +"$LUAC" -o module2.luac module2.lua echo -n "amalgamate modules only ... " -lua$LUAV ../src/amalg.lua -o modules.lua module1 module2 -lua$LUAV -l modules main.lua +"$LUA" ../src/amalg.lua -o modules.lua module1 module2 +"$LUA" -l modules main.lua echo -n "amalgamate modules as fallbacks(1) ... " -lua$LUAV ../src/amalg.lua -f -o fallbacks.lua module1 module2 -lua$LUAV -l fallbacks main.lua +"$LUA" ../src/amalg.lua -f -o fallbacks.lua module1 module2 +"$LUA" -l fallbacks main.lua echo -n "amalgamate modules as fallbacks(2) ... " -lua$LUAV -l fallbacks -e "package.path=''" main.lua +"$LUA" -l fallbacks -e "package.path=''" main.lua echo -n "amalgamate modules and script in text form ... " -lua$LUAV ../src/amalg.lua -o textout.lua -s main.lua module1 module2 -lua$LUAV -e 'package.path=""' textout.lua +"$LUA" ../src/amalg.lua -o textout.lua -s main.lua module1 module2 +"$LUA" -e 'package.path=""' textout.lua echo -n "amalgamate modules and script in binary form ... " -lua$LUAV -e 'package.path = "./?.luac;"..package.path' ../src/amalg.lua -o binout.lua -s main.lua module1 module2 -lua$LUAV -e 'package.path=""' binout.lua +"$LUA" -e 'package.path = "./?.luac;"..package.path' ../src/amalg.lua -o binout.lua -s main.lua module1 module2 +"$LUA" -e 'package.path=""' binout.lua echo -n "amalgamate and transform modules and script(1) ... " -lua$LUAV -e 'package.path = "../src/?.lua;"..package.path' ../src/amalg.lua -o zippedout.lua -s main.lua -t luac -z brieflz module1 module2 && \ -lua$LUAV -e 'package.path=""' zippedout.lua +"$LUA" -e 'package.path = "../src/?.lua;"..package.path' ../src/amalg.lua -o zippedout.lua -s main.lua -t luac -z brieflz module1 module2 && \ +"$LUA" -e 'package.path=""' zippedout.lua echo -n "amalgamate and transform modules and script(2) ... " -lua$LUAV -e 'package.path = "../src/?.lua;"..package.path' ../src/amalg.lua -o dietout.lua -s main.lua -t luasrcdiet module1 module2 && \ -lua$LUAV -e 'package.path=""' dietout.lua +"$LUA" -e 'package.path = "../src/?.lua;"..package.path' ../src/amalg.lua -o dietout.lua -s main.lua -t luasrcdiet module1 module2 && \ +"$LUA" -e 'package.path=""' dietout.lua echo -n "amalgamate and transform in two steps ... " -lua$LUAV ../src/amalg.lua -o- -s main.lua module1 module2 | \ -lua$LUAV -e 'package.path = "../src/?.lua;"..package.path' ../src/amalg.lua -o twosteps.lua -s- -t luasrcdiet -z brieflz && \ -lua$LUAV -e 'package.path=""' twosteps.lua +"$LUA" ../src/amalg.lua -o- -s main.lua module1 module2 | \ +"$LUA" -e 'package.path = "../src/?.lua;"..package.path' ../src/amalg.lua -o twosteps.lua -s- -t luasrcdiet -z brieflz && \ +"$LUA" -e 'package.path=""' twosteps.lua echo -n "amalgamate modules and script without arg fix ... " -lua$LUAV ../src/amalg.lua -o afixout.lua -a -s main.lua module1 module2 -lua$LUAV -e 'package.path=""' afixout.lua +"$LUA" ../src/amalg.lua -o afixout.lua -a -s main.lua module1 module2 +"$LUA" -e 'package.path=""' afixout.lua echo -n "amalgamate modules and script with debug info ... " -lua$LUAV ../src/amalg.lua -o debugout.lua -d -s main.lua module1 module2 -lua$LUAV -e 'package.path=""' debugout.lua +"$LUA" ../src/amalg.lua -o debugout.lua -d -s main.lua module1 module2 +"$LUA" -e 'package.path=""' debugout.lua echo -n "collect module names using amalg.lua as a module ... " -lua$LUAV -e 'package.path = "../src/?.lua;"..package.path' -l amalg main.lua +"$LUA" -e 'package.path = "../src/?.lua;"..package.path' -l amalg main.lua echo -n "amalgamate modules and script using amalg.cache ... " -lua$LUAV ../src/amalg.lua -o cacheout.lua -s main.lua -c -lua$LUAV -e 'package.path=""' cacheout.lua +"$LUA" ../src/amalg.lua -o cacheout.lua -s main.lua -c +"$LUA" -e 'package.path=""' cacheout.lua echo -n "amalgamate Lua modules, Lua script and C modules ... " -lua$LUAV ../src/amalg.lua -o cmodout.lua -s main.lua -c -x -lua$LUAV -e 'package.path,package.cpath="",""' cmodout.lua +"$LUA" ../src/amalg.lua -o cmodout.lua -s main.lua -c -x +"$LUA" -e 'package.path,package.cpath="",""' cmodout.lua echo -n "amalgamate Lua modules, Lua script and C modules compressed ... " -lua$LUAV -e 'package.path = "../src/?.lua;"..package.path' ../src/amalg.lua -o zipcmodout.lua -s main.lua -c -x -t luasrcdiet -z brieflz && \ -lua$LUAV -e 'package.path,package.cpath="",""' zipcmodout.lua +"$LUA" -e 'package.path = "../src/?.lua;"..package.path' ../src/amalg.lua -o zipcmodout.lua -s main.lua -c -x -t luasrcdiet -z brieflz && \ +"$LUA" -e 'package.path,package.cpath="",""' zipcmodout.lua echo -n "amalgamate Lua modules, Lua script and C modules in two steps ... " -lua$LUAV ../src/amalg.lua -o- -s main.lua -c -x | \ -lua$LUAV -e 'package.path = "../src/?.lua;"..package.path' ../src/amalg.lua -o ctwosteps.lua -s- -t luasrcdiet -z brieflz && \ -lua$LUAV -e 'package.path,package.cpath="",""' ctwosteps.lua +"$LUA" ../src/amalg.lua -o- -s main.lua -c -x | \ +"$LUA" -e 'package.path = "../src/?.lua;"..package.path' ../src/amalg.lua -o ctwosteps.lua -s- -t luasrcdiet -z brieflz && \ +"$LUA" -e 'package.path,package.cpath="",""' ctwosteps.lua echo -n "amalgamate Lua modules, but ignore C modules ... " -lua$LUAV ../src/amalg.lua -o ignout.lua -s main.lua -c -x -i '^cmod' -i '^aiomod' -lua$LUAV -e 'package.path=""' ignout.lua - -exit 0 - -rm -f module1.luac module2.luac modules.lua fallbacks.lua textout.lua binout.lua zippedout.lua twosteps.lua dietout.lua afixout.lua debugout.lua cacheout.lua cmodout.lua zipcmodout.lua ctwosteps.lua ignout.lua amalg.cache cmod.so aiomod.so +"$LUA" ../src/amalg.lua -o ignout.lua -s main.lua -c -x -i '^cmod' -i '^aiomod' +"$LUA" -e 'package.path=""' ignout.lua + + +if [ "$1" != keep ]; then + rm -f module1.luac \ + module2.luac \ + modules.lua \ + fallbacks.lua \ + textout.lua \ + binout.lua \ + zippedout.lua \ + twosteps.lua \ + dietout.lua \ + afixout.lua \ + debugout.lua \ + cacheout.lua \ + cmodout.lua \ + zipcmodout.lua \ + ctwosteps.lua \ + ignout.lua \ + amalg.cache \ + cmod.so \ + aiomod.so +fi