|
5 | 5 |
|
6 | 6 | import git |
7 | 7 |
|
| 8 | +from codeflash.api.cfapi import is_github_app_installed_on_repo |
8 | 9 | from codeflash.cli_cmds import logging_config |
9 | 10 | from codeflash.cli_cmds.cli_common import apologize_and_exit |
10 | 11 | from codeflash.cli_cmds.cmd_init import init_codeflash, install_github_actions |
@@ -128,14 +129,22 @@ def process_pyproject_config(args: Namespace) -> Namespace: |
128 | 129 | assert args.tests_root is not None, "--tests-root must be specified" |
129 | 130 | assert Path(args.tests_root).is_dir(), f"--tests-root {args.tests_root} must be a valid directory" |
130 | 131 |
|
131 | | - assert not (env_utils.get_pr_number() is not None and not env_utils.ensure_codeflash_api_key()), ( |
132 | | - "Codeflash API key not found. When running in a Github Actions Context, provide the " |
133 | | - "'CODEFLASH_API_KEY' environment variable as a secret.\n" |
134 | | - "You can add a secret by going to your repository's settings page, then clicking 'Secrets' in the left sidebar.\n" |
135 | | - "Then, click 'New repository secret' and add your api key with the variable name CODEFLASH_API_KEY.\n" |
136 | | - f"Here's a direct link: {get_github_secrets_page_url()}\n" |
137 | | - "Exiting..." |
138 | | - ) |
| 132 | + if env_utils.get_pr_number() is not None: |
| 133 | + assert env_utils.ensure_codeflash_api_key(), ( |
| 134 | + "Codeflash API key not found. When running in a Github Actions Context, provide the " |
| 135 | + "'CODEFLASH_API_KEY' environment variable as a secret.\n" |
| 136 | + "You can add a secret by going to your repository's settings page, then clicking 'Secrets' in the left sidebar.\n" |
| 137 | + "Then, click 'New repository secret' and add your api key with the variable name CODEFLASH_API_KEY.\n" |
| 138 | + f"Here's a direct link: {get_github_secrets_page_url()}\n" |
| 139 | + "Exiting..." |
| 140 | + ) |
| 141 | + |
| 142 | + repo = git.Repo(search_parent_directories=True) |
| 143 | + |
| 144 | + owner, repo_name = get_repo_owner_and_name(repo) |
| 145 | + |
| 146 | + require_github_app_or_exit(owner, repo_name) |
| 147 | + |
139 | 148 | if hasattr(args, "ignore_paths") and args.ignore_paths is not None: |
140 | 149 | normalized_ignore_paths = [] |
141 | 150 | for path in args.ignore_paths: |
|
0 commit comments