diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 0000000..69f8fe6 --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,61 @@ +name: CI + +on: + push: + branches: + main + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@master + - name: Install Lua + uses: leafo/gh-actions-lua@master + with: + luaVersion: 5.1 + - name: Run test case + run: lua ./tests.lua --Linux --CI + + build: + runs-on: windows-latest # gh-actions-lua doesn't work on windows + steps: + - name: Checkout repo + uses: actions/checkout@master + - name: Download srlua-mingw + run: curl -o srlua.zip "https://raw.githubusercontent.com/joedf/LuaBuilds/gh-pages/hdata/srlua-5.1.5_Win32_bin.zip" + - name: Unzip srlua-mingw + run: | + tar -xf srlua.zip + Rename-Item -Path srglue.exe -NewName glue.exe + - name: Download Lua53 + run: curl -o Lua53.zip "https://raw.githubusercontent.com/joedf/LuaBuilds/gh-pages/hdata/lua-5.3.5_Win64_bin.zip" + - name: Unzip Lua53 + run: | + tar -xf Lua53.zip + - run: dir + - name: Build the project + run: | + ./build.bat + shell: bash + - name: Zip the build + uses: papeloto/action-zip@v1 + with: + files: build/ + dest: build.zip + - name: Load version and name + run: | # I have no idea why but 5.1 just won't work for some reason + echo "prometheus_full_version=$(./lua.exe ./src/config.lua --FullVersion)" >> $GITHUB_ENV + echo "prometheus_version=$(./lua.exe ./src/config.lua --Version)" >> $GITHUB_ENV + shell: bash + - name: Upload binaries to release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: build.zip + asset_name: ${{ env.prometheus_full_version }}.zip + tag: release-${{ github.ref }}-${{ env.prometheus_version }} + release_name: ${{ env.prometheus_version }} + overwrite: true + body: ${{ env.prometheus_full_version }} ${{ github.event.commits[0].message }} \ No newline at end of file diff --git a/src/config.lua b/src/config.lua index 83899a3..c558cc6 100644 --- a/src/config.lua +++ b/src/config.lua @@ -11,6 +11,19 @@ local REVISION = "Alpha"; local VERSION = "v0.2"; local BY = "levno-710"; +for _, currArg in pairs(arg) do + if currArg == "--CI" then + local releaseName = string.gsub(string.format("%s %s %s", NAME, REVISION, VERSION), "%s", "-") + print(releaseName) + return + end + + if currArg == "--FullVersion" then + print(VERSION) + return + end +end + -- Config Starts here return { Name = NAME, diff --git a/tests.lua b/tests.lua index 37f0376..112be1c 100644 --- a/tests.lua +++ b/tests.lua @@ -13,6 +13,7 @@ local Prometheus = require("src.prometheus") local noColors = false; -- Wether Colors in the Console output should be enabled local noHighlight = false; -- Disable Syntax Highlighting of Outputed Code local isWindows = true; -- Wether the Test are Performed on a Windows or Linux System +local ciMode = false; -- Wether the Test error are ignored or not -- The Code to Obfuscate local code = [=[ @@ -23,6 +24,9 @@ for _, currArg in pairs(arg) do if currArg == "--Linux" then isWindows = false end + if currArg == "--CI" then + ciMode = true + end end -- Enable/Disable Console Colors - this may be needed because cmd.exe and powershell.exe do not support ANSI Color Escape Sequences. The Windows Terminal Application is needed @@ -122,6 +126,9 @@ for i, filename in ipairs(scandir(testdir)) do print(Prometheus.colors("[FAILED] ", "red") .. "(" .. filename .. ") " .. step.Name); print("[OUTA] ", outa); print("[OUTB] ", outb); + if ciMode then + error("Test Failed!") + end fc = fc + 1; end end