From 39fa47a3ef802c406315fda567ccc91206c11d71 Mon Sep 17 00:00:00 2001 From: h1alexbel Date: Mon, 7 Oct 2024 15:20:13 +0300 Subject: [PATCH] feat(#125): skip None artifact --- sr-data/src/sr_data/steps/maven.py | 2 +- sr-data/src/tests/test_maven.py | 19 +++++++++++++++++++ .../src/tests/to-maven-without-artifact.csv | 2 ++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 sr-data/src/tests/to-maven-without-artifact.csv diff --git a/sr-data/src/sr_data/steps/maven.py b/sr-data/src/sr_data/steps/maven.py index 1588029..a37f615 100644 --- a/sr-data/src/sr_data/steps/maven.py +++ b/sr-data/src/sr_data/steps/maven.py @@ -118,7 +118,7 @@ def merge(build, repo): artifact = plugin.find("./pom:artifactId", namespaces) if group is not None: plugins.append(f"{group.text}:{artifact.text}") - else: + elif artifact is not None: plugins.append(artifact.text) good.append(profile) used = len(good) diff --git a/sr-data/src/tests/test_maven.py b/sr-data/src/tests/test_maven.py index 69fe593..f7215d1 100644 --- a/sr-data/src/tests/test_maven.py +++ b/sr-data/src/tests/test_maven.py @@ -69,6 +69,25 @@ def test_skips_repos_without_maven(self): frame = pd.read_csv(path) self.assertTrue(len(frame) == 0) + @pytest.mark.nightly + def test_skips_plugin_without_artifact(self): + with TemporaryDirectory() as temp: + path = os.path.join(temp, "maven.csv") + main( + os.path.join( + os.path.dirname(os.path.realpath(__file__)), + "to-maven-without-artifact.csv" + ), + path, + os.environ["GH_TESTING_TOKEN"] + ) + frame = pd.read_csv(path) + self.assertEqual( + frame.iloc[0]["plugins"], + "[org.jetbrains.kotlin:kotlin-maven-plugin,org.springframework.boot:spring-boot-maven-plugin]" + ) + + @pytest.mark.fast def test_merges_projects_in_one_profile(self): merged = merge( diff --git a/sr-data/src/tests/to-maven-without-artifact.csv b/sr-data/src/tests/to-maven-without-artifact.csv new file mode 100644 index 0000000..f09d22a --- /dev/null +++ b/sr-data/src/tests/to-maven-without-artifact.csv @@ -0,0 +1,2 @@ +repo,branch +habuma/spring-ai-examples,main \ No newline at end of file