You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+51Lines changed: 51 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -62,6 +62,57 @@ Target Determinator now includes hash persistence capabilities for optimized CI
62
62
63
63
These tools enable faster target determination in CI by pre-computing hashes once per commit and reusing them across multiple comparisons.
64
64
65
+
### Incremental hash persistence
66
+
67
+
A normal `hash-persister` run asks Bazel for the complete target graph selected by `--targets`, computes every target hash, and writes a complete JSON artifact for the requested Git revision. Incremental mode starts with such an artifact from an earlier revision, uses the Git diff and the persisted dependency graph to find targets that may have changed, and queries and hashes only that smaller set. Hashes for unaffected targets are copied into the new artifact, which is again complete and can seed a later run.
68
+
69
+
Incremental mode is enabled by passing both `--seed-file` and `--seed-sha`. It currently requires the faster, configuration-independent `query` backend:
70
+
71
+
```sh
72
+
hash-persister \
73
+
--working-directory . \
74
+
--query-backend=query \
75
+
--output "hashes-${NEW_SHA}.json" \
76
+
--seed-file "hashes-${BASE_SHA}.json" \
77
+
--seed-sha "${BASE_SHA}" \
78
+
"${NEW_SHA}"
79
+
```
80
+
81
+
`--seed-file` is the JSON artifact produced for the revision named by `--seed-sha`. The seed must use the current seed-capable artifact format and must have been created with compatible hashing inputs, including the Bazel release, target expression, query backend, Bazel options, and rule-class fingerprints. These inputs are represented by a compatibility fingerprint embedded in the artifact.
82
+
83
+
Incremental hashing is an optimization rather than a weaker correctness mode. If `hash-persister` cannot prove that reuse is safe, it logs a bounded fallback code and performs a normal full computation. This includes incompatible or malformed seeds and changes that can affect Bazel loading or package boundaries without appearing in the persisted target graph, such as changes to Starlark, workspace or module metadata, Bazel configuration files, or BUILD-file boundaries. The resulting output is still a complete artifact for the requested revision and can seed a later incremental run.
84
+
85
+
To create the first compatible seed, run without `--seed-file` while still selecting the `query` backend:
86
+
87
+
```sh
88
+
hash-persister \
89
+
--working-directory . \
90
+
--query-backend=query \
91
+
--output "hashes-${BASE_SHA}.json" \
92
+
"${BASE_SHA}"
93
+
```
94
+
95
+
#### Verifying incremental results
96
+
97
+
`--verify-seed` runs both incremental and full hashing for the destination revision and compares the resulting target hashes:
98
+
99
+
```sh
100
+
hash-persister \
101
+
--working-directory . \
102
+
--query-backend=query \
103
+
--output "hashes-${NEW_SHA}.json" \
104
+
--seed-file "hashes-${BASE_SHA}.json" \
105
+
--seed-sha "${BASE_SHA}" \
106
+
--verify-seed \
107
+
"${NEW_SHA}"
108
+
```
109
+
110
+
Verification exits nonzero if the two results differ or if incremental execution falls back to full hashing. When the two computations differ, the output path receives the full result so it remains safe for investigation and downstream use. A fallback stops verification rather than treating two full computations as evidence that incremental mode is correct. Verification is intended for rollout checks and sampling rather than the normal fast path because it deliberately performs both computations.
111
+
112
+
#### Execution reports
113
+
114
+
Pass `--execution-report <path>` to write a versioned, machine-readable JSON summary. The report distinguishes the requested mode from the mode actually used, records success or failure and any fallback code, and includes counts for changed files, dirty packages and targets, recomputed targets, reused targets, and total targets. This lets CI systems emit bounded metrics without parsing human-readable logs.
115
+
65
116
## driver binary
66
117
67
118
`driver` is a binary which implements a simple CI pipeline; it runs the same logic as `target-determinator`, then tests all identified targets.
0 commit comments