Skip to content

Commit 7a641f0

Browse files
authored
Merge pull request #106 from github/jm-dependabot-pr-prefix-and-updates
chore(deps): update dependabot config to include pr prefixes
2 parents f22bf95 + 6e24023 commit 7a641f0

File tree

4 files changed

+42
-32
lines changed

4 files changed

+42
-32
lines changed

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,17 @@ updates:
55
directory: "/"
66
schedule:
77
interval: "daily"
8+
commit-message:
9+
prefix: "chore(deps)"
810
- package-ecosystem: "github-actions"
911
directory: "/"
1012
schedule:
1113
interval: "daily"
14+
commit-message:
15+
prefix: "chore(deps)"
1216
- package-ecosystem: "docker"
1317
directory: "/"
1418
schedule:
1519
interval: "daily"
20+
commit-message:
21+
prefix: "chore(deps)"

env.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ def get_int_env_var(env_var_name: str) -> int | None:
4343
return None
4444

4545

46-
def get_env_vars() -> tuple[
46+
def get_env_vars(
47+
test: bool = False,
48+
) -> tuple[
4749
str | None,
4850
list[str],
4951
int | None,
@@ -92,9 +94,10 @@ def get_env_vars() -> tuple[
9294
enable_security_updates (bool): Whether to enable security updates in target repositories
9395
exempt_ecosystems_list (list[str]): A list of package ecosystems to exempt from the action
9496
"""
95-
# Load from .env file if it exists
96-
dotenv_path = join(dirname(__file__), ".env")
97-
load_dotenv(dotenv_path)
97+
if not test:
98+
# Load from .env file if it exists
99+
dotenv_path = join(dirname(__file__), ".env")
100+
load_dotenv(dotenv_path)
98101

99102
organization = os.getenv("ORGANIZATION")
100103
repositories_str = os.getenv("REPOSITORY")

requirements-test.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
black==24.4.0
1+
black==24.4.1
22
flake8==7.0.0
3-
mypy==1.9.0
3+
mypy==1.10.0
44
mypy-extensions==1.0.0
55
pylint==3.1.0
66
pytest==8.1.1

test_env.py

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,21 @@ class TestEnv(unittest.TestCase):
1212

1313
def setUp(self):
1414
env_keys = [
15-
"ORGANIZATION",
15+
"BATCH_SIZE",
16+
"BODY",
17+
"COMMIT_MESSAGE",
18+
"CREATED_AFTER_DATE",
1619
"EXEMPT_REPOS",
1720
"GH_APP_ID",
1821
"GH_APP_INSTALLATION_ID",
1922
"GH_APP_PRIVATE_KEY",
2023
"GH_TOKEN",
2124
"GH_ENTERPRISE_URL",
22-
"TYPE",
23-
"TITLE",
24-
"BODY",
25-
"CREATED_AFTER_DATE",
26-
"COMMIT_MESSAGE",
27-
"PROJECT_ID",
2825
"GROUP_DEPENDENCIES",
26+
"ORGANIZATION",
27+
"PROJECT_ID",
28+
"TITLE",
29+
"TYPE",
2930
]
3031
for key in env_keys:
3132
if key in os.environ:
@@ -70,7 +71,7 @@ def test_get_env_vars_with_org(self):
7071
True, # enable_security_updates
7172
[], # exempt_ecosystems
7273
)
73-
result = get_env_vars()
74+
result = get_env_vars(True)
7475
self.assertEqual(result, expected_result)
7576

7677
@patch.dict(
@@ -114,7 +115,7 @@ def test_get_env_vars_with_repos(self):
114115
True, # enable_security_updates
115116
[], # exempt_ecosystems
116117
)
117-
result = get_env_vars()
118+
result = get_env_vars(True)
118119
self.assertEqual(result, expected_result)
119120

120121
@patch.dict(
@@ -150,14 +151,14 @@ def test_get_env_vars_optional_values(self):
150151
True, # enable_security_updates
151152
[], # exempt_ecosystems
152153
)
153-
result = get_env_vars()
154+
result = get_env_vars(True)
154155
self.assertEqual(result, expected_result)
155156

156157
@patch.dict(os.environ, {})
157158
def test_get_env_vars_missing_org_or_repo(self):
158159
"""Test that an error is raised if required environment variables are not set"""
159160
with self.assertRaises(ValueError) as cm:
160-
get_env_vars()
161+
get_env_vars(True)
161162
the_exception = cm.exception
162163
self.assertEqual(
163164
str(the_exception),
@@ -202,7 +203,7 @@ def test_get_env_vars_auth_with_github_app_installation(self):
202203
True, # enable_security_updates
203204
[], # exempt_ecosystems
204205
)
205-
result = get_env_vars()
206+
result = get_env_vars(True)
206207
self.assertEqual(result, expected_result)
207208

208209
@patch.dict(
@@ -220,7 +221,7 @@ def test_get_env_vars_missing_at_least_one_auth(self):
220221
"""Test that an error is raised if at least one type of authentication
221222
required environment variables are not set"""
222223
with self.assertRaises(ValueError) as cm:
223-
get_env_vars()
224+
get_env_vars(True)
224225
the_exception = cm.exception
225226
self.assertEqual(
226227
str(the_exception),
@@ -262,7 +263,7 @@ def test_get_env_vars_with_repos_no_dry_run(self):
262263
True, # enable_security_updates
263264
[], # exempt_ecosystems
264265
)
265-
result = get_env_vars()
266+
result = get_env_vars(True)
266267
self.assertEqual(result, expected_result)
267268

268269
@patch.dict(
@@ -300,7 +301,7 @@ def test_get_env_vars_with_repos_disabled_security_updates(self):
300301
False, # enable_security_updates
301302
[], # exempt_ecosystems
302303
)
303-
result = get_env_vars()
304+
result = get_env_vars(True)
304305
self.assertEqual(result, expected_result)
305306

306307
@patch.dict(
@@ -339,7 +340,7 @@ def test_get_env_vars_with_repos_filter_visibility_multiple_values(self):
339340
False, # enable_security_updates
340341
[], # exempt_ecosystems
341342
)
342-
result = get_env_vars()
343+
result = get_env_vars(True)
343344
self.assertEqual(result, expected_result)
344345

345346
@patch.dict(
@@ -378,7 +379,7 @@ def test_get_env_vars_with_repos_filter_visibility_single_value(self):
378379
False, # enable_security_updates
379380
[], # exempt_ecosystems
380381
)
381-
result = get_env_vars()
382+
result = get_env_vars(True)
382383
self.assertEqual(result, expected_result)
383384

384385
@patch.dict(
@@ -394,7 +395,7 @@ def test_get_env_vars_with_repos_filter_visibility_single_value(self):
394395
def test_get_env_vars_with_repos_filter_visibility_invalid_single_value(self):
395396
"""Test that filter_visibility throws an error when an invalid value is provided"""
396397
with self.assertRaises(ValueError):
397-
get_env_vars()
398+
get_env_vars(True)
398399

399400
@patch.dict(
400401
os.environ,
@@ -409,7 +410,7 @@ def test_get_env_vars_with_repos_filter_visibility_invalid_single_value(self):
409410
def test_get_env_vars_with_repos_filter_visibility_invalid_multiple_value(self):
410411
"""Test that filter_visibility throws an error when an invalid value is provided"""
411412
with self.assertRaises(ValueError):
412-
get_env_vars()
413+
get_env_vars(True)
413414

414415
@patch.dict(
415416
os.environ,
@@ -447,7 +448,7 @@ def test_get_env_vars_with_repos_filter_visibility_no_duplicates(self):
447448
False, # enable_security_updates
448449
[], # exempt_ecosystems
449450
)
450-
result = get_env_vars()
451+
result = get_env_vars(True)
451452
self.assertEqual(result, expected_result)
452453

453454
@patch.dict(
@@ -487,7 +488,7 @@ def test_get_env_vars_with_repos_exempt_ecosystems(self):
487488
False, # enable_security_updates
488489
["gomod", "docker"], # exempt_ecosystems
489490
)
490-
result = get_env_vars()
491+
result = get_env_vars(True)
491492
self.assertEqual(result, expected_result)
492493

493494
@patch.dict(
@@ -526,7 +527,7 @@ def test_get_env_vars_with_no_batch_size(self):
526527
False, # enable_security_updates
527528
[], # exempt_ecosystems
528529
)
529-
result = get_env_vars()
530+
result = get_env_vars(True)
530531
self.assertEqual(result, expected_result)
531532

532533
@patch.dict(
@@ -566,7 +567,7 @@ def test_get_env_vars_with_batch_size(self):
566567
False, # enable_security_updates
567568
[], # exempt_ecosystems
568569
)
569-
result = get_env_vars()
570+
result = get_env_vars(True)
570571
self.assertEqual(result, expected_result)
571572

572573
@patch.dict(
@@ -583,7 +584,7 @@ def test_get_env_vars_with_batch_size(self):
583584
def test_get_env_vars_with_invalid_batch_size_int(self):
584585
"""Test that invalid batch size with negative 1 throws exception"""
585586
with self.assertRaises(ValueError):
586-
get_env_vars()
587+
get_env_vars(True)
587588

588589
@patch.dict(
589590
os.environ,
@@ -599,7 +600,7 @@ def test_get_env_vars_with_invalid_batch_size_int(self):
599600
def test_get_env_vars_with_invalid_batch_size_str(self):
600601
"""Test that invalid batch size of string throws exception"""
601602
with self.assertRaises(ValueError):
602-
get_env_vars()
603+
get_env_vars(True)
603604

604605
@patch.dict(
605606
os.environ,
@@ -613,7 +614,7 @@ def test_get_env_vars_with_invalid_batch_size_str(self):
613614
def test_get_env_vars_with_badly_formatted_created_after_date(self):
614615
"""Test that"""
615616
with self.assertRaises(ValueError) as context_manager:
616-
get_env_vars()
617+
get_env_vars(True)
617618
the_exception = context_manager.exception
618619
self.assertEqual(
619620
str(the_exception),

0 commit comments

Comments
 (0)