Skip to content

Commit 1f8cad9

Browse files
committed
Create workflow
1 parent d743fb1 commit 1f8cad9

16 files changed

+205
-126
lines changed

.codespellrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[codespell]
2+
skip = demo/addons/gut
3+
builtin = en-GB_to_en-US

.gdlintrc

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
class-definitions-order:
2+
- tools
3+
- classnames
4+
- extends
5+
- signals
6+
- enums
7+
- consts
8+
- exports
9+
- pubvars
10+
- prvvars
11+
- onreadypubvars
12+
- onreadyprvvars
13+
- others
14+
class-load-variable-name: (([A-Z][a-z0-9]*)+|_?[a-z][a-z0-9]*(_[a-z0-9]+)*)
15+
class-name: ([A-Z][a-z0-9]*)+
16+
class-variable-name: _?[a-z][a-z0-9]*(_[a-z0-9]+)*
17+
comparison-with-itself: null
18+
constant-name: '[A-Z][A-Z0-9]*(_[A-Z0-9]+)*'
19+
disable: []
20+
duplicated-load: null
21+
enum-element-name: '[A-Z][A-Z0-9]*(_[A-Z0-9]+)*'
22+
enum-name: ([A-Z][a-z0-9]*)+
23+
excluded_directories: !!set
24+
.git: null
25+
expression-not-assigned: null
26+
function-argument-name: _?[a-z][a-z0-9]*(_[a-z0-9]+)*
27+
function-arguments-number: 10
28+
function-name: (_on_([A-Z][a-z0-9]*)+(_[a-z0-9]+)*|_?[a-z][a-z0-9]*(_[a-z0-9]+)*)
29+
function-preload-variable-name: ([A-Z][a-z0-9]*)+
30+
function-variable-name: '[a-z][a-z0-9]*(_[a-z0-9]+)*'
31+
load-constant-name: (([A-Z][a-z0-9]*)+|[A-Z][A-Z0-9]*(_[A-Z0-9]+)*)
32+
loop-variable-name: _?[a-z][a-z0-9]*(_[a-z0-9]+)*
33+
max-file-lines: 1000
34+
max-line-length: 100
35+
max-public-methods: 20
36+
max-returns: 6
37+
mixed-tabs-and-spaces: null
38+
no-elif-return: null
39+
no-else-return: null
40+
private-method-call: null
41+
signal-name: '[a-z][a-z0-9]*(_[a-z0-9]+)*'
42+
sub-class-name: _?([A-Z][a-z0-9]*)+
43+
tab-characters: 1
44+
trailing-whitespace: null
45+
unnecessary-pass: null
46+
unused-argument: null

.github/workflows/master.yml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: 🌟 Master
2+
3+
on:
4+
pull_request:
5+
branches: [master]
6+
7+
jobs:
8+
gdscript:
9+
name: 💅 Linting / 🤖 GDScript
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
- run: pip3 install "gdtoolkit==4.*"
14+
- run: bash -c 'for f in ./demo/addons/json_config_file/**/*.gd; do gdlint "$f"; done'
15+
- run: bash -c 'for f in ./demo/tests/**/*.gd; do gdlint "$f"; done'
16+
17+
spelling:
18+
name: 💅 Linting / 👓 Spelling
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v3
22+
- uses: codespell-project/actions-codespell@v1
23+
24+
unit-testing:
25+
name: 🧪 Unit Testing
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v2
29+
30+
- name: Download Godot
31+
run: |
32+
curl -O https://downloads.tuxfamily.org/godotengine/4.0.2/Godot_v4.0.2-stable_linux.x86_64.zip
33+
unzip Godot_v4.0.2-stable_linux.x86_64.zip
34+
35+
- name: Execute tests
36+
run: |
37+
./Godot_v4.0.2-stable_linux.x86_64 --headless -d -s --path ./demo addons/gut/gut_cmdln.gd
38+
39+
package:
40+
name: 📦 Package
41+
runs-on: ubuntu-latest
42+
steps:
43+
- uses: actions/checkout@v3
44+
45+
- name: Create addon
46+
run: |
47+
mkdir addons
48+
cp -R demo/addons/json_config_file addons
49+
cp LICENSE.md addons/json_config_file
50+
51+
- name: Create package
52+
run: |
53+
zip -r json_config_file.zip addons
54+
55+
- name: Upload addon
56+
uses: actions/upload-artifact@v3
57+
with:
58+
name: json_config_file
59+
path: json_config_file.zip

LICENSE.txt renamed to LICENSE.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
MIT License
2+
13
Copyright (c) 2020 Tomás Espejo Gómez
24

35
Permission is hereby granted, free of charge, to any person obtaining a copy

demo/.gutconfig.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"dirs": [
3+
"res://tests/"
4+
],
5+
"include_subdirs": true,
6+
"selected": "",
7+
"should_exit": true,
8+
"should_maximize": false,
9+
"tests": [],
10+
"unit_test_name": "",
11+
"disabled_colors": true
12+
}

demo/addons/gut/gui/GutSceneTheme.tres

+4-4
Large diffs are not rendered by default.

demo/addons/json_config_file/json_schema.gd

+21-35
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,9 @@ func _add_property(name: StringName, property_script: Script) -> Object:
111111

112112
func add_exclusivity(property_names: Array[StringName], one_is_required := false) -> void:
113113
assert(property_names.all(func(name: StringName) -> bool: return _property_exists(name)))
114-
assert(
115-
property_names.all(
116-
func(name: StringName) -> bool: return _get_property_by_name(name)._required == false
117-
)
118-
)
114+
assert(property_names.all(
115+
func(name: StringName) -> bool: return _get_property_by_name(name)._required == false
116+
))
119117

120118
_exclusivity_relations.append(_ExclusivityRelation.new(property_names, one_is_required))
121119

@@ -220,49 +218,38 @@ func _parse(value: Variant, json_config_file_path := "") -> Dictionary:
220218

221219

222220
static func _not_allowed_property_error(property: StringName) -> _ValidationMsg:
223-
return (
224-
_ValidationMsg
225-
. new_error(
226-
_type_name + ":not_allowed_property",
227-
"Unkown property: '%s', this property is not allowed" % property,
228-
{"property": property},
229-
)
221+
return _ValidationMsg.new_error(
222+
_type_name + ":not_allowed_property",
223+
"Unkown property: '%s', this property is not allowed" % property,
224+
{"property": property},
230225
)
231226

232227

233228
static func _required_property_error(property: StringName) -> _ValidationMsg:
234-
return (
235-
_ValidationMsg
236-
. new_error(
237-
_type_name + ":required_property",
238-
"Missing property: '%s', this property is required" % property,
239-
{"property": property},
240-
)
229+
return _ValidationMsg.new_error(
230+
_type_name + ":required_property",
231+
"Missing property: '%s', this property is required" % property,
232+
{"property": property},
241233
)
242234

243235

244236
static func _required_dependent_property_error(
245237
main_property: StringName, dependent_property: StringName
246238
) -> _ValidationMsg:
247-
return (
248-
_ValidationMsg
249-
. new_error(
250-
_type_name + ":required_dependent_property",
251-
(
252-
"Missing property: '%s', this property is required if '%s' has been specified"
253-
% [dependent_property, main_property]
254-
),
255-
{"main_property": main_property, "dependent_property": dependent_property},
256-
)
239+
return _ValidationMsg.new_error(
240+
_type_name + ":required_dependent_property",
241+
"Missing property: '%s', this property is required if '%s' has been specified" % [
242+
dependent_property, main_property
243+
],
244+
{"main_property": main_property, "dependent_property": dependent_property},
257245
)
258246

259247

260248
static func _one_property_is_required_error(properties: Array[StringName]) -> _ValidationMsg:
261249
return _ValidationMsg.new_error(
262250
_type_name + ":one_property_is_required",
263-
(
264-
"One of this properties needs to be specified: %s"
265-
% _ValidationMsg._array_as_text(properties)
251+
"One of this properties needs to be specified: %s" % _ValidationMsg._array_as_text(
252+
properties
266253
),
267254
{"properties": properties}
268255
)
@@ -271,9 +258,8 @@ static func _one_property_is_required_error(properties: Array[StringName]) -> _V
271258
static func _exclusive_properties_error(properties: Array[StringName]) -> _ValidationMsg:
272259
return _ValidationMsg.new_error(
273260
_type_name + ":exclusive_properties",
274-
(
275-
"This properties can not be defined at the same time: %s"
276-
% _ValidationMsg._array_as_text(properties)
261+
"This properties can not be defined at the same time: %s" % _ValidationMsg._array_as_text(
262+
properties
277263
),
278264
{"properties": properties}
279265
)

demo/addons/json_config_file/scripts/validation_msg.gd

+6-10
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ static func new_warning(code: StringName, message: String, info: Dictionary) ->
3434
func as_text() -> String:
3535
if context_levels.is_empty():
3636
return message + "."
37-
else:
38-
return message + ", at '" + _context_as_text() + "'."
37+
return message + ", at '" + _context_as_text() + "'."
3938

4039

4140
func _context_as_text() -> String:
@@ -65,14 +64,11 @@ func _to_string() -> String:
6564

6665

6766
static func _wrong_type_error(type: String) -> ValidationMsg:
68-
return (
69-
ValidationMsg
70-
. new(
71-
Importance.ERROR,
72-
"wrong_type",
73-
"Wrong type: expected '%s'" % type,
74-
{"type": type},
75-
)
67+
return ValidationMsg.new(
68+
Importance.ERROR,
69+
"wrong_type",
70+
"Wrong type: expected '%s'" % type,
71+
{"type": type},
7672
)
7773

7874

demo/addons/json_config_file/scripts/validators/enum_validator.gd

+4-7
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,8 @@ func _parse(value: Variant) -> int:
3030

3131

3232
static func _not_valid_value(value: String) -> _ValidationMsg:
33-
return (
34-
_ValidationMsg
35-
. new_error(
36-
_type_name + ":not_valid_value",
37-
"'%s' is not a valid value" % [value],
38-
{"value": value},
39-
)
33+
return _ValidationMsg.new_error(
34+
_type_name + ":not_valid_value",
35+
"'%s' is not a valid value" % [value],
36+
{"value": value},
4037
)

demo/addons/json_config_file/scripts/validators/file_access_validator.gd

+6-9
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,12 @@ func _valid_mode_flags(mode_flags: int) -> bool:
126126

127127

128128
func _valid_compression_mode(compression_mode: int) -> bool:
129-
return (
130-
[
131-
FileAccess.COMPRESSION_FASTLZ,
132-
FileAccess.COMPRESSION_DEFLATE,
133-
FileAccess.COMPRESSION_ZSTD,
134-
FileAccess.COMPRESSION_GZIP
135-
]
136-
. has(compression_mode)
137-
)
129+
return [
130+
FileAccess.COMPRESSION_FASTLZ,
131+
FileAccess.COMPRESSION_DEFLATE,
132+
FileAccess.COMPRESSION_ZSTD,
133+
FileAccess.COMPRESSION_GZIP
134+
].has(compression_mode)
138135

139136

140137
func _validate(value: Variant, json_config_file_path: String) -> Array[_ValidationMsg]:

demo/addons/json_config_file/scripts/validators/float_validator.gd

+8-14
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,16 @@ func _parse(value: Variant) -> float:
4444

4545

4646
static func _less_than_min_error(value: float, min: float) -> _ValidationMsg:
47-
return (
48-
_ValidationMsg
49-
. new_error(
50-
_type_name + ":less_than_min",
51-
"%s is less than the minimum allowed (%s)" % [value, min],
52-
{"value": value, "min": min},
53-
)
47+
return _ValidationMsg.new_error(
48+
_type_name + ":less_than_min",
49+
"%s is less than the minimum allowed (%s)" % [value, min],
50+
{"value": value, "min": min},
5451
)
5552

5653

5754
static func _more_than_max_error(value: float, max: float) -> _ValidationMsg:
58-
return (
59-
_ValidationMsg
60-
. new_error(
61-
_type_name + ":more_than_max",
62-
"%s is more than the maximum allowed (%s)" % [value, max],
63-
{"value": value, "max": max},
64-
)
55+
return _ValidationMsg.new_error(
56+
_type_name + ":more_than_max",
57+
"%s is more than the maximum allowed (%s)" % [value, max],
58+
{"value": value, "max": max},
6559
)

demo/addons/json_config_file/scripts/validators/int_validator.gd

+8-14
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,16 @@ func _parse(value: Variant) -> int:
4747

4848

4949
static func _less_than_min_error(value: int, min: int) -> _ValidationMsg:
50-
return (
51-
_ValidationMsg
52-
. new_error(
53-
_type_name + ":less_than_min",
54-
"%d is less than the minimum allowed (%d)" % [value, min],
55-
{"value": value, "min": min},
56-
)
50+
return _ValidationMsg.new_error(
51+
_type_name + ":less_than_min",
52+
"%d is less than the minimum allowed (%d)" % [value, min],
53+
{"value": value, "min": min},
5754
)
5855

5956

6057
static func _more_than_max_error(value: int, max: int) -> _ValidationMsg:
61-
return (
62-
_ValidationMsg
63-
. new_error(
64-
_type_name + ":more_than_max",
65-
"%d is more than the maximum allowed (%d)" % [value, max],
66-
{"value": value, "max": max},
67-
)
58+
return _ValidationMsg.new_error(
59+
_type_name + ":more_than_max",
60+
"%d is more than the maximum allowed (%d)" % [value, max],
61+
{"value": value, "max": max},
6862
)

demo/addons/json_config_file/scripts/validators/string_validator.gd

+12-21
Original file line numberDiff line numberDiff line change
@@ -57,33 +57,24 @@ func _parse(value: Variant) -> String:
5757

5858

5959
static func _shorter_than_min_error(value: String, min_length: int) -> _ValidationMsg:
60-
return (
61-
_ValidationMsg
62-
. new_error(
63-
_type_name + ":shorter_than_min",
64-
"'%s's length is shorter than the minimum length allowed (%d)" % [value, min_length],
65-
{"value": value, "min_length": min_length},
66-
)
60+
return _ValidationMsg.new_error(
61+
_type_name + ":shorter_than_min",
62+
"'%s's length is shorter than the minimum length allowed (%d)" % [value, min_length],
63+
{"value": value, "min_length": min_length},
6764
)
6865

6966

7067
static func _longer_than_max_error(value: String, max_length: int) -> _ValidationMsg:
71-
return (
72-
_ValidationMsg
73-
. new_error(
74-
_type_name + ":longer_than_max",
75-
"'%s's length is longer than the maximum length allowed (%d)" % [value, max_length],
76-
{"value": value, "max_length": max_length},
77-
)
68+
return _ValidationMsg.new_error(
69+
_type_name + ":longer_than_max",
70+
"'%s's length is longer than the maximum length allowed (%d)" % [value, max_length],
71+
{"value": value, "max_length": max_length},
7872
)
7973

8074

8175
static func _unmatched_pattern_error(value: String, pattern: String) -> _ValidationMsg:
82-
return (
83-
_ValidationMsg
84-
. new_error(
85-
_type_name + ":unmatched_pattern",
86-
"'%s' does not match the specified pattern: /%s/" % [value, pattern],
87-
{"value": value, "pattern": pattern},
88-
)
76+
return _ValidationMsg.new_error(
77+
_type_name + ":unmatched_pattern",
78+
"'%s' does not match the specified pattern: /%s/" % [value, pattern],
79+
{"value": value, "pattern": pattern},
8980
)

0 commit comments

Comments
 (0)