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.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: actions-tools
3
- Version: 0.0.2
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
+ [![Publish](https://img.shields.io/github/actions/workflow/status/cssnr/actions-tools/publish.yaml?logo=python&logoColor=white&label=publish)](https://github.com/cssnr/actions-tools/actions/workflows/publish.yaml)
24
25
  [![Release](https://img.shields.io/github/actions/workflow/status/cssnr/actions-tools/release.yaml?logo=github&logoColor=white&label=release)](https://github.com/cssnr/actions-tools/actions/workflows/release.yaml)
25
26
  [![Test](https://img.shields.io/github/actions/workflow/status/cssnr/actions-tools/test.yaml?logo=github&logoColor=white&label=test)](https://github.com/cssnr/actions-tools/actions/workflows/test.yaml)
26
27
  [![Lint](https://img.shields.io/github/actions/workflow/status/cssnr/actions-tools/lint.yaml?logo=github&logoColor=white&label=lint)](https://github.com/cssnr/actions-tools/actions/workflows/lint.yaml)
@@ -28,8 +29,8 @@ License-File: LICENSE
28
29
  [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=cssnr_actions-tools&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=cssnr_actions-tools)
29
30
  [![PyPI](https://img.shields.io/pypi/v/actions-tools?logo=python&logoColor=white&label=PyPI)](https://pypi.org/project/actions-tools/)
30
31
  [![GitHub Release Version](https://img.shields.io/github/v/release/cssnr/actions-tools?logo=github)](https://github.com/cssnr/actions-tools/releases/latest)
31
- [![GitHub Top Language](https://img.shields.io/github/languages/top/cssnr/actions-tools?logo=htmx&logoColor=white)](https://github.com/cssnr/actions-tools)
32
32
  [![TOML Python Version](https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2Fcssnr%2Factions-tools%2Frefs%2Fheads%2Fmaster%2Fpyproject.toml&query=%24.project.requires-python&logo=python&logoColor=white&label=version)](https://github.com/cssnr/actions-tools)
33
+ [![GitHub Top Language](https://img.shields.io/github/languages/top/cssnr/actions-tools?logo=htmx&logoColor=white)](https://github.com/cssnr/actions-tools)
33
34
  [![GitHub Last Commit](https://img.shields.io/github/last-commit/cssnr/actions-tools?logo=github&logoColor=white&label=updated)](https://github.com/cssnr/actions-tools/graphs/commit-activity)
34
35
  [![GitHub Repo Stars](https://img.shields.io/github/stars/cssnr/actions-tools?style=flat&logo=github&logoColor=white)](https://github.com/cssnr/actions-tools/stargazers)
35
36
  [![GitHub Org Stars](https://img.shields.io/github/stars/cssnr?style=flat&logo=github&logoColor=white&label=org%20stars)](https://cssnr.github.io/)
@@ -76,11 +77,9 @@ Functionality from @actions/toolkit
76
77
  from actions import core
77
78
 
78
79
  # Input
79
- myStr = core.get_input('myStr')
80
- myLowerString = core.get_input('myLowerStr', low=1)
81
- myRequiredStr = core.get_input('myRequiredStr', req=1)
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("Test")
94
+ core.start_group("Title")
96
95
  core.info('This is folded.')
97
96
  core.end_group()
98
97
 
99
- with core.with_group("Test") as info:
100
- info('This is folded.')
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
- stateName = core.set_state('NAME', 'value')
111
- stateValue = core.get_state('NAME')
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
- myRandom = core.get_random(32)
131
+ rand = core.get_random(32)
133
132
 
134
133
  # Indent
135
134
  core.start_indent(4)
@@ -1,3 +1,4 @@
1
+ [![Publish](https://img.shields.io/github/actions/workflow/status/cssnr/actions-tools/publish.yaml?logo=python&logoColor=white&label=publish)](https://github.com/cssnr/actions-tools/actions/workflows/publish.yaml)
1
2
  [![Release](https://img.shields.io/github/actions/workflow/status/cssnr/actions-tools/release.yaml?logo=github&logoColor=white&label=release)](https://github.com/cssnr/actions-tools/actions/workflows/release.yaml)
2
3
  [![Test](https://img.shields.io/github/actions/workflow/status/cssnr/actions-tools/test.yaml?logo=github&logoColor=white&label=test)](https://github.com/cssnr/actions-tools/actions/workflows/test.yaml)
3
4
  [![Lint](https://img.shields.io/github/actions/workflow/status/cssnr/actions-tools/lint.yaml?logo=github&logoColor=white&label=lint)](https://github.com/cssnr/actions-tools/actions/workflows/lint.yaml)
@@ -5,8 +6,8 @@
5
6
  [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=cssnr_actions-tools&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=cssnr_actions-tools)
6
7
  [![PyPI](https://img.shields.io/pypi/v/actions-tools?logo=python&logoColor=white&label=PyPI)](https://pypi.org/project/actions-tools/)
7
8
  [![GitHub Release Version](https://img.shields.io/github/v/release/cssnr/actions-tools?logo=github)](https://github.com/cssnr/actions-tools/releases/latest)
8
- [![GitHub Top Language](https://img.shields.io/github/languages/top/cssnr/actions-tools?logo=htmx&logoColor=white)](https://github.com/cssnr/actions-tools)
9
9
  [![TOML Python Version](https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2Fcssnr%2Factions-tools%2Frefs%2Fheads%2Fmaster%2Fpyproject.toml&query=%24.project.requires-python&logo=python&logoColor=white&label=version)](https://github.com/cssnr/actions-tools)
10
+ [![GitHub Top Language](https://img.shields.io/github/languages/top/cssnr/actions-tools?logo=htmx&logoColor=white)](https://github.com/cssnr/actions-tools)
10
11
  [![GitHub Last Commit](https://img.shields.io/github/last-commit/cssnr/actions-tools?logo=github&logoColor=white&label=updated)](https://github.com/cssnr/actions-tools/graphs/commit-activity)
11
12
  [![GitHub Repo Stars](https://img.shields.io/github/stars/cssnr/actions-tools?style=flat&logo=github&logoColor=white)](https://github.com/cssnr/actions-tools/stargazers)
12
13
  [![GitHub Org Stars](https://img.shields.io/github/stars/cssnr?style=flat&logo=github&logoColor=white&label=org%20stars)](https://cssnr.github.io/)
@@ -53,11 +54,9 @@ Functionality from @actions/toolkit
53
54
  from actions import core
54
55
 
55
56
  # Input
56
- myStr = core.get_input('myStr')
57
- myLowerString = core.get_input('myLowerStr', low=1)
58
- myRequiredStr = core.get_input('myRequiredStr', req=1)
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("Test")
71
+ core.start_group("Title")
73
72
  core.info('This is folded.')
74
73
  core.end_group()
75
74
 
76
- with core.with_group("Test") as info:
77
- info('This is folded.')
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
- stateName = core.set_state('NAME', 'value')
88
- stateValue = core.get_state('NAME')
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
- myRandom = core.get_random(32)
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 Optional, Union
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
- true = ["y", "yes", "true", "on"]
13
- false = ["n", "no", "false", "off"]
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 with_group(title: str):
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, boolean=False, split="") -> Union[str, bool, list]:
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
- :param boolean: bool: If Boolean
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
- if boolean:
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 a Required Input: {name}")
149
+ raise ValueError(f"Error Parsing Required Input: {name} -> {value}")
166
150
  return value
167
151
 
168
152
 
169
- def _get_str_value(value, low=False, strip=True):
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.2
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
+ [![Publish](https://img.shields.io/github/actions/workflow/status/cssnr/actions-tools/publish.yaml?logo=python&logoColor=white&label=publish)](https://github.com/cssnr/actions-tools/actions/workflows/publish.yaml)
24
25
  [![Release](https://img.shields.io/github/actions/workflow/status/cssnr/actions-tools/release.yaml?logo=github&logoColor=white&label=release)](https://github.com/cssnr/actions-tools/actions/workflows/release.yaml)
25
26
  [![Test](https://img.shields.io/github/actions/workflow/status/cssnr/actions-tools/test.yaml?logo=github&logoColor=white&label=test)](https://github.com/cssnr/actions-tools/actions/workflows/test.yaml)
26
27
  [![Lint](https://img.shields.io/github/actions/workflow/status/cssnr/actions-tools/lint.yaml?logo=github&logoColor=white&label=lint)](https://github.com/cssnr/actions-tools/actions/workflows/lint.yaml)
@@ -28,8 +29,8 @@ License-File: LICENSE
28
29
  [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=cssnr_actions-tools&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=cssnr_actions-tools)
29
30
  [![PyPI](https://img.shields.io/pypi/v/actions-tools?logo=python&logoColor=white&label=PyPI)](https://pypi.org/project/actions-tools/)
30
31
  [![GitHub Release Version](https://img.shields.io/github/v/release/cssnr/actions-tools?logo=github)](https://github.com/cssnr/actions-tools/releases/latest)
31
- [![GitHub Top Language](https://img.shields.io/github/languages/top/cssnr/actions-tools?logo=htmx&logoColor=white)](https://github.com/cssnr/actions-tools)
32
32
  [![TOML Python Version](https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2Fcssnr%2Factions-tools%2Frefs%2Fheads%2Fmaster%2Fpyproject.toml&query=%24.project.requires-python&logo=python&logoColor=white&label=version)](https://github.com/cssnr/actions-tools)
33
+ [![GitHub Top Language](https://img.shields.io/github/languages/top/cssnr/actions-tools?logo=htmx&logoColor=white)](https://github.com/cssnr/actions-tools)
33
34
  [![GitHub Last Commit](https://img.shields.io/github/last-commit/cssnr/actions-tools?logo=github&logoColor=white&label=updated)](https://github.com/cssnr/actions-tools/graphs/commit-activity)
34
35
  [![GitHub Repo Stars](https://img.shields.io/github/stars/cssnr/actions-tools?style=flat&logo=github&logoColor=white)](https://github.com/cssnr/actions-tools/stargazers)
35
36
  [![GitHub Org Stars](https://img.shields.io/github/stars/cssnr?style=flat&logo=github&logoColor=white&label=org%20stars)](https://cssnr.github.io/)
@@ -76,11 +77,9 @@ Functionality from @actions/toolkit
76
77
  from actions import core
77
78
 
78
79
  # Input
79
- myStr = core.get_input('myStr')
80
- myLowerString = core.get_input('myLowerStr', low=1)
81
- myRequiredStr = core.get_input('myRequiredStr', req=1)
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("Test")
94
+ core.start_group("Title")
96
95
  core.info('This is folded.')
97
96
  core.end_group()
98
97
 
99
- with core.with_group("Test") as info:
100
- info('This is folded.')
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
- stateName = core.set_state('NAME', 'value')
111
- stateValue = core.get_state('NAME')
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
- myRandom = core.get_random(32)
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.with_group("With Group") as p:
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.get_input("test", boolean=True)
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
- assert isinstance(core.get_input("test", split="\n"), list)
60
- assert len(core.get_input("test", split="\n")) == 1
61
- assert not core.get_input("false", boolean=True)
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