Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add all dependencies to coverage report #2170

Merged
merged 3 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/scripts/checkCoverage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import os
import xml.etree.ElementTree as ET

def get_all_pom_files():
pom_files = []
for root, dirs, files in os.walk("../../.."):
for file in files:
if file == "pom.xml":
pom_files.append(os.path.join(root, file))
return pom_files

# get content from a file as a string
def get_file_content(file):
with open(file, "r") as f:
return f.read()

# extract xml field artifact id from string
def extract_artifact_id(xml):
root = ET.fromstring(xml)
return root.find("{http://maven.apache.org/POM/4.0.0}artifactId").text

excluded_artifacts = ["coverage-report", "aggregator", "languages"]
artifact_ids = [extract_artifact_id(get_file_content(file)) for file in get_all_pom_files()]
print("All artifacts: " + str(artifact_ids))
filtered_artifact_ids = [artifact_id for artifact_id in artifact_ids if artifact_id not in excluded_artifacts]

coverage_report_pom = ""
with open("../../../coverage-report/pom.xml", "r") as f:
coverage_report_pom = f.read()
xml = ET.fromstring(coverage_report_pom)
coverage_report_artifacts = [dependency.find("{http://maven.apache.org/POM/4.0.0}artifactId").text for dependency in xml.find("{http://maven.apache.org/POM/4.0.0}dependencies").findall("{http://maven.apache.org/POM/4.0.0}dependency")]
print("Coverage report artifacts: " + str(coverage_report_artifacts))

only_in_coverage_report = [artifact_id for artifact_id in coverage_report_artifacts if artifact_id not in filtered_artifact_ids]
print("Only in coverage report: " + str(only_in_coverage_report))
not_in_coverage_report = [artifact_id for artifact_id in filtered_artifact_ids if artifact_id not in coverage_report_artifacts]
print("Not in coverage report: " + str(not_in_coverage_report))

if len(not_in_coverage_report) > 0:
raise Exception("Some artifacts are not in the coverage report: " + str(not_in_coverage_report))
if len(only_in_coverage_report) > 0:
raise Exception("Some artifacts are only in the coverage report: " + str(only_in_coverage_report))
28 changes: 28 additions & 0 deletions .github/workflows/verify-coverage-report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Check that all dependencies are in coverage report

on:
workflow_dispatch:
push:
paths:
- ".github/workflows/verify-coverage-report.yml"
- "./scripts/checkCoverage.py"
- "**/pom.xml"
pull_request:
types: [opened, synchronize, reopened]
paths:
- ".github/workflows/verify-coverage-report..yml"
- "./scripts/checkCoverage.py"
- "**/pom.xml"

jobs:
check_coverage:
runs-on: ubuntu-latest

steps:
- name: Checkout 🛎️
uses: actions/checkout@v4

- name: Run script
working-directory: .github/workflows/scripts
run: |
python checkCoverage.py
10 changes: 10 additions & 0 deletions coverage-report/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,16 @@
<artifactId>llvmir</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>de.jplag</groupId>
<artifactId>javascript</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>de.jplag</groupId>
<artifactId>multi-language</artifactId>
<version>${revision}</version>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
Loading