@@ -182,13 +182,88 @@ function check_repo() {
182
182
cd $WORKDIR
183
183
}
184
184
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
+
185
259
# Zip up all the diff changes detected by the script
186
260
#
187
261
# Globlas:
188
262
# $OUTPUT_DIR: Output directory where all `*diif.txt` files are written to. Set in `main`.
189
263
# $CURRENT_DIR: The directory where the script was run from. Set in `main`.
190
264
function zip_up_diffs() {
191
265
cd $OUTPUT_DIR
266
+ write_readme
192
267
193
268
# Just to clean things up we'll make sure to remove empty files and directories
194
269
find . -type f -empty -delete
0 commit comments