From b2781bf6f77512d1685a7db9da4ff01bf2986439 Mon Sep 17 00:00:00 2001 From: "William D. Jones" Date: Sun, 26 Nov 2023 19:49:39 -0500 Subject: [PATCH] Fix DoIt race condition found as a result of workflow job split. --- dodo.py | 26 ++++++++++++++++++++++---- pyproject.toml | 6 +++++- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/dodo.py b/dodo.py index 79b47f0..b336dea 100644 --- a/dodo.py +++ b/dodo.py @@ -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], @@ -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 { @@ -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"], } diff --git a/pyproject.toml b/pyproject.toml index 581a02d..a60fec1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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", @@ -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"}