Skip to content

Commit

Permalink
Merge pull request #106 from github/jm-dependabot-pr-prefix-and-updates
Browse files Browse the repository at this point in the history
chore(deps): update dependabot config to include pr prefixes
  • Loading branch information
jmeridth committed Apr 25, 2024
2 parents f22bf95 + 6e24023 commit 7a641f0
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 32 deletions.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@ updates:
directory: "/"
schedule:
interval: "daily"
commit-message:
prefix: "chore(deps)"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
commit-message:
prefix: "chore(deps)"
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "daily"
commit-message:
prefix: "chore(deps)"
11 changes: 7 additions & 4 deletions env.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ def get_int_env_var(env_var_name: str) -> int | None:
return None


def get_env_vars() -> tuple[
def get_env_vars(
test: bool = False,
) -> tuple[
str | None,
list[str],
int | None,
Expand Down Expand Up @@ -92,9 +94,10 @@ def get_env_vars() -> tuple[
enable_security_updates (bool): Whether to enable security updates in target repositories
exempt_ecosystems_list (list[str]): A list of package ecosystems to exempt from the action
"""
# Load from .env file if it exists
dotenv_path = join(dirname(__file__), ".env")
load_dotenv(dotenv_path)
if not test:
# Load from .env file if it exists
dotenv_path = join(dirname(__file__), ".env")
load_dotenv(dotenv_path)

organization = os.getenv("ORGANIZATION")
repositories_str = os.getenv("REPOSITORY")
Expand Down
4 changes: 2 additions & 2 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
black==24.4.0
black==24.4.1
flake8==7.0.0
mypy==1.9.0
mypy==1.10.0
mypy-extensions==1.0.0
pylint==3.1.0
pytest==8.1.1
Expand Down
53 changes: 27 additions & 26 deletions test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,21 @@ class TestEnv(unittest.TestCase):

def setUp(self):
env_keys = [
"ORGANIZATION",
"BATCH_SIZE",
"BODY",
"COMMIT_MESSAGE",
"CREATED_AFTER_DATE",
"EXEMPT_REPOS",
"GH_APP_ID",
"GH_APP_INSTALLATION_ID",
"GH_APP_PRIVATE_KEY",
"GH_TOKEN",
"GH_ENTERPRISE_URL",
"TYPE",
"TITLE",
"BODY",
"CREATED_AFTER_DATE",
"COMMIT_MESSAGE",
"PROJECT_ID",
"GROUP_DEPENDENCIES",
"ORGANIZATION",
"PROJECT_ID",
"TITLE",
"TYPE",
]
for key in env_keys:
if key in os.environ:
Expand Down Expand Up @@ -70,7 +71,7 @@ def test_get_env_vars_with_org(self):
True, # enable_security_updates
[], # exempt_ecosystems
)
result = get_env_vars()
result = get_env_vars(True)
self.assertEqual(result, expected_result)

@patch.dict(
Expand Down Expand Up @@ -114,7 +115,7 @@ def test_get_env_vars_with_repos(self):
True, # enable_security_updates
[], # exempt_ecosystems
)
result = get_env_vars()
result = get_env_vars(True)
self.assertEqual(result, expected_result)

@patch.dict(
Expand Down Expand Up @@ -150,14 +151,14 @@ def test_get_env_vars_optional_values(self):
True, # enable_security_updates
[], # exempt_ecosystems
)
result = get_env_vars()
result = get_env_vars(True)
self.assertEqual(result, expected_result)

@patch.dict(os.environ, {})
def test_get_env_vars_missing_org_or_repo(self):
"""Test that an error is raised if required environment variables are not set"""
with self.assertRaises(ValueError) as cm:
get_env_vars()
get_env_vars(True)
the_exception = cm.exception
self.assertEqual(
str(the_exception),
Expand Down Expand Up @@ -202,7 +203,7 @@ def test_get_env_vars_auth_with_github_app_installation(self):
True, # enable_security_updates
[], # exempt_ecosystems
)
result = get_env_vars()
result = get_env_vars(True)
self.assertEqual(result, expected_result)

@patch.dict(
Expand All @@ -220,7 +221,7 @@ def test_get_env_vars_missing_at_least_one_auth(self):
"""Test that an error is raised if at least one type of authentication
required environment variables are not set"""
with self.assertRaises(ValueError) as cm:
get_env_vars()
get_env_vars(True)
the_exception = cm.exception
self.assertEqual(
str(the_exception),
Expand Down Expand Up @@ -262,7 +263,7 @@ def test_get_env_vars_with_repos_no_dry_run(self):
True, # enable_security_updates
[], # exempt_ecosystems
)
result = get_env_vars()
result = get_env_vars(True)
self.assertEqual(result, expected_result)

@patch.dict(
Expand Down Expand Up @@ -300,7 +301,7 @@ def test_get_env_vars_with_repos_disabled_security_updates(self):
False, # enable_security_updates
[], # exempt_ecosystems
)
result = get_env_vars()
result = get_env_vars(True)
self.assertEqual(result, expected_result)

@patch.dict(
Expand Down Expand Up @@ -339,7 +340,7 @@ def test_get_env_vars_with_repos_filter_visibility_multiple_values(self):
False, # enable_security_updates
[], # exempt_ecosystems
)
result = get_env_vars()
result = get_env_vars(True)
self.assertEqual(result, expected_result)

@patch.dict(
Expand Down Expand Up @@ -378,7 +379,7 @@ def test_get_env_vars_with_repos_filter_visibility_single_value(self):
False, # enable_security_updates
[], # exempt_ecosystems
)
result = get_env_vars()
result = get_env_vars(True)
self.assertEqual(result, expected_result)

@patch.dict(
Expand All @@ -394,7 +395,7 @@ def test_get_env_vars_with_repos_filter_visibility_single_value(self):
def test_get_env_vars_with_repos_filter_visibility_invalid_single_value(self):
"""Test that filter_visibility throws an error when an invalid value is provided"""
with self.assertRaises(ValueError):
get_env_vars()
get_env_vars(True)

@patch.dict(
os.environ,
Expand All @@ -409,7 +410,7 @@ def test_get_env_vars_with_repos_filter_visibility_invalid_single_value(self):
def test_get_env_vars_with_repos_filter_visibility_invalid_multiple_value(self):
"""Test that filter_visibility throws an error when an invalid value is provided"""
with self.assertRaises(ValueError):
get_env_vars()
get_env_vars(True)

@patch.dict(
os.environ,
Expand Down Expand Up @@ -447,7 +448,7 @@ def test_get_env_vars_with_repos_filter_visibility_no_duplicates(self):
False, # enable_security_updates
[], # exempt_ecosystems
)
result = get_env_vars()
result = get_env_vars(True)
self.assertEqual(result, expected_result)

@patch.dict(
Expand Down Expand Up @@ -487,7 +488,7 @@ def test_get_env_vars_with_repos_exempt_ecosystems(self):
False, # enable_security_updates
["gomod", "docker"], # exempt_ecosystems
)
result = get_env_vars()
result = get_env_vars(True)
self.assertEqual(result, expected_result)

@patch.dict(
Expand Down Expand Up @@ -526,7 +527,7 @@ def test_get_env_vars_with_no_batch_size(self):
False, # enable_security_updates
[], # exempt_ecosystems
)
result = get_env_vars()
result = get_env_vars(True)
self.assertEqual(result, expected_result)

@patch.dict(
Expand Down Expand Up @@ -566,7 +567,7 @@ def test_get_env_vars_with_batch_size(self):
False, # enable_security_updates
[], # exempt_ecosystems
)
result = get_env_vars()
result = get_env_vars(True)
self.assertEqual(result, expected_result)

@patch.dict(
Expand All @@ -583,7 +584,7 @@ def test_get_env_vars_with_batch_size(self):
def test_get_env_vars_with_invalid_batch_size_int(self):
"""Test that invalid batch size with negative 1 throws exception"""
with self.assertRaises(ValueError):
get_env_vars()
get_env_vars(True)

@patch.dict(
os.environ,
Expand All @@ -599,7 +600,7 @@ def test_get_env_vars_with_invalid_batch_size_int(self):
def test_get_env_vars_with_invalid_batch_size_str(self):
"""Test that invalid batch size of string throws exception"""
with self.assertRaises(ValueError):
get_env_vars()
get_env_vars(True)

@patch.dict(
os.environ,
Expand All @@ -613,7 +614,7 @@ def test_get_env_vars_with_invalid_batch_size_str(self):
def test_get_env_vars_with_badly_formatted_created_after_date(self):
"""Test that"""
with self.assertRaises(ValueError) as context_manager:
get_env_vars()
get_env_vars(True)
the_exception = context_manager.exception
self.assertEqual(
str(the_exception),
Expand Down

0 comments on commit 7a641f0

Please sign in to comment.