MCPcopy Create free account
hub / github.com/apache/tvm / test_should_rebuild_docker

Function test_should_rebuild_docker

tests/python/ci/test_ci.py:1347–1403  ·  view source on GitHub ↗

Check that the Docker images are built when necessary

(tmpdir_factory, changed_files, name, check, expected_code)

Source from the content-addressed store, hash-verified

1345 ),
1346)
1347def test_should_rebuild_docker(tmpdir_factory, changed_files, name, check, expected_code):
1348 """
1349 Check that the Docker images are built when necessary
1350 """
1351 tag_script = JENKINS_SCRIPT_ROOT / "should_rebuild_docker.py"
1352
1353 git = TempGit(tmpdir_factory.mktemp("tmp_git_dir"))
1354 git.run("config", "user.name", "ci")
1355 git.run("config", "user.email", "email@example.com")
1356
1357 git_path = Path(git.cwd)
1358 for i, commits in enumerate(changed_files):
1359 for filename in commits:
1360 path = git_path / filename
1361 path.parent.mkdir(exist_ok=True, parents=True)
1362 path.touch()
1363 git.run("add", filename)
1364
1365 git.run("commit", "-m", f"message {i}")
1366
1367 if name is None:
1368 ref = "HEAD"
1369 if len(changed_files) > 1:
1370 ref = f"HEAD~{len(changed_files) - 1}"
1371 proc = git.run("rev-parse", ref, stdout=subprocess.PIPE)
1372 last_hash = proc.stdout.strip()
1373 name = f"123-123-{last_hash}"
1374
1375 docker_data = {
1376 "repositories/tlcpack": {
1377 "results": [
1378 {
1379 "name": "ci-something",
1380 },
1381 {
1382 "name": "something-else",
1383 },
1384 ],
1385 },
1386 "repositories/tlcpack/ci-something/tags": {
1387 "results": [{"name": name}, {"name": name + "old"}],
1388 },
1389 }
1390
1391 proc = run_script(
1392 [
1393 tag_script,
1394 "--testing-docker-data",
1395 json.dumps(docker_data),
1396 ],
1397 stderr=subprocess.STDOUT,
1398 cwd=git.cwd,
1399 check=False,
1400 )
1401
1402 assert_in(check, proc.stdout)
1403 assert proc.returncode == expected_code
1404

Callers

nothing calls this directly

Calls 4

runMethod · 0.95
TempGitClass · 0.85
run_scriptFunction · 0.85
assert_inFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…