Skip to content

Commit

Permalink
Fix DoIt race condition found as a result of workflow job split.
Browse files Browse the repository at this point in the history
  • Loading branch information
cr1901 committed Nov 27, 2023
1 parent d26edd9 commit b2781bf
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
26 changes: 22 additions & 4 deletions dodo.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def git_init(repo_dir):
return {
"basename": "_git_init",
"name": repo_dir.stem,
"actions": [CmdAction("git submodule update --init --recursive",
"actions": [CmdAction("git submodule update --init --recursive -- .",
cwd=repo_dir)],
"targets": [submod],
"uptodate": [run_once],
Expand Down Expand Up @@ -474,6 +474,26 @@ def task_run_sby():
disasm_py = formal_tests / "disasm.py"
checks_cfg = formal_tests / "checks.cfg"

# Expose this until I can figure out how to serialize the setup for
# all the sby tasks when they run in parallel. If this line isn't
# present, default behavior will try to initialize riscv-formal repo
# twice (as well as the other submodules, if "-- ." on end of "_git_init"
# tasks isn't present). This results in a failed checkout that doit thinks
# succeeded (thanks to only having the ".git" file as a target), which
# then causes dependent files like genchecks.py to never appear.
#
# Idk if the other two tasks in this setup can meaningfully race (I think
# they're idempotent), but just in case, use separate task for now.
yield {
"name": "setup",
"actions": [],
"setup": ["_git_init:riscv-formal",
"_formal_gen_sentinel",
"_formal_gen_files"],
"doc": "run sby initialization once, mostly used to avoid doit "
"parallel race conditions"
}

for c in SBY_TESTS:
sby_file = (sentinel_dir / "checks" / c).with_suffix(".sby")
yield {
Expand All @@ -488,9 +508,7 @@ def task_run_sby():
"file_dep": pyfiles + [genchecks, disasm_py, checks_cfg,
Path("./src/sentinel/microcode.asm")],
"verbosity": 2,
"setup": ["_git_init:riscv-formal",
"_formal_gen_sentinel",
"_formal_gen_files"],
"setup": ["run_sby:setup"],
}


Expand Down
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ addopts="--ignore=tests/upstream/binaries"

[tool.pdm.dev-dependencies]
dev = [
"amaranth-soc @ git+https://github.com/amaranth-lang/amaranth-soc",
"bronzebeard>=0.2.1",
"flake8>=6.1.0",
"pytest>=7.4.2",
Expand Down Expand Up @@ -79,7 +80,10 @@ rvformal-force = { composite = [
"doit forget run_sby:{args}",
"rvformal {args}"
], help="force-run a single RISC-V Formal test"}
rvformal-all = { cmd = "doit {args:-n 2} run_sby", help="run all RISC-V Formal tests" }
rvformal-all = { composite = [
"doit run_sby:setup", # serially generate RISC-V Formal files to avoid race condition
"doit {args:-n 2} run_sby"
], help="run all RISC-V Formal tests" }
# RISCOF
riscof-all = { cmd = "doit run_riscof", help="run all RISCOF tests"}

Expand Down

0 comments on commit b2781bf

Please sign in to comment.