Skip to content

Commit eb3ca50

Browse files
authored
feat: use extra prep step for easier deploys (#5421)
1 parent 3326d7c commit eb3ca50

File tree

7 files changed

+60
-17
lines changed

7 files changed

+60
-17
lines changed

.github/workflows/bot-bot.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ jobs:
6565
6666
pushd cf-graph
6767
68+
conda-forge-tick prep-auto-tick
69+
conda-forge-tick deploy-to-github --dirs-to-deploy=pr_json,version_pr_info,pr_info
6870
conda-forge-tick auto-tick
71+
6972
env:
7073
BOT_TOKEN: ${{ secrets.AUTOTICK_BOT_TOKEN }}
7174
RUN_ID: ${{ github.run_id }}

conda_forge_tick/auto_tick.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
FeedstockContext,
2626
MigratorSessionContext,
2727
)
28-
from conda_forge_tick.deploy import deploy
2928
from conda_forge_tick.feedstock_parser import BOOTSTRAP_MAPPINGS
3029
from conda_forge_tick.git_utils import (
3130
DryRunBackend,
@@ -1340,19 +1339,17 @@ def _update_graph_with_pr_info():
13401339
dump_graph(gx)
13411340

13421341

1343-
def main(ctx: CliContext) -> None:
1344-
start_time = time.time()
1345-
1342+
def main_prep(ctx: CliContext) -> None:
13461343
_setup_limits()
13471344

13481345
with fold_log_lines("updating graph with PR info"):
13491346
_update_graph_with_pr_info()
1350-
gc.collect()
1351-
deploy(
1352-
dry_run=ctx.dry_run,
1353-
dirs_to_deploy=["version_pr_info", "pr_json", "pr_info"],
1354-
git_only=False,
1355-
)
1347+
1348+
1349+
def main(ctx: CliContext) -> None:
1350+
start_time = time.time()
1351+
1352+
_setup_limits()
13561353

13571354
# record tmp dir so we can be sure to clean it later
13581355
temp = glob.glob("/tmp/*")

conda_forge_tick/cli.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,14 @@ def update_upstream_versions(
159159
update_upstream_versions.main(ctx, job=job, n_jobs=n_jobs, package=package)
160160

161161

162+
@main.command(name="prep-auto-tick")
163+
@pass_context
164+
def prep_auto_tick(ctx: CliContext) -> None:
165+
from . import auto_tick
166+
167+
auto_tick.main_prep(ctx)
168+
169+
162170
@main.command(name="auto-tick")
163171
@pass_context
164172
def auto_tick(ctx: CliContext) -> None:
@@ -218,14 +226,25 @@ def make_mappings() -> None:
218226
"not be deployed."
219227
),
220228
)
229+
@click.option(
230+
"--dirs-to-deploy",
231+
default=None,
232+
help=(
233+
"Comma-separated list of directories to deplot. If given, all other "
234+
"directories will be ignored."
235+
),
236+
)
221237
@pass_context
222-
def deploy_to_github(ctx: CliContext, git_only: bool, dirs_to_ignore: str) -> None:
238+
def deploy_to_github(
239+
ctx: CliContext, git_only: bool, dirs_to_ignore: str, dirs_to_deploy: str
240+
) -> None:
223241
from . import deploy
224242

225243
deploy.deploy(
226244
dry_run=ctx.dry_run,
227245
git_only=git_only,
228246
dirs_to_ignore=[] if dirs_to_ignore is None else dirs_to_ignore.split(","),
247+
dirs_to_deploy=[] if dirs_to_deploy is None else dirs_to_deploy.split(","),
229248
)
230249

231250

conda_forge_tick/deploy.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ def deploy(
291291
clean_disk_space()
292292

293293
files_to_add: set[str] = set()
294-
if dirs_to_deploy is None:
294+
if not dirs_to_deploy:
295295
drs_to_deploy = [
296296
"status",
297297
"mappings",
@@ -304,7 +304,7 @@ def deploy(
304304
drs_to_deploy += CF_TICK_GRAPH_DATA_HASHMAPS
305305
drs_to_deploy += ["graph.json"]
306306
else:
307-
if dirs_to_ignore is not None:
307+
if dirs_to_ignore:
308308
raise RuntimeError(
309309
"You cannot specify both `dirs_to_deploy` "
310310
"and `dirs_to_ignore` when deploying the graph!"
@@ -344,7 +344,7 @@ def deploy(
344344

345345
files_to_delete = _get_files_to_delete()
346346

347-
if dirs_to_ignore is not None:
347+
if dirs_to_ignore:
348348
print("ignoring dirs:", dirs_to_ignore, flush=True)
349349
new_files_to_add = set()
350350
for fn in files_to_add:

conda_forge_tick/migrators/migration_yaml.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,8 @@ def migrate(
434434
cbc_contents = f.read()
435435
merged_cbc = merge_migrator_cbc(self.yaml_contents, cbc_contents)
436436
with pushd(os.path.join(recipe_dir, "migrations")):
437-
os.remove(f"{self.name}.yaml")
437+
if os.path.exists(f"{self.name}.yaml"):
438+
os.remove(f"{self.name}.yaml")
438439
# replace the conda build config with the merged one
439440
with pushd(recipe_dir), open("conda_build_config.yaml", "w") as f:
440441
f.write(merged_cbc)

tests/test_cli.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,10 @@ def test_cli_mock_deploy_to_github_git_only(
169169

170170
assert result.exit_code == 0
171171
cmd_mock.assert_called_once_with(
172-
dry_run=False, git_only=git_only, dirs_to_ignore=[]
172+
dry_run=False,
173+
git_only=git_only,
174+
dirs_to_ignore=[],
175+
dirs_to_deploy=[],
173176
)
174177

175178

@@ -192,7 +195,9 @@ def test_cli_mock_deploy_to_github_dirs_to_ignore(
192195
kws = {"dirs_to_ignore": []}
193196

194197
assert result.exit_code == 0
195-
cmd_mock.assert_called_once_with(dry_run=False, git_only=False, **kws)
198+
cmd_mock.assert_called_once_with(
199+
dry_run=False, git_only=False, dirs_to_deploy=[], **kws
200+
)
196201

197202

198203
@pytest.mark.parametrize(

tests_integration/test_integration.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,15 @@ def test_scenario(
304304
invoke_bot_command(["--debug", "deploy-to-github", "--git-only"])
305305

306306
with in_fresh_cf_graph():
307+
with mitmproxy_env():
308+
invoke_bot_command(["--debug", "prep-auto-tick"])
309+
invoke_bot_command(
310+
[
311+
"--debug",
312+
"deploy-to-github",
313+
"--dirs-to-deploy=pr_json,version_pr_info,pr_info",
314+
]
315+
)
307316
with mitmproxy_env():
308317
invoke_bot_command(["--debug", "auto-tick"])
309318
invoke_bot_command(
@@ -324,6 +333,15 @@ def test_scenario(
324333
with in_fresh_cf_graph():
325334
# due to a similar implementation detail, we need to run auto-tick twice
326335
# for changes to be picked up
336+
with mitmproxy_env():
337+
invoke_bot_command(["--debug", "prep-auto-tick"])
338+
invoke_bot_command(
339+
[
340+
"--debug",
341+
"deploy-to-github",
342+
"--dirs-to-deploy=pr_json,version_pr_info,pr_info",
343+
]
344+
)
327345
with mitmproxy_env():
328346
invoke_bot_command(["--debug", "auto-tick"])
329347
invoke_bot_command(

0 commit comments

Comments
 (0)