-
Notifications
You must be signed in to change notification settings - Fork 0
124 lines (119 loc) · 3.47 KB
/
lua.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
---
#
# .github/workflows/lua.yml
#
name: Lua Workflow
on: # yamllint disable-line rule:truthy
pull_request:
defaults:
run:
shell: bash
jobs:
stage1:
name: Change Check
runs-on: 'ubuntu-latest'
outputs:
docs_changed: ${{ steps.check_file_changed.outputs.docs_changed }}
steps:
- name: Checkout Repo
id: checkout-repo
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.ref }}
submodules: recursive
- name: Get Change List
id: check_file_changed
run: |
# Diff HEAD with the previous commit then output to stdout.
printf "=== Which files changed? ===\n"
GIT_DIFF="$(git diff --name-only HEAD^ HEAD)"
printf "%s\n" "${GIT_DIFF}"
printf "\n"
# Check if the files are present in the changed file list (added, modified, deleted) then output to stdout.
HAS_DIFF=false
printf "=== Which Lua files changed? ===\n"
if printf "%s\n" "${GIT_DIFF}" | grep -E '^(lua/.*[.]lua|.github/workflows/lua.yml)$'; then
HAS_DIFF=true
fi
printf "\n"
# Did Golang files change?
printf "=== Did Golang files change? ===\n"
printf "%s\n" "${HAS_DIFF}"
printf "\n"
# Set the output named "docs_changed"
printf "%s=%s\n" "docs_changed" "${HAS_DIFF}" >> "${GITHUB_OUTPUT}"
stage2:
name: Lua Checks
strategy:
matrix:
luaVersion: ["5.4"]
os: ["ubuntu-latest"]
runs-on: "${{ matrix.os }}"
needs: [stage1]
if: needs.stage1.outputs.docs_changed == 'True'
steps:
- name: Checkout Repo
id: checkout-repo
uses: actions/checkout@v3
- name: Set up Lua
id: setup-lua
uses: leafo/gh-actions-lua@v9
with:
luaVersion: ${{ matrix.luaVersion }}
- name: Show Lua Versions
id: lua-version
run: |
which lua
lua -v
ls .lua/bin
- name: Setup Lua-Rocks
id: setup-lua-rocks
uses: leafo/gh-actions-luarocks@v4
- name: Show Lua-Rocks Versions
id: luarocks-version
run: |
which luarocks
luarocks --version
ls .luarocks/bin
- name: Install Lua Tools
id: install-lua-tools
run: |
luarocks install luacheck
luarocks install busted
luarocks install luacov
luarocks install luacov-console
- name: Show Lua Tool Versions
id: lua-tool-versions
run: |
luacheck -v
busted --version
luacov -h | head -n 1
luacov-console --version
- name: CD to Lua Dir
id: cd-to-lua-dir
run: |
pwd
ls
cd ./lua
pwd
ls
- name: Analysing the code with lua-check
id: lua-lint
run: |
cd ./lua
./for_each luacheck . --exclude-files '*_spec.lua'
- name: Testing with Lua test
id: lua-test-run
run: |
cd ./lua
./for_each rm -fv luacov.report.out luacov.report.out.index luacov.stats.out
./for_each busted --coverage --lpath="" --cpath="" --output=gtest -Xoutput --color
- name: Coverage Report
id: lua-coverage-report
run: |-
cd ./lua
./for_each luacov .
./for_each luacov-console .
./for_each luacov-console --summary .
git status .