Skip to content

Commit efb0f66

Browse files
author
pnlmon
committed
CI Workflow
1 parent 882f13a commit efb0f66

File tree

3 files changed

+81
-0
lines changed

3 files changed

+81
-0
lines changed

.github/workflows/CI.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
main
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout repo
13+
uses: actions/checkout@master
14+
- name: Install Lua
15+
uses: leafo/gh-actions-lua@master
16+
with:
17+
luaVersion: 5.1
18+
- name: Run test case
19+
run: lua ./tests.lua --Linux --CI
20+
21+
build:
22+
runs-on: windows-latest # gh-actions-lua doesn't work on windows
23+
steps:
24+
- name: Checkout repo
25+
uses: actions/checkout@master
26+
- name: Download srlua-mingw
27+
run: curl -o srlua.zip "https://raw.githubusercontent.com/joedf/LuaBuilds/gh-pages/hdata/srlua-5.1.5_Win32_bin.zip"
28+
- name: Unzip srlua-mingw
29+
run: |
30+
tar -xf srlua.zip
31+
Rename-Item -Path srglue.exe -NewName glue.exe
32+
- name: Download Lua53
33+
run: curl -o Lua53.zip "https://raw.githubusercontent.com/joedf/LuaBuilds/gh-pages/hdata/lua-5.3.5_Win64_bin.zip"
34+
- name: Unzip Lua53
35+
run: |
36+
tar -xf Lua53.zip
37+
- run: dir
38+
- name: Build the project
39+
run: |
40+
./build.bat
41+
shell: bash
42+
- name: Zip the build
43+
uses: papeloto/action-zip@v1
44+
with:
45+
files: build/
46+
dest: build.zip
47+
- name: Load version and name
48+
run: | # I have no idea why but 5.1 just won't work for some reason
49+
echo "prometheus_full_version=$(./lua.exe ./src/config.lua --FullVersion)" >> $GITHUB_ENV
50+
echo "prometheus_version=$(./lua.exe ./src/config.lua --Version)" >> $GITHUB_ENV
51+
shell: bash
52+
- name: Upload binaries to release
53+
uses: svenstaro/upload-release-action@v2
54+
with:
55+
repo_token: ${{ secrets.GITHUB_TOKEN }}
56+
file: build.zip
57+
asset_name: ${{ env.prometheus_full_version }}.zip
58+
tag: release-${{ github.ref }}-${{ env.prometheus_version }}
59+
release_name: ${{ env.prometheus_version }}
60+
overwrite: true
61+
body: ${{ env.prometheus_full_version }} ${{ github.event.commits[0].message }}

src/config.lua

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,19 @@ local REVISION = "Alpha";
1111
local VERSION = "v0.2";
1212
local BY = "levno-710";
1313

14+
for _, currArg in pairs(arg) do
15+
if currArg == "--CI" then
16+
local releaseName = string.gsub(string.format("%s %s %s", NAME, REVISION, VERSION), "%s", "-")
17+
print(releaseName)
18+
return
19+
end
20+
21+
if currArg == "--FullVersion" then
22+
print(VERSION)
23+
return
24+
end
25+
end
26+
1427
-- Config Starts here
1528
return {
1629
Name = NAME,

tests.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ local Prometheus = require("src.prometheus")
1313
local noColors = false; -- Wether Colors in the Console output should be enabled
1414
local noHighlight = false; -- Disable Syntax Highlighting of Outputed Code
1515
local isWindows = true; -- Wether the Test are Performed on a Windows or Linux System
16+
local ciMode = false; -- Wether the Test error are ignored or not
1617

1718
-- The Code to Obfuscate
1819
local code = [=[
@@ -23,6 +24,9 @@ for _, currArg in pairs(arg) do
2324
if currArg == "--Linux" then
2425
isWindows = false
2526
end
27+
if currArg == "--CI" then
28+
ciMode = true
29+
end
2630
end
2731

2832
-- 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
122126
print(Prometheus.colors("[FAILED] ", "red") .. "(" .. filename .. ") " .. step.Name);
123127
print("[OUTA] ", outa);
124128
print("[OUTB] ", outb);
129+
if ciMode then
130+
error("Test Failed!")
131+
end
125132
fc = fc + 1;
126133
end
127134
end

0 commit comments

Comments
 (0)