-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
92 lines (88 loc) · 2.69 KB
/
action.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
name: Love actions for testing
description: Automatic tests for LÖVE based games
branding:
icon: "heart"
color: "gray-dark"
inputs:
font-path:
description: |
Font path
Would be used in font coverage tests
required: false
language-folder:
description: |
Path to the language folder
Would be used in font coverage tests
required: false
love-package:
description: |
Love package
Would be used for gaming logic tests
required: false
default: "./game.love"
source-folder:
description: |
Top folder of the game sources
Would be used to check grammar errors
required: false
default: "."
strict:
description: |
Strict mode
Would fail the tests if font coverage is not 100%
required: false
default: "false"
runs:
using: "composite"
steps:
- name: Install luajit
shell: bash
run: |
sudo apt-get install luajit -y
- name: Check all lua files are valid
shell: luajit {0}
run: |
local files = assert(io.popen "find ${{ inputs.source-folder }} -name '*.lua' -not -path '*/.git/*'")
local errors = 0
for file in files:lines() do
local f, error = loadfile(file)
if not f then
print(error)
errors = errors + 1
end
end
files:close()
if errors > 0 then
print(("%d syntax error(s) found."):format(errors))
os.exit(1)
else
print("No syntax error found.")
end
- name: Prepare FontTools
if: "${{ inputs.font-path != '' && inputs.language-folder != ''}}"
shell: bash
run: |
pip install fonttools
- name: Check all characters are in the font
if: "${{ inputs.font-path != '' && inputs.language-folder != ''}}"
shell: python3 {0}
run: |
from fontTools.ttLib import TTFont
from pathlib import Path
font = TTFont("${{ inputs.font-path }}")
keys = set(font.getBestCmap().keys())
missing = []
for file in Path("${{ inputs.language-folder }}").glob("*.lua"):
for i, line in enumerate(file.read_text().splitlines()):
for char in line:
if ord(char) not in keys:
missing.append((char, file, i+1))
if missing:
print("Missing characters:")
for char, file, i in missing:
print(f"'{char}'({ord(char):x}) in {file} at line {i} " \
f"(${{ github.server_url }}/${{ github.repository }}/blob/${{ github.sha }}/{file}#L{i})")
if "${{ inputs.strict }}" == "true":
exit(1)
else:
print("All characters are present in the font.")