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 ci-tooling and config files #7

Merged
merged 24 commits into from
Jul 12, 2024
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
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[flake8]
max-line-length = 120
68 changes: 68 additions & 0 deletions .github/scripts/changed_apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/usr/bin/env python3

import pathlib
import json
import sys
import os
import re

APP_REGEX = re.compile(r"^ix-dev\/([-\w\.]+)\/([-\w\.]+)")
TEST_VALUES_DIR = "templates/test_values"


def get_changed_files():
json_files = os.getenv("CHANGED_FILES", "")
if not json_files:
print("Environment variable CHANGED_FILES is empty", file=sys.stderr)
exit(1)

try:
return json.loads(json_files.replace("\\", ""))
except json.JSONDecodeError:
print("Failed to decode JSON from CHANGED_FILES", file=sys.stderr)
exit(1)


def find_test_files(changed_files):
seen = set()
matrix = []
for file in changed_files:
match = APP_REGEX.match(file)
if not match:
continue

full_name = f"{match.group(1)}/{match.group(2)}"
print(f"Detected changed item for {full_name}", file=sys.stderr)

for file in pathlib.Path("ix-dev", full_name, TEST_VALUES_DIR).glob("*.yaml"):
item_tuple = (match.group(1), match.group(2), file.name)
if item_tuple not in seen:
seen.add(item_tuple)
matrix.append(
{
"train": match.group(1),
"app": match.group(2),
"test_file": file.name,
}
)

return matrix


def main():
changed_files = get_changed_files()
matrix = find_test_files(changed_files)
# This should look like:
# {
# "include": [
# { "train": "enterprise", "app": "minio", "test_file": "basic-values.yaml" },
# { "train": "enterprise", "app": "minio", "test_file": "https-values.yaml" },
# ...
# ]
# }

print(json.dumps({"include": matrix}))


if __name__ == "__main__":
main()
Loading
Loading