Check FL ticket in PR name after merge (#2076)
* Add base * Add base again * Test reporting * Fix reporting * Fix secrets * Fix arguments in report * Remove depricated actions * Disable reporting on PR Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
@@ -77,28 +77,38 @@ def add_env(name, value, file):
|
||||
print(f"{delimeter}", file=file)
|
||||
|
||||
|
||||
def add_envs(data, env_file, args):
|
||||
add_env("COMMIT_MSG", data["commit_comment"], env_file)
|
||||
add_env("COMMIT_HASH", data["commit_hash"], env_file)
|
||||
add_env("COMMIT_SHA", data["commit_sha"], env_file)
|
||||
add_env("SUFFIX", data["suffix"], env_file)
|
||||
add_env("BRANCH_NAME", data["branch_name"], env_file)
|
||||
add_env("DIST_SUFFIX", data["suffix"], env_file)
|
||||
add_env("WORKFLOW_BRANCH_OR_TAG", data["branch_name"], env_file)
|
||||
def add_set_output_var(name, value, file):
|
||||
print(f"{name}={value}", file=file)
|
||||
|
||||
|
||||
def add_envs(data, gh_env_file, gh_out_file, args):
|
||||
add_env("COMMIT_MSG", data["commit_comment"], gh_env_file)
|
||||
add_env("COMMIT_HASH", data["commit_hash"], gh_env_file)
|
||||
add_env("COMMIT_SHA", data["commit_sha"], gh_env_file)
|
||||
add_env("SUFFIX", data["suffix"], gh_env_file)
|
||||
add_env("BRANCH_NAME", data["branch_name"], gh_env_file)
|
||||
add_env("DIST_SUFFIX", data["suffix"], gh_env_file)
|
||||
add_env("WORKFLOW_BRANCH_OR_TAG", data["branch_name"], gh_env_file)
|
||||
add_set_output_var("branch_name", data["branch_name"], gh_out_file)
|
||||
add_set_output_var("commit_sha", data["commit_sha"], gh_out_file)
|
||||
add_set_output_var("default_target", os.getenv("DEFAULT_TARGET"), gh_out_file)
|
||||
add_set_output_var("suffix", data["suffix"], gh_out_file)
|
||||
if args.type == "pull":
|
||||
add_env("PULL_ID", data["pull_id"], env_file)
|
||||
add_env("PULL_NAME", data["pull_name"], env_file)
|
||||
add_env("PULL_ID", data["pull_id"], gh_env_file)
|
||||
add_env("PULL_NAME", data["pull_name"], gh_env_file)
|
||||
|
||||
|
||||
def main():
|
||||
args = parse_args()
|
||||
event_file = open(args.event_file)
|
||||
event_file = open(args.event_file, "r")
|
||||
event = json.load(event_file)
|
||||
env_file = open(os.environ["GITHUB_ENV"], "a")
|
||||
gh_env_file = open(os.environ["GITHUB_ENV"], "a")
|
||||
gh_out_file = open(os.environ["GITHUB_OUTPUT"], "a")
|
||||
data = get_details(event, args)
|
||||
add_envs(data, env_file, args)
|
||||
add_envs(data, gh_env_file, gh_out_file, args)
|
||||
event_file.close()
|
||||
env_file.close()
|
||||
gh_env_file.close()
|
||||
gh_out_file.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
53
scripts/merge_report_qa.py
Executable file
53
scripts/merge_report_qa.py
Executable file
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import argparse
|
||||
from slack_sdk import WebClient
|
||||
from slack_sdk.errors import SlackApiError
|
||||
|
||||
|
||||
def parse_args():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("slack_token")
|
||||
parser.add_argument("slack_channel")
|
||||
args = parser.parse_args()
|
||||
return args
|
||||
|
||||
|
||||
def checkCommitMessage(msg):
|
||||
regex = re.compile(r"^'?\[FL-\d+\]")
|
||||
if regex.match(msg):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def reportSlack(commit_hash, slack_token, slack_channel, message):
|
||||
client = WebClient(token=slack_token)
|
||||
try:
|
||||
client.chat_postMessage(channel="#" + slack_channel, text=message)
|
||||
except SlackApiError as e:
|
||||
print(e)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def main():
|
||||
args = parse_args()
|
||||
commit_msg = os.getenv("COMMIT_MSG")
|
||||
commit_hash = os.getenv("COMMIT_HASH")
|
||||
commit_sha = os.getenv("COMMIT_SHA")
|
||||
commit_link = (
|
||||
"<https://github.com/flipperdevices/flipperzero-firmware/commit/"
|
||||
+ commit_hash
|
||||
+ "|"
|
||||
+ commit_sha
|
||||
+ ">"
|
||||
)
|
||||
message = "Commit " + commit_link + " merged to dev without 'FL' ticket!"
|
||||
if not checkCommitMessage(commit_msg):
|
||||
reportSlack(commit_hash, args.slack_token, args.slack_channel, message)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Reference in New Issue
Block a user