-
Notifications
You must be signed in to change notification settings - Fork 58
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
Docs workflolw #998
Merged
Merged
Docs workflolw #998
Changes from all commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
fead1f4
test
stavros-k 8ed913d
clen
stavros-k f5ef339
test more complex
stavros-k 6747c13
fix
stavros-k 71904a5
one line?
stavros-k e80e8ff
test
stavros-k aa67c2b
br
stavros-k 897e3eb
list
stavros-k 95f4e02
test more
stavros-k cde2dfc
omre?
stavros-k f7f795d
cleaner
stavros-k 4c90157
hmm
stavros-k 2b6d739
back
stavros-k 0e97538
hmm
stavros-k 70b524b
no json
stavros-k 55a58b7
fmt
stavros-k 61c531a
speratate
stavros-k b5d44b2
cleaner
stavros-k a4f2005
test
stavros-k 9fdb682
fix
stavros-k 38c6335
aha
stavros-k 1ae4fb0
remove
stavros-k 32ef0fa
ok
stavros-k bb6acd9
okay
stavros-k 544728a
test
stavros-k f47fe20
reduce noise
stavros-k d45f181
reduce nosie
stavros-k b12fd5c
separate
stavros-k 3820e59
fmt
stavros-k e665d21
cleaner
stavros-k 76e0e3d
new lines
stavros-k bd5c2b1
slim down
stavros-k ceaba15
sort
stavros-k a1f393b
remove import
stavros-k 06548f8
fmt
stavros-k c44b2e0
app
stavros-k 1defc72
tag docs-team
stavros-k 4379ce2
quote
stavros-k 275a26e
revert app changes
stavros-k 5b2e7b5
skip if empty
stavros-k 697aeda
skip better
stavros-k bf85256
test
stavros-k dada067
clean
stavros-k 798b9b5
lets not block the rest of the pipeline
stavros-k 0786e20
Merge branch 'master' into docs-workflolw
stavros-k 68e7e35
use files
stavros-k 96b376c
dont fail if its empty
stavros-k File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import sys | ||
import json | ||
|
||
|
||
def get_files_from_file(file: str): | ||
with open(file, "r") as f: | ||
json_files = f.read() | ||
|
||
try: | ||
return json.loads(json_files.replace("\\", "")) | ||
except json.JSONDecodeError: | ||
print(f"Failed to decode JSON from {file}", file=sys.stderr) | ||
exit(1) | ||
|
||
|
||
trains_to_check = ["test", "stable", "enterprise"] | ||
account_to_notify = ["@truenas/docs-team"] | ||
|
||
|
||
def process(changed_files=[], added_files=[]): | ||
changes = {} | ||
|
||
for file in changed_files: | ||
if not file.startswith("ix-dev/"): | ||
continue | ||
train = file.split("/")[1] | ||
if train not in trains_to_check: | ||
continue | ||
|
||
app = file.split("/")[2] | ||
if file.startswith(f"ix-dev/{train}/{app}/templates/library/base_"): | ||
continue | ||
|
||
if train not in changes: | ||
changes[train] = {"apps": {}} | ||
|
||
if app not in changes[train]["apps"]: | ||
changes[train]["apps"][app] = {"areas": set([]), "added": set([]), "modified": set([])} | ||
|
||
trimmed_file_name = file.replace(f"ix-dev/{train}/{app}/", "") | ||
if file in added_files: | ||
changes[train]["apps"][app]["added"].add(trimmed_file_name) | ||
else: | ||
changes[train]["apps"][app]["modified"].add(trimmed_file_name) | ||
|
||
if file.endswith("questions.yaml"): | ||
changes[train]["apps"][app]["areas"].add("ui") | ||
elif file.endswith("app.yaml"): | ||
changes[train]["apps"][app]["areas"].add("metadata") | ||
elif file.endswith("docker-compose.yaml"): | ||
changes[train]["apps"][app]["areas"].add("template") | ||
elif file.endswith("ix_values.yaml"): | ||
changes[train]["apps"][app]["areas"].add("static_config") | ||
|
||
return generate_message(changes) | ||
|
||
|
||
def generate_message(changes): | ||
message = "" | ||
for train in sorted(changes): | ||
message += f"## `{train.title()}`\n\n" | ||
for app in sorted(changes[train]["apps"]): | ||
message += f"### `{app.title()}`\n" | ||
if len(changes[train]["apps"][app]["areas"]) > 0: | ||
fmt_areas = [f"`{a}`" for a in changes[train]["apps"][app]["areas"]] | ||
message += f"Affected areas: {', '.join(fmt_areas)}\n" | ||
if len(changes[train]["apps"][app]["added"]) > 0: | ||
message += "Added files:\n" | ||
for file in sorted(changes[train]["apps"][app]["added"]): | ||
message += f"- `{file}`\n" | ||
message += "\n" | ||
if len(changes[train]["apps"][app]["modified"]) > 0: | ||
message += "Modified files:\n" | ||
for file in sorted(changes[train]["apps"][app]["modified"]): | ||
message += f"- `{file}`\n" | ||
message += "\n" | ||
message += "\n---\n\n" | ||
|
||
if message != "": | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could do
|
||
message += "Notifying the following about changes to the trains:\n" | ||
message += ", ".join(account_to_notify) | ||
return message | ||
|
||
|
||
ALL_CHANGED_FILE = ".github/outputs/all_changed_files.json" | ||
ADDED_FILE = ".github/outputs/added_files.json" | ||
|
||
|
||
def main(): | ||
changed_files = get_files_from_file(ALL_CHANGED_FILE) | ||
added_files = get_files_from_file(ADDED_FILE) | ||
|
||
print(process(changed_files, added_files)) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should never use mutable args as default args