Skip to content
This repository has been archived by the owner on Nov 6, 2024. It is now read-only.

Commit

Permalink
Use skill name instead of skill path
Browse files Browse the repository at this point in the history
This finds the skill name from the skill path and uses that when creating the test_skill.yml
  • Loading branch information
forslund committed Aug 2, 2021
1 parent 6887a07 commit 38305c1
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion build_test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""
from argparse import ArgumentParser
from os import environ
import re

import requests
from github import Github
Expand Down Expand Up @@ -57,6 +58,21 @@ def get_pull_request_submodule(pull_request_diff):
return skill_submodule_path


def get_skill_submodule_name(skill_submodule_path):
"""Find the skill name from a skill submodule path."""
with open('.gitmodules') as f:
for line in f:
name_match = re.match(r"\[submodule \"(?P<entryname>.+)\"\]", line)
if name_match:
name = name_match.groups()[0]
if line.strip() == f'path = {skill_submodule_path}':
return name

print("WARNING: The skill name couldn't be determined. "
"Using skill_submodule_path instead!")
return skill_submodule_path


def write_test_config_file(submodule_path):
"""Write a YAML file for the integration test setup script."""
with open('test_skill.yml', 'w') as config_file:
Expand All @@ -68,11 +84,13 @@ def main():
args = parse_command_line()
pull_request_diff = get_pull_request_diff(args)
skill_submodule_path = get_pull_request_submodule(pull_request_diff)

if skill_submodule_path is None:
# Not every PR into this repository will be a change to a skill.
# If no Skill submodule was found, use the "hello world" Skill.
skill_submodule_path = 'skill-hello-world'
write_test_config_file(skill_submodule_path)
skill_submodule_name = get_skill_submodule_name(skill_submodule_path)
write_test_config_file(skill_submodule_name)


if __name__ == '__main__':
Expand Down

0 comments on commit 38305c1

Please sign in to comment.