Skip to content

Commit 4798a6e

Browse files
zkoppertCopilot
andcommitted
fix: add JuliaProject.toml, docker-compose suffixed variants, consolidate tests
- Add JuliaProject.toml to julia manifest detection (matches dependabot-core's file_fetcher regex) - Add common docker-compose suffixed variants (dev, ci, prod, test, override) to match dependabot-core's broader regex support - Consolidate docker, maven, gradle individual tests into the parametric ecosystem test to stay under pylint's 1000-line limit - Fix indentation issue in test loop body Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 695a548 commit 4798a6e

File tree

2 files changed

+28
-70
lines changed

2 files changed

+28
-70
lines changed

dependabot_file.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,12 +293,22 @@ def build_dependabot_file(
293293
"docker-compose.yaml",
294294
"compose.yaml",
295295
"compose.yml",
296+
"docker-compose.dev.yml",
297+
"docker-compose.dev.yaml",
298+
"docker-compose.ci.yml",
299+
"docker-compose.ci.yaml",
300+
"docker-compose.prod.yml",
301+
"docker-compose.prod.yaml",
302+
"docker-compose.test.yml",
303+
"docker-compose.test.yaml",
304+
"docker-compose.override.yml",
305+
"docker-compose.override.yaml",
296306
],
297307
"dotnet-sdk": ["global.json"],
298308
"elm": ["elm.json"],
299309
"gitsubmodule": [".gitmodules"],
300310
"helm": ["Chart.yaml"],
301-
"julia": ["Project.toml"],
311+
"julia": ["Project.toml", "JuliaProject.toml"],
302312
"pre-commit": [
303313
".pre-commit-config.yaml",
304314
".pre-commit-config.yml",

test_dependabot_file.py

Lines changed: 17 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -366,80 +366,36 @@ def test_build_dependabot_file_with_nuget(self):
366366
)
367367
self.assertEqual(result, expected_result)
368368

369-
def test_build_dependabot_file_with_docker(self):
370-
"""Test that the dependabot.yml file is built correctly with Docker"""
371-
repo = MagicMock()
372-
repo.file_contents.side_effect = lambda filename: filename == "Dockerfile"
373-
374-
expected_result = yaml.load(b"""
375-
version: 2
376-
updates:
377-
- package-ecosystem: 'docker'
378-
directory: '/'
379-
schedule:
380-
interval: 'weekly'
381-
""")
382-
result = build_dependabot_file(
383-
repo, False, [], {}, None, "weekly", "", [], None
384-
)
385-
self.assertEqual(result, expected_result)
386-
387-
def test_build_dependabot_file_with_maven(self):
388-
"""Test that the dependabot.yml file is built correctly with maven"""
389-
repo = MagicMock()
390-
repo.file_contents.side_effect = lambda filename: filename == "pom.xml"
391-
392-
expected_result = yaml.load(b"""
393-
version: 2
394-
updates:
395-
- package-ecosystem: 'maven'
396-
directory: '/'
397-
schedule:
398-
interval: 'weekly'
399-
""")
400-
result = build_dependabot_file(
401-
repo, False, [], {}, None, "weekly", "", [], None
402-
)
403-
self.assertEqual(result, expected_result)
404-
405-
def test_build_dependabot_file_with_gradle(self):
406-
"""Test that the dependabot.yml file is built correctly with gradle"""
407-
repo = MagicMock()
408-
repo.file_contents.side_effect = lambda filename: filename == "build.gradle"
409-
410-
expected_result = yaml.load(b"""
411-
version: 2
412-
updates:
413-
- package-ecosystem: 'gradle'
414-
directory: '/'
415-
schedule:
416-
interval: 'weekly'
417-
""")
418-
result = build_dependabot_file(
419-
repo, False, [], {}, None, "weekly", "", [], None
420-
)
421-
self.assertEqual(result, expected_result)
422-
423369
def test_build_dependabot_file_with_new_ecosystems(self):
424370
"""Test that the dependabot.yml file is built correctly for newly added ecosystems.
425371
Each (ecosystem, manifest_file) pair gets its own subTest so every
426372
alternative manifest filename is verified, not just the first one."""
373+
tmpl = (
374+
"version: 2\nupdates:\n - package-ecosystem: '{}'"
375+
"\n directory: '/'\n schedule:\n interval: 'weekly'\n"
376+
)
427377
ecosystems = [
428378
("bazel", "MODULE.bazel"),
429379
("bazel", "WORKSPACE"),
430380
("bazel", "WORKSPACE.bazel"),
431381
("bun", "bun.lock"),
432382
("conda", "environment.yml"),
433383
("conda", "environment.yaml"),
384+
("docker", "Dockerfile"),
434385
("docker-compose", "docker-compose.yml"),
435386
("docker-compose", "docker-compose.yaml"),
436387
("docker-compose", "compose.yaml"),
437388
("docker-compose", "compose.yml"),
389+
("docker-compose", "docker-compose.override.yml"),
438390
("dotnet-sdk", "global.json"),
439391
("elm", "elm.json"),
440392
("gitsubmodule", ".gitmodules"),
393+
("gradle", "build.gradle"),
394+
("gradle", "build.gradle.kts"),
441395
("helm", "Chart.yaml"),
442396
("julia", "Project.toml"),
397+
("julia", "JuliaProject.toml"),
398+
("maven", "pom.xml"),
443399
("pre-commit", ".pre-commit-config.yaml"),
444400
("pre-commit", ".pre-commit-config.yml"),
445401
("pre-commit", ".pre-commit.yaml"),
@@ -453,21 +409,13 @@ def test_build_dependabot_file_with_new_ecosystems(self):
453409
("vcpkg", "vcpkg-configuration.json"),
454410
]
455411
for ecosystem, manifest_file in ecosystems:
456-
repo = MagicMock()
457-
repo.file_contents.side_effect = lambda f, mf=manifest_file: f == mf
458-
459-
expected_result = yaml.load(f"""
460-
version: 2
461-
updates:
462-
- package-ecosystem: '{ecosystem}'
463-
directory: '/'
464-
schedule:
465-
interval: 'weekly'
466-
""".encode())
467-
result = build_dependabot_file(
468-
repo, False, [], {}, None, "weekly", "", [], None
469-
)
470-
self.assertEqual(result, expected_result)
412+
repo = MagicMock()
413+
repo.file_contents.side_effect = lambda f, mf=manifest_file: f == mf
414+
expected = yaml.load(tmpl.format(ecosystem).encode())
415+
result = build_dependabot_file(
416+
repo, False, [], {}, None, "weekly", "", [], None
417+
)
418+
self.assertEqual(result, expected)
471419

472420
def test_build_dependabot_file_with_terraform_with_files(self):
473421
"""Test that the dependabot.yml file is built correctly with Terraform"""

0 commit comments

Comments
 (0)