Skip to content

Commit

Permalink
test2...
Browse files Browse the repository at this point in the history
  • Loading branch information
idubnori committed Apr 21, 2024
1 parent c368634 commit dac74b0
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 6 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/pr-agent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
- Answer in Japanese.
pr_reviewer.extra_instructions: >-
- Additional second priority point: focus on the need for test code additions or changes to the application code changes.
- name: PR Agent action step
id: pragent
uses: Codium-ai/pr-agent@main
env:
OPENAI_KEY: ${{ secrets.OPENAI_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# - name: PR Agent action step
# id: pragent
# uses: Codium-ai/pr-agent@main
# env:
# OPENAI_KEY: ${{ secrets.OPENAI_KEY }}
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

53 changes: 53 additions & 0 deletions wiki_conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import os
import toml
import json

ei_key = 'extra_instructions'
ei_sections = ['pr_reviewer', 'pr_description', 'pr_code_suggestions', 'pr_add_docs', 'pr_update_changelog', 'pr_test', 'pr_improve_component']

repository_name = os.getenv('GITHUB_REPOSITORY')

def get_conf():
try:
# Load Config file
with open("wiki_temp/${{ inputs.page-name }}", encoding="UTF-8") as f:
toml_content = f.read()

# Parse TOML content
start = toml_content.find("```") + 3
end = toml_content.rfind("```")
toml_content = toml_content[start:end]

parsed_toml = toml.loads(toml_content)
return parsed_toml

except Exception as e:
print(f"Error: {e}")
return {}

def concat_env_value(parsed_toml):
common_instructions = os.getenv('common_instructions')
for key in ei_sections:
additional_instructions = os.getenv(f"{key}.{ei_key}", None).strip() + '\n' + common_instructions
if key in parsed_toml:
if ei_key in parsed_toml[key]:
parsed_toml[key][ei_key] = (parsed_toml[key][ei_key]).strip() + '\n' + additional_instructions
else:
parsed_toml[key][ei_key] = additional_instructions
else:
parsed_toml[key] = {ei_key: additional_instructions}

return parsed_toml

def set_to_env(parsed_toml):
github_env = os.getenv('GITHUB_ENV')
with open(github_env, "a") as outputfile:
for key in ei_sections:
print(f"{key}.{ei_key}<<EOF",file=outputfile)
print(f"{parsed_toml[key][ei_key]}",file=outputfile)
print(f"EOF",file=outputfile)

if __name__ == "__main__":
toml_conf = get_conf()
added_toml_conf = concat_env_value(toml_conf)
set_to_env(added_toml_conf)

0 comments on commit dac74b0

Please sign in to comment.