Skip to content

Commit c940aef

Browse files
committed
Add a README.md to the diff-check.zip archive
The README provides details about how to interpret the diff-check output and some tips on how to start inspecting the output.
1 parent 78545bc commit c940aef

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

ci/check_diff.sh

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,88 @@ function check_repo() {
182182
cd $WORKDIR
183183
}
184184

185+
function write_readme() {
186+
rustfmt_diff=\`rustfmt_diff.txt\`
187+
feature_diff=\`feature_diff.txt\`
188+
diff_file=\`diff.txt\`
189+
diff_files=\`*_diff.txt\`
190+
191+
if [ -n "$OPTIONAL_RUSTFMT_CONFIGS" ]; then
192+
OPTIONAL_CONFIG_DETAILS="* diff check optional configs: \`$OPTIONAL_RUSTFMT_CONFIGS\`"
193+
fi
194+
195+
cat > README.md << EOL
196+
# Diff Check
197+
198+
## Summary
199+
200+
The Diff Check Job is used to validate rustfmts backwards compatability guarantees
201+
by running the latest rustfmt from [rust-lang/rustfmt](https://github.com/rust-lang/rustfmt) and
202+
comparing the formatting results against a fork or feature branch of rustfmt --
203+
often before deciding to merge those changes into rustfmt via a pull request.
204+
205+
**cargo details**
206+
* version: \`$CARGO_VERSON\`
207+
208+
**rustfmt details**
209+
* version: \`$RUSTFMT_VERSION\`
210+
211+
**fork details**
212+
* repo url: $REMOTE_REPO
213+
* feature branch: \`$FEATURE_BRANCH\`
214+
* version: \`$FEATURE_VERSION\`
215+
$OPTIONAL_CONFIG_DETAILS
216+
217+
## How to interpret results
218+
219+
Diffs created by running the rustfmt binary are reported in $rustfmt_diff, and
220+
diffs created by running the forked rustfmt binary are stored in $feature_diff.
221+
The presence of $rustfmt_diff and $feature_diff are not indicative of any errors.
222+
Some of the real world projects that rustfmt is tested against may not use rustfmt at all.
223+
All the $diff_files files show is that using rustfmt on a given project would change some formatting.
224+
225+
If a $diff_file file is present for a given project then that indicates a failure to
226+
uphold rustfmts backwards compatability guarantees. Given the same input both binaries produced different outputs.
227+
The $diff_file shows the difference in formatting output between both binaries.
228+
229+
## How to inspect diff-check results
230+
231+
First unzip the the diff-check archive
232+
233+
\`\`\`
234+
unzip diff-check.zip -d diff-check
235+
\`\`\`
236+
237+
If the diff-check job completes successfully that means that both the rustfmt binary and the forked rustfmt binary
238+
agree upon formatting changes. However, if the job fails because both binaries produced different formatting, you
239+
can inspect the differences by running:
240+
241+
\`\`\`
242+
for file in \$(find diff-check -type f -name diff.txt); cat \$file
243+
\`\`\`
244+
245+
If you're curious you can inspect formatting changes produced when running rustfmt by running:
246+
247+
\`\`\`
248+
for file in \$(find diff-check -type f -name rustfmt_diff.txt); cat \$file
249+
\`\`\`
250+
251+
Similarly, you can inspect formatting changes produced when running the forked rustfmt binary by running:
252+
253+
\`\`\`
254+
for file in \$(find diff-check -type f -name feature_diff.txt); cat \$file
255+
\`\`\`
256+
EOL
257+
}
258+
185259
# Zip up all the diff changes detected by the script
186260
#
187261
# Globlas:
188262
# $OUTPUT_DIR: Output directory where all `*diif.txt` files are written to. Set in `main`.
189263
# $CURRENT_DIR: The directory where the script was run from. Set in `main`.
190264
function zip_up_diffs() {
191265
cd $OUTPUT_DIR
266+
write_readme
192267

193268
# Just to clean things up we'll make sure to remove empty files and directories
194269
find . -type f -empty -delete

0 commit comments

Comments
 (0)