Skip to content

Commit

Permalink
Merge pull request #62 from cloudblue/bugfix/LITE-19650_github_action…
Browse files Browse the repository at this point in the history
…s_wrong_removal

LITE-19650: Fix github removal action on CLI bundles.
  • Loading branch information
marcserrat authored Jul 26, 2021
2 parents 7a89cb3 + 21d3873 commit f09515a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion connect/cli/plugins/project/extension_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def bootstrap_extension_project(config, data_dir: str):
extra_context=answers,
output_dir=data_dir,
)
utils.post_gen_cookiecutter_extension_hook(answers)
utils.post_gen_cookiecutter_extension_hook(answers, project_dir)
else:
project_dir = cookiecutter(
PROJECT_EXTENSION_BOILERPLATE_URL,
Expand Down
4 changes: 2 additions & 2 deletions connect/cli/plugins/project/report_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def bootstrap_report_project(data_dir: str):
extra_context=answers,
output_dir=data_dir,
)
utils.post_gen_cookiecutter_report_hook(answers)
utils.post_gen_cookiecutter_report_hook(answers, project_dir)
else:
project_dir = cookiecutter(
PROJECT_REPORT_BOILERPLATE_URL,
Expand Down Expand Up @@ -182,7 +182,7 @@ def _generate_files(context, output_dir, repo_dir):
skip_if_file_exists=False,
output_dir=output_dir,
)
utils.post_gen_cookiecutter_report_hook(context['cookiecutter'])
utils._create_renderer_templates(context['cookiecutter'])
else:
result = generate_files(
repo_dir=repo_dir,
Expand Down
12 changes: 6 additions & 6 deletions connect/cli/plugins/project/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,9 @@ def pre_gen_cookiecutter_extension_hook(answers: dict):
raise ClickException(f'{pk_slug} package slug is not a valid Python identifier.')


def post_gen_cookiecutter_extension_hook(answers: dict):
def post_gen_cookiecutter_extension_hook(answers: dict, project_dir: str):
if answers['use_github_actions'].lower() == 'n':
_remove_github_actions()
_remove_github_actions(project_dir)

pr_slug = _slugify(answers['project_name'])
pk_slug = _slugify(answers['package_name'])
Expand All @@ -258,8 +258,8 @@ def _slugify(name):
return name.lower().strip().replace(' ', '_').replace('-', '_').replace('.', '_').replace(',', '')


def _remove_github_actions():
shutil.rmtree('.github')
def _remove_github_actions(project_dir: str):
shutil.rmtree(f'{project_dir}/.github')


def _json_subscription_process_capabilities(descriptor: dict, answers: dict):
Expand Down Expand Up @@ -361,9 +361,9 @@ def pre_gen_cookiecutter_report_hook(answers: dict):
raise ClickException(f'{initial_report_slug} report slug is not a valid Python identifier.')


def post_gen_cookiecutter_report_hook(answers: dict):
def post_gen_cookiecutter_report_hook(answers: dict, project_dir: str):
if answers['use_github_actions'] == 'n':
_remove_github_actions()
_remove_github_actions(project_dir)

_create_renderer_templates(answers)

Expand Down
4 changes: 2 additions & 2 deletions tests/plugins/project/test_extension_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,12 +550,12 @@ def test_post_gen_cookiecutter_hook(mocker, answer, capability):
'capabilities': {},
}
with tempfile.TemporaryDirectory() as tmp_data:
os.mkdir(f'{tmp_data}/project')
project_dir = os.mkdir(f'{tmp_data}/project')
os.mkdir(f'{tmp_data}/project/package')
with open(f'{tmp_data}/project/package/extension.json', 'w') as fp:
json.dump(extension_json, fp)
with work_in(f'{tmp_data}'):
utils.post_gen_cookiecutter_extension_hook(answers)
utils.post_gen_cookiecutter_extension_hook(answers, project_dir)

with open(f'{tmp_data}/project/package/extension.json', 'r') as fp:
data = json.load(fp)
Expand Down

0 comments on commit f09515a

Please sign in to comment.