Skip to content

Commit

Permalink
Add more environment info to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TeamSPoon committed Sep 3, 2024
1 parent ff55a0e commit 001d707
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion scripts/generate_allure_environment.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
import sys
import subprocess

def get_git_info(commit_sha):
"""Retrieve the commit message, author, and timestamp from the given commit SHA."""
commit_message = subprocess.check_output(
["git", "log", "-1", "--pretty=%B", commit_sha]
).decode("utf-8").strip()

commit_author = subprocess.check_output(
["git", "log", "-1", "--pretty=%an", commit_sha]
).decode("utf-8").strip()

commit_time = subprocess.check_output(
["git", "log", "-1", "--pretty=%ci", commit_sha]
).decode("utf-8").strip()

return commit_message, commit_author, commit_time

if __name__ == "__main__":
if len(sys.argv) != 3:
Expand All @@ -7,4 +24,23 @@

commit_SHA = sys.argv[1]
branch = sys.argv[2]
print("COMMIT_SHA = {}\nBRANCH = {}".format(commit_SHA, branch))

# Retrieve git information
commit_message, commit_author, commit_time = get_git_info(commit_SHA)

# Create the environment.properties content
environment_content = (
f"COMMIT_SHA = {commit_SHA}\n"
f"BRANCH = {branch}\n"
f"COMMIT_MESSAGE = {commit_message}\n"
f"COMMIT_AUTHOR = {commit_author}\n"
f"COMMIT_TIME = {commit_time}\n"
)

# Write the content to environment.properties file
with open("environment.properties", "w") as f:
f.write(environment_content)

# Print out the generated properties
print(environment_content)

0 comments on commit 001d707

Please sign in to comment.