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

Reproducibility Score #108

Open
wants to merge 14 commits into
base: dev
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions pyscripts/vc/.buildspec.template
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ newline={{ newline }}

# Rebuild command
# command="mvn clean package -DskipTests -Dmaven.javadoc.skip -Dgpg.skip"
command="mvn clean package -pl :${artifactId} -am -DskipTests -Dmaven.javadoc.skip -Dgpg.skip"

# command="mvn clean package -pl :${artifactId} -am -DskipTests -Dmaven.javadoc.skip -Dgpg.skip"
command="{{ command }}"

# Location of the buildinfo file generated during rebuild to record output fingerprints
# buildinfo=target/${artifactId}-${version}.buildinfo
Expand Down
343 changes: 343 additions & 0 deletions pyscripts/vc/build_list.csv

Large diffs are not rendered by default.

305 changes: 183 additions & 122 deletions pyscripts/vc/build_packages.py

Large diffs are not rendered by default.

57 changes: 57 additions & 0 deletions pyscripts/vc/buildspec_paths_to_db.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import psycopg2
from build_packages import BuildPackages
from common.config import Config
from common.packageId import PackageId
from psycopg2.extras import DictCursor
from rc_path_finder import create_build_spec_coord2path_dic


class Main:
"""
Standalone script that searches for the buildspec of every package in RC
and updates it in the packages table in the row of its respective package.
"""

def __init__(self, config: Config) -> None:
host, port = config.DB_CONFIG["hostname"], config.DB_CONFIG["port"]
user, password = config.DB_CONFIG["username"], config.DB_CONFIG["password"]
self.conn = psycopg2.connect(
dbname="postgres", user=user, password=password, host=host, port=port
)
self.cur: DictCursor = self.conn.cursor(cursor_factory=DictCursor)

self.PKG_TABLE = "packages"

def run(self):
dic: dict[str, str] = create_build_spec_coord2path_dic("temp/builder/")
pkg_to_path = {
PackageId(part[0], part[1], part[2]): path
for (coord, path) in dic.items()
for part in [coord.split(":")]
}
print(pkg_to_path)
self.add_col_if_not_exists()
self.insert_or_update_path(pkg_to_path)

def insert_or_update_path(self, pkg_to_path: dict[PackageId, str]):
query = """
UPDATE packages
SET buildspec_path = %s
WHERE groupid = %s AND artifactid = %s AND version = %s;
"""
self.cur.executemany(
query, [(v, k.groupid, k.artifactid, k.version) for k, v in pkg_to_path.items()]
)
self.conn.commit()

def add_col_if_not_exists(self):
query = """
ALTER TABLE packages ADD COLUMN IF NOT EXISTS buildspec_path TEXT;
"""
self.cur.execute(query)
self.conn.commit()


if __name__ == "__main__":
config = Config()
Main(config).run()
2 changes: 1 addition & 1 deletion pyscripts/vc/common/build_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
class Build_Result:
def __init__(
self,
build_success: str,
build_success: bool,
stdout: str,
stderr: str,
ok_files: List[str],
Expand Down
33 changes: 26 additions & 7 deletions pyscripts/vc/common/config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import yaml
import csv
import logging

import pandas as pd
import yaml
from common.packageId import PackageId


class Config:
def __init__(self) -> None:
Expand All @@ -10,16 +14,31 @@ def __init__(self) -> None:
self.LOG_LEVEL = config["log_level"]
self.DB_CONFIG = config["database"]
self.RUN_LIST = [
key
for dictionary in config["run_config"]
for key, value in dictionary.items()
if value
key for dictionary in config["run_config"] for key, value in dictionary.items() if value
]
self.GITHUB_API_KEY = config["github_api_key"]
if self.GITHUB_API_KEY is None:
self.log.warn("GITHUB API KEY NOT SET!")
self.BUILD_CMD: str = config["build_cmd"]

build_list_path = config["build_list"]
self.BUILD_LIST: list[PackageId] = (
self.read_build_list(build_list_path) if build_list_path else []
)
self.check_config()

def load_config(self, filename):
with open(filename) as config_file:
config = yaml.safe_load(config_file)
return config

def check_config(self):
if "tag_finder" in self.RUN_LIST and self.GITHUB_API_KEY is None:
raise ValueError("GITHUB API KEY NOT SET!")
if "builder" in self.RUN_LIST and not self.BUILD_CMD:
raise ValueError("Build command not set in config. Builder will FAIL!")

def read_build_list(self, file):
packages: list[PackageId] = []
df = pd.read_csv(file, sep=",", comment="#", index_col=0, skip_blank_lines=True)
for row in df.itertuples():
packages.append(PackageId(row[0], row[1], row[2]))
return packages
15 changes: 15 additions & 0 deletions pyscripts/vc/common/packageId.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,18 @@ def __init__(self, groupid: str, artifactid: str, version: str) -> None:
self.groupid = groupid
self.artifactid = artifactid
self.version = version

def __repr__(self) -> str:
return f"{self.groupid}:{self.artifactid}:{self.version}"

def __eq__(self, other: object) -> bool:
if not isinstance(other, PackageId):
return False
return (self.groupid, self.artifactid, self.version) == (
other.groupid,
other.artifactid,
other.version,
)

def __hash__(self) -> int:
return hash((self.groupid, self.artifactid, self.version))
18 changes: 11 additions & 7 deletions pyscripts/vc/create_buildspec.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
import os

from jinja2 import Template
from common.packageId import PackageId
from build_packages import BuildPackages
from common.packageId import PackageId


def main():
"""
Standalone script used to build individual packages with given buildspec parameters
(DEBUGGING).
"""
os.chdir("./temp/builder")
builder = BuildPackages(None, None)
pkg = PackageId("org.apache.maven.wagon", "wagon-http-lightweight", "3.5.0")
pkg = PackageId("io.github.git-commit-id", "git-commit-id-maven-plugin", "6.0.0")
path = builder.create_buildspec(
pkg,
"https://github.com/apache/maven-wagon",
"wagon-3.5.0",
"https://github.com/git-commit-id/git-commit-id-maven-plugin.git",
"v6.0.0",
"mvn",
"8",
"11",
"lf",
"mvn clean package"
)
result = builder.build(path, pkg)
result = builder.build(path)
print(result.stdout)
print("------------ERRORS----------")
print(result.stderr)
Expand Down
Loading