-
Notifications
You must be signed in to change notification settings - Fork 487
perf(spec-tools,ci): parallel PR spec-doc builds, publish-only social cards #3101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
danceratopz
merged 4 commits into
ethereum:forks/amsterdam
from
spencer-tb:ci/docs-build-speedup
Jul 6, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
653c646
feat(docs): parallel PR spec-doc builds, publish-only social cards
spencer-tb 31b36ba
refactor(docs): replace docs-spec-parallel bash with a Python planner
danceratopz 2eb1669
docs(spec-tools): note forward refs validated only by the serial build
spencer-tb d41d073
test(test-forks): run docc_shards unit test in the spec-tools job
danceratopz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| """ | ||
| Build the docc spec docs as parallel shards of consecutive forks. | ||
|
|
||
| Fast PR-time validation only: the fork range is split into ``n`` | ||
| contiguous shards, each overlapping its predecessor by one fork so a | ||
| fork's reference to the previous fork resolves within its shard. One | ||
| ``docc`` process renders each shard concurrently; the per-shard outputs | ||
| are not merged. | ||
|
|
||
| Forward references (a fork referencing a later fork) fall outside their | ||
| shard and are pruned, so they are validated only by the serial | ||
| default-branch ``docs-spec`` build that gates the docs deploy. | ||
| """ | ||
|
|
||
| import argparse | ||
| import os | ||
| import subprocess | ||
| import sys | ||
| from pathlib import Path | ||
| from typing import List | ||
|
|
||
| from .forks import Hardfork | ||
|
|
||
|
|
||
| def compute_shards(forks: List[str], n: int) -> List[List[str]]: | ||
| """ | ||
| Split ``forks`` into at most ``n`` contiguous shards. | ||
|
|
||
| Every shard after the first is prefixed with its predecessor fork, so | ||
| a fork's reference to the previous fork resolves within its shard. | ||
| """ | ||
| per = (len(forks) + n - 1) // n | ||
| shards: List[List[str]] = [] | ||
| for i in range(n): | ||
| start = i * per | ||
| if start >= len(forks): | ||
| break | ||
| lo = start - 1 if start > 0 else start | ||
| shards.append(forks[lo : min(start + per, len(forks))]) | ||
| return shards | ||
|
|
||
|
|
||
| def main() -> int: | ||
| """Discover forks, shard them, and render each shard with ``docc``.""" | ||
| parser = argparse.ArgumentParser(description=__doc__) | ||
| parser.add_argument( | ||
| "-n", | ||
| "--shards", | ||
| type=int, | ||
| default=4, | ||
| help="number of parallel shards (default: 4)", | ||
| ) | ||
| parser.add_argument( | ||
| "-o", | ||
| "--output-dir", | ||
| type=Path, | ||
| required=True, | ||
| help="parent directory for each shard's output", | ||
| ) | ||
| args = parser.parse_args() | ||
| if args.shards < 1: | ||
| parser.error("--shards must be a positive integer") | ||
|
|
||
| forks = [fork.short_name for fork in Hardfork.discover()] | ||
| if not forks: | ||
| print("error: no forks discovered", file=sys.stderr) | ||
| return 1 | ||
|
|
||
| processes: List[subprocess.Popen[bytes]] = [] | ||
| for i, shard in enumerate(compute_shards(forks, args.shards)): | ||
| print(f"shard {i}: {','.join(shard)}", flush=True) | ||
| env = { | ||
| **os.environ, | ||
| "DOCC_SKIP_DIFFS": "1", | ||
| "DOCC_ONLY_FORKS": ",".join(shard), | ||
| } | ||
| output = args.output_dir / f"shard-{i}" | ||
| processes.append( | ||
| subprocess.Popen(["docc", "--output", str(output)], env=env) | ||
| ) | ||
|
|
||
| exit_codes = [process.wait() for process in processes] | ||
| return 1 if any(exit_codes) else 0 | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| sys.exit(main()) |
|
danceratopz marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| """ | ||
| Unit tests for the parallel spec-doc shard planner. | ||
| """ | ||
|
|
||
| from ethereum_spec_tools.docc_shards import compute_shards | ||
| from ethereum_spec_tools.forks import Hardfork | ||
|
|
||
|
|
||
| def test_shards_cover_every_fork() -> None: | ||
| """Every fork lands in at least one shard.""" | ||
| forks = [f"f{i}" for i in range(24)] | ||
| shards = compute_shards(forks, 4) | ||
| covered = {fork for shard in shards for fork in shard} | ||
| assert covered == set(forks) | ||
|
|
||
|
|
||
| def test_shards_are_contiguous_with_one_fork_overlap() -> None: | ||
| """Shards tile the range in order, overlapping one fork per seam.""" | ||
| forks = [f"f{i}" for i in range(24)] | ||
| assert compute_shards(forks, 4) == [ | ||
| forks[0:6], | ||
| forks[5:12], | ||
| forks[11:18], | ||
| forks[17:24], | ||
| ] | ||
|
|
||
|
|
||
| def test_each_fork_shares_a_shard_with_its_predecessor() -> None: | ||
| """The overlap keeps every fork beside its immediate predecessor.""" | ||
| forks = [f"f{i}" for i in range(24)] | ||
| shards = compute_shards(forks, 4) | ||
| for i in range(1, len(forks)): | ||
| assert any( | ||
| forks[i] in shard and forks[i - 1] in shard for shard in shards | ||
| ) | ||
|
|
||
|
|
||
| def test_more_shards_than_forks_still_covers_all() -> None: | ||
| """Requesting more shards than forks leaves no fork uncovered.""" | ||
| shards = compute_shards(["a", "b", "c"], 4) | ||
| covered = {fork for shard in shards for fork in shard} | ||
| assert covered == {"a", "b", "c"} | ||
|
|
||
|
|
||
| def test_real_fork_set_is_fully_covered() -> None: | ||
| """The discovered fork set shards without dropping any fork.""" | ||
| forks = [fork.short_name for fork in Hardfork.discover()] | ||
| shards = compute_shards(forks, 4) | ||
| covered = {fork for shard in shards for fork in shard} | ||
| assert covered == set(forks) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.