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

feat(back): #894 data quality #899

Merged
merged 1 commit into from
Sep 7, 2022
Merged
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
35 changes: 30 additions & 5 deletions src/cli/main/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
exists,
getctime,
join,
realpath,
)
from posixpath import (
abspath,
Expand Down Expand Up @@ -832,7 +833,10 @@ def cli(args: List[str]) -> None:
args, attr = _cli_get_args_and_attr(args, config.attrs, src)

out: str = join(MAKES_DIR, f"out{attr.replace('/', '-')}")
provenance: str = join(MAKES_DIR, f"provenance{attr.replace('/', '-')}")
provenance: str = join(
MAKES_DIR,
f"provenance{attr.replace('/', '-')}.json",
)
code = _cli_build(attr, config, head, out, src)

if code == 0:
Expand Down Expand Up @@ -949,6 +953,27 @@ def write_provenance(
provenance: str,
src: str,
) -> None:
src_uri: str = (
# GitLab
(
f"git+https://{environ['CI_REPOSITORY_URL']}"
if "CI_REPOSITORY_URL" in environ
else ""
)
# GitHub
or (
f"git+https://{environ['GITHUB_SERVER_URL']}"
f"/{environ['GITHUB_REPOSITORY']}"
if "GITHUB_SERVER_URL" in environ
and "GITHUB_REPOSITORY" in environ
else ""
)
# Local
or (f"git+file://{abspath(src)}" if abspath(src) == CWD else "")
# Other
or src
)

CON.rule("Provenance")
attestation: Dict[str, Any] = {}
attestation["_type"] = "https://in-toto.io/Statement/v0.1"
Expand All @@ -962,11 +987,11 @@ def write_provenance(
)
attestation["predicate"]["invocation"] = {}
attestation["predicate"]["invocation"]["configSource"] = {
"uri": f"git+https://{src}",
"uri": src_uri,
"digest": {"sha1": _clone_src_git_rev_parse(head, "HEAD")},
"entrypoint": args[0],
"entrypoint": args[2],
}
attestation["predicate"]["invocation"]["parameters"] = args[1:]
attestation["predicate"]["invocation"]["parameters"] = args[3:]
attestation["predicate"]["invocation"]["environment"] = {
key: "" for key in environ
}
Expand All @@ -986,7 +1011,7 @@ def write_provenance(

attestation["subject"] = [
{
"uri": out,
"uri": realpath(out),
"hash": dict([_nix_hashes(out)[0].split(":")]), # type: ignore
}
]
Expand Down