Skip to content

Commit 384851e

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 b0bf250 commit 384851e

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
@@ -181,13 +181,88 @@ function check_repo() {
181181
cd $WORKDIR
182182
}
183183

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

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

0 commit comments

Comments
 (0)