actions-tools 0.0.2__tar.gz → 0.0.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of actions-tools might be problematic. Click here for more details.
- {actions_tools-0.0.2 → actions_tools-0.0.3}/PKG-INFO +12 -13
- {actions_tools-0.0.2 → actions_tools-0.0.3}/README.md +11 -12
- {actions_tools-0.0.2 → actions_tools-0.0.3}/src/actions/core.py +45 -26
- {actions_tools-0.0.2 → actions_tools-0.0.3}/src/actions_tools.egg-info/PKG-INFO +12 -13
- {actions_tools-0.0.2 → actions_tools-0.0.3}/tests/test_all.py +9 -7
- {actions_tools-0.0.2 → actions_tools-0.0.3}/LICENSE +0 -0
- {actions_tools-0.0.2 → actions_tools-0.0.3}/pyproject.toml +0 -0
- {actions_tools-0.0.2 → actions_tools-0.0.3}/setup.cfg +0 -0
- {actions_tools-0.0.2 → actions_tools-0.0.3}/src/actions/__init__.py +0 -0
- {actions_tools-0.0.2 → actions_tools-0.0.3}/src/actions_tools.egg-info/SOURCES.txt +0 -0
- {actions_tools-0.0.2 → actions_tools-0.0.3}/src/actions_tools.egg-info/dependency_links.txt +0 -0
- {actions_tools-0.0.2 → actions_tools-0.0.3}/src/actions_tools.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: actions-tools
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.3
|
|
4
4
|
Summary: GitHub Actions Tools for Python
|
|
5
5
|
Author: Shane
|
|
6
6
|
License: GPL-3.0
|
|
@@ -21,6 +21,7 @@ Requires-Python: >=3.10
|
|
|
21
21
|
Description-Content-Type: text/markdown
|
|
22
22
|
License-File: LICENSE
|
|
23
23
|
|
|
24
|
+
[](https://github.com/cssnr/actions-tools/actions/workflows/publish.yaml)
|
|
24
25
|
[](https://github.com/cssnr/actions-tools/actions/workflows/release.yaml)
|
|
25
26
|
[](https://github.com/cssnr/actions-tools/actions/workflows/test.yaml)
|
|
26
27
|
[](https://github.com/cssnr/actions-tools/actions/workflows/lint.yaml)
|
|
@@ -28,8 +29,8 @@ License-File: LICENSE
|
|
|
28
29
|
[](https://sonarcloud.io/summary/new_code?id=cssnr_actions-tools)
|
|
29
30
|
[](https://pypi.org/project/actions-tools/)
|
|
30
31
|
[](https://github.com/cssnr/actions-tools/releases/latest)
|
|
31
|
-
[](https://github.com/cssnr/actions-tools)
|
|
32
32
|
[](https://github.com/cssnr/actions-tools)
|
|
33
|
+
[](https://github.com/cssnr/actions-tools)
|
|
33
34
|
[](https://github.com/cssnr/actions-tools/graphs/commit-activity)
|
|
34
35
|
[](https://github.com/cssnr/actions-tools/stargazers)
|
|
35
36
|
[](https://cssnr.github.io/)
|
|
@@ -76,11 +77,9 @@ Functionality from @actions/toolkit
|
|
|
76
77
|
from actions import core
|
|
77
78
|
|
|
78
79
|
# Input
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
myBoolean = core.get_input('myBoolean', boolean=1)
|
|
83
|
-
myList = core.get_input('myList', split="[,|\n]")
|
|
80
|
+
my_str = core.get_input('string')
|
|
81
|
+
my_bool = core.get_bool('boolean')
|
|
82
|
+
my_list = core.get_list('list')
|
|
84
83
|
|
|
85
84
|
# Logging
|
|
86
85
|
core.info("info") # alias for print
|
|
@@ -92,12 +91,12 @@ core.warn("warn")
|
|
|
92
91
|
core.error("error")
|
|
93
92
|
|
|
94
93
|
# Blocks
|
|
95
|
-
core.start_group("
|
|
94
|
+
core.start_group("Title")
|
|
96
95
|
core.info('This is folded.')
|
|
97
96
|
core.end_group()
|
|
98
97
|
|
|
99
|
-
with core.
|
|
100
|
-
|
|
98
|
+
with core.group("Title") as p:
|
|
99
|
+
p('This is folded.')
|
|
101
100
|
core.info('Also folded.')
|
|
102
101
|
|
|
103
102
|
# Summary
|
|
@@ -107,8 +106,8 @@ core.summary('## Test Action')
|
|
|
107
106
|
core.set_env('NAME', 'value')
|
|
108
107
|
|
|
109
108
|
# State
|
|
110
|
-
|
|
111
|
-
|
|
109
|
+
name = core.set_state('name', 'value')
|
|
110
|
+
value = core.get_state('name')
|
|
112
111
|
|
|
113
112
|
# System Path
|
|
114
113
|
core.add_path('/dev/null')
|
|
@@ -129,7 +128,7 @@ from actions import core
|
|
|
129
128
|
core.command('warning', 'Warned!')
|
|
130
129
|
|
|
131
130
|
# Random
|
|
132
|
-
|
|
131
|
+
rand = core.get_random(32)
|
|
133
132
|
|
|
134
133
|
# Indent
|
|
135
134
|
core.start_indent(4)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
[](https://github.com/cssnr/actions-tools/actions/workflows/publish.yaml)
|
|
1
2
|
[](https://github.com/cssnr/actions-tools/actions/workflows/release.yaml)
|
|
2
3
|
[](https://github.com/cssnr/actions-tools/actions/workflows/test.yaml)
|
|
3
4
|
[](https://github.com/cssnr/actions-tools/actions/workflows/lint.yaml)
|
|
@@ -5,8 +6,8 @@
|
|
|
5
6
|
[](https://sonarcloud.io/summary/new_code?id=cssnr_actions-tools)
|
|
6
7
|
[](https://pypi.org/project/actions-tools/)
|
|
7
8
|
[](https://github.com/cssnr/actions-tools/releases/latest)
|
|
8
|
-
[](https://github.com/cssnr/actions-tools)
|
|
9
9
|
[](https://github.com/cssnr/actions-tools)
|
|
10
|
+
[](https://github.com/cssnr/actions-tools)
|
|
10
11
|
[](https://github.com/cssnr/actions-tools/graphs/commit-activity)
|
|
11
12
|
[](https://github.com/cssnr/actions-tools/stargazers)
|
|
12
13
|
[](https://cssnr.github.io/)
|
|
@@ -53,11 +54,9 @@ Functionality from @actions/toolkit
|
|
|
53
54
|
from actions import core
|
|
54
55
|
|
|
55
56
|
# Input
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
myBoolean = core.get_input('myBoolean', boolean=1)
|
|
60
|
-
myList = core.get_input('myList', split="[,|\n]")
|
|
57
|
+
my_str = core.get_input('string')
|
|
58
|
+
my_bool = core.get_bool('boolean')
|
|
59
|
+
my_list = core.get_list('list')
|
|
61
60
|
|
|
62
61
|
# Logging
|
|
63
62
|
core.info("info") # alias for print
|
|
@@ -69,12 +68,12 @@ core.warn("warn")
|
|
|
69
68
|
core.error("error")
|
|
70
69
|
|
|
71
70
|
# Blocks
|
|
72
|
-
core.start_group("
|
|
71
|
+
core.start_group("Title")
|
|
73
72
|
core.info('This is folded.')
|
|
74
73
|
core.end_group()
|
|
75
74
|
|
|
76
|
-
with core.
|
|
77
|
-
|
|
75
|
+
with core.group("Title") as p:
|
|
76
|
+
p('This is folded.')
|
|
78
77
|
core.info('Also folded.')
|
|
79
78
|
|
|
80
79
|
# Summary
|
|
@@ -84,8 +83,8 @@ core.summary('## Test Action')
|
|
|
84
83
|
core.set_env('NAME', 'value')
|
|
85
84
|
|
|
86
85
|
# State
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
name = core.set_state('name', 'value')
|
|
87
|
+
value = core.get_state('name')
|
|
89
88
|
|
|
90
89
|
# System Path
|
|
91
90
|
core.add_path('/dev/null')
|
|
@@ -106,7 +105,7 @@ from actions import core
|
|
|
106
105
|
core.command('warning', 'Warned!')
|
|
107
106
|
|
|
108
107
|
# Random
|
|
109
|
-
|
|
108
|
+
rand = core.get_random(32)
|
|
110
109
|
|
|
111
110
|
# Indent
|
|
112
111
|
core.start_indent(4)
|
|
@@ -3,14 +3,14 @@ import random
|
|
|
3
3
|
import re
|
|
4
4
|
import string
|
|
5
5
|
from contextlib import contextmanager
|
|
6
|
-
from typing import
|
|
6
|
+
from typing import List, Optional
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
_true = ["y", "yes", "true", "on"]
|
|
13
|
+
_false = ["n", "no", "false", "off"]
|
|
14
14
|
|
|
15
15
|
_indent = 0
|
|
16
16
|
_endtoken = ""
|
|
@@ -61,7 +61,7 @@ def end_group():
|
|
|
61
61
|
|
|
62
62
|
|
|
63
63
|
@contextmanager
|
|
64
|
-
def
|
|
64
|
+
def group(title: str):
|
|
65
65
|
print(f"::group::{title}")
|
|
66
66
|
try:
|
|
67
67
|
yield info
|
|
@@ -134,39 +134,58 @@ def summary(text: str, nlc=1):
|
|
|
134
134
|
# Inputs
|
|
135
135
|
|
|
136
136
|
|
|
137
|
-
def get_input(name: str, req=False, low=False, strip=True
|
|
137
|
+
def get_input(name: str, req=False, low=False, strip=True) -> str:
|
|
138
138
|
"""
|
|
139
139
|
Get Input by Name
|
|
140
140
|
:param name: str: Input Name
|
|
141
141
|
:param req: bool: If Required
|
|
142
142
|
:param low: bool: To Lower
|
|
143
143
|
:param strip: bool: To Strip
|
|
144
|
-
:
|
|
145
|
-
:param split: str: To Split
|
|
146
|
-
:return: Union[str, bool, list]
|
|
144
|
+
:return: str
|
|
147
145
|
"""
|
|
148
146
|
value = os.getenv(f"INPUT_{name.upper()}", "")
|
|
149
|
-
|
|
150
|
-
value = value.strip().lower()
|
|
151
|
-
if req and value not in true + false:
|
|
152
|
-
raise ValueError(f"Error Validating a Required Boolean Input: {name}")
|
|
153
|
-
if value in ["y", "yes", "true", "on"]:
|
|
154
|
-
return True
|
|
155
|
-
return False
|
|
156
|
-
|
|
157
|
-
if split:
|
|
158
|
-
result = []
|
|
159
|
-
for x in re.split(split, value):
|
|
160
|
-
result.append(_get_str_value(x, low, strip))
|
|
161
|
-
return result
|
|
162
|
-
|
|
163
|
-
value = _get_str_value(value, low, strip)
|
|
147
|
+
value = _get_str_value(value, strip, low)
|
|
164
148
|
if req and not value:
|
|
165
|
-
raise ValueError(f"Error Parsing
|
|
149
|
+
raise ValueError(f"Error Parsing Required Input: {name} -> {value}")
|
|
166
150
|
return value
|
|
167
151
|
|
|
168
152
|
|
|
169
|
-
def
|
|
153
|
+
def get_list(name: str, split: str = "[,|\n]", req=False, low=False, strip=True) -> List[str]:
|
|
154
|
+
"""
|
|
155
|
+
Get Input by Name
|
|
156
|
+
:param name: str: Input Name
|
|
157
|
+
:param split: str: Split Regex
|
|
158
|
+
:param req: bool: If Required
|
|
159
|
+
:param strip: bool: To Strip
|
|
160
|
+
:param low: bool: To Lowercase
|
|
161
|
+
:return: list
|
|
162
|
+
"""
|
|
163
|
+
value = os.getenv(f"INPUT_{name.upper()}", "")
|
|
164
|
+
value = _get_str_value(value, strip, low)
|
|
165
|
+
if req and not value.strip():
|
|
166
|
+
raise ValueError(f"Error Parsing Required Input: {name} -> {value}")
|
|
167
|
+
results = []
|
|
168
|
+
for x in re.split(split, value):
|
|
169
|
+
results.append(_get_str_value(x, strip, low))
|
|
170
|
+
return results
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
def get_bool(name: str, req=False) -> bool:
|
|
174
|
+
"""
|
|
175
|
+
Get Boolean Input by Name
|
|
176
|
+
:param name: str: Input Name
|
|
177
|
+
:param req: bool: If Required
|
|
178
|
+
:return: bool
|
|
179
|
+
"""
|
|
180
|
+
value = os.getenv(f"INPUT_{name.upper()}", "").strip().lower()
|
|
181
|
+
if req and value not in _true + _false:
|
|
182
|
+
raise ValueError(f"Error Parsing Required Input: {name} -> {value}")
|
|
183
|
+
if value in _true:
|
|
184
|
+
return True
|
|
185
|
+
return False
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
def _get_str_value(value, strip=True, low=False) -> str:
|
|
170
189
|
if strip:
|
|
171
190
|
value = value.strip()
|
|
172
191
|
if low:
|
|
@@ -181,7 +200,7 @@ def command(name: str, value: Optional[str] = ""):
|
|
|
181
200
|
print(f"::{name}::{value}")
|
|
182
201
|
|
|
183
202
|
|
|
184
|
-
def get_random(length: int = 16):
|
|
203
|
+
def get_random(length: int = 16) -> str:
|
|
185
204
|
r = random.choices(string.ascii_uppercase + string.ascii_lowercase + string.digits, k=length) # NOSONAR
|
|
186
205
|
return "".join(r)
|
|
187
206
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: actions-tools
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.3
|
|
4
4
|
Summary: GitHub Actions Tools for Python
|
|
5
5
|
Author: Shane
|
|
6
6
|
License: GPL-3.0
|
|
@@ -21,6 +21,7 @@ Requires-Python: >=3.10
|
|
|
21
21
|
Description-Content-Type: text/markdown
|
|
22
22
|
License-File: LICENSE
|
|
23
23
|
|
|
24
|
+
[](https://github.com/cssnr/actions-tools/actions/workflows/publish.yaml)
|
|
24
25
|
[](https://github.com/cssnr/actions-tools/actions/workflows/release.yaml)
|
|
25
26
|
[](https://github.com/cssnr/actions-tools/actions/workflows/test.yaml)
|
|
26
27
|
[](https://github.com/cssnr/actions-tools/actions/workflows/lint.yaml)
|
|
@@ -28,8 +29,8 @@ License-File: LICENSE
|
|
|
28
29
|
[](https://sonarcloud.io/summary/new_code?id=cssnr_actions-tools)
|
|
29
30
|
[](https://pypi.org/project/actions-tools/)
|
|
30
31
|
[](https://github.com/cssnr/actions-tools/releases/latest)
|
|
31
|
-
[](https://github.com/cssnr/actions-tools)
|
|
32
32
|
[](https://github.com/cssnr/actions-tools)
|
|
33
|
+
[](https://github.com/cssnr/actions-tools)
|
|
33
34
|
[](https://github.com/cssnr/actions-tools/graphs/commit-activity)
|
|
34
35
|
[](https://github.com/cssnr/actions-tools/stargazers)
|
|
35
36
|
[](https://cssnr.github.io/)
|
|
@@ -76,11 +77,9 @@ Functionality from @actions/toolkit
|
|
|
76
77
|
from actions import core
|
|
77
78
|
|
|
78
79
|
# Input
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
myBoolean = core.get_input('myBoolean', boolean=1)
|
|
83
|
-
myList = core.get_input('myList', split="[,|\n]")
|
|
80
|
+
my_str = core.get_input('string')
|
|
81
|
+
my_bool = core.get_bool('boolean')
|
|
82
|
+
my_list = core.get_list('list')
|
|
84
83
|
|
|
85
84
|
# Logging
|
|
86
85
|
core.info("info") # alias for print
|
|
@@ -92,12 +91,12 @@ core.warn("warn")
|
|
|
92
91
|
core.error("error")
|
|
93
92
|
|
|
94
93
|
# Blocks
|
|
95
|
-
core.start_group("
|
|
94
|
+
core.start_group("Title")
|
|
96
95
|
core.info('This is folded.')
|
|
97
96
|
core.end_group()
|
|
98
97
|
|
|
99
|
-
with core.
|
|
100
|
-
|
|
98
|
+
with core.group("Title") as p:
|
|
99
|
+
p('This is folded.')
|
|
101
100
|
core.info('Also folded.')
|
|
102
101
|
|
|
103
102
|
# Summary
|
|
@@ -107,8 +106,8 @@ core.summary('## Test Action')
|
|
|
107
106
|
core.set_env('NAME', 'value')
|
|
108
107
|
|
|
109
108
|
# State
|
|
110
|
-
|
|
111
|
-
|
|
109
|
+
name = core.set_state('name', 'value')
|
|
110
|
+
value = core.get_state('name')
|
|
112
111
|
|
|
113
112
|
# System Path
|
|
114
113
|
core.add_path('/dev/null')
|
|
@@ -129,7 +128,7 @@ from actions import core
|
|
|
129
128
|
core.command('warning', 'Warned!')
|
|
130
129
|
|
|
131
130
|
# Random
|
|
132
|
-
|
|
131
|
+
rand = core.get_random(32)
|
|
133
132
|
|
|
134
133
|
# Indent
|
|
135
134
|
core.start_indent(4)
|
|
@@ -31,7 +31,7 @@ def test_print():
|
|
|
31
31
|
core.stop_commands()
|
|
32
32
|
core.info("::warning::Just kidding")
|
|
33
33
|
core.start_commands()
|
|
34
|
-
with core.
|
|
34
|
+
with core.group("Title") as p:
|
|
35
35
|
core.info("with group")
|
|
36
36
|
p("core.info")
|
|
37
37
|
core.info("no group")
|
|
@@ -51,14 +51,16 @@ def test_inputs():
|
|
|
51
51
|
assert core.get_input("test") == os.environ["INPUT_TEST"].strip()
|
|
52
52
|
assert core.get_input("test", low=True) == os.environ["INPUT_TEST"].strip().lower()
|
|
53
53
|
assert core.get_input("test", strip=False) == os.environ["INPUT_TEST"]
|
|
54
|
-
assert core.
|
|
55
|
-
with pytest.raises(ValueError):
|
|
56
|
-
core.get_input("asdf", boolean=True, req=True)
|
|
54
|
+
assert core.get_bool("test")
|
|
57
55
|
with pytest.raises(ValueError):
|
|
58
56
|
core.get_input("asdf", req=True)
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
with pytest.raises(ValueError):
|
|
58
|
+
core.get_bool("asdf", req=True)
|
|
59
|
+
with pytest.raises(ValueError):
|
|
60
|
+
core.get_list("asdf", req=True)
|
|
61
|
+
assert isinstance(core.get_list("test", split="\n"), list)
|
|
62
|
+
assert len(core.get_list("test", split="\n")) == 1
|
|
63
|
+
assert not core.get_bool("false")
|
|
62
64
|
|
|
63
65
|
|
|
64
66
|
def test_getters():
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|