Skip to content

Commit 71c3f68

Browse files
committed
write rustfmt diff check output to diff-check.zip
Now we have an archive that we can inspect after running the diff-check job. I believe this will be easier to inspect than looking at diff output in the github actions console.
1 parent a9ae746 commit 71c3f68

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

.github/workflows/check_diff.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,9 @@ jobs:
3131
3232
- name: check diff
3333
run: bash ${GITHUB_WORKSPACE}/ci/check_diff.sh ${{ github.event.inputs.clone_url }} ${{ github.event.inputs.branch_name }} ${{ github.event.inputs.commit_hash || github.event.inputs.branch_name }} ${{ github.event.inputs.rustfmt_configs }}
34+
35+
- name: Archive Diff Check Report
36+
uses: actions/upload-artifact@v3
37+
with:
38+
name: diff-check-report
39+
path: diff-check.zip

ci/check_diff.sh

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ function create_diff() {
7171
# $RUSFMT_BIN: Path to the rustfmt master binary. Created when running `compile_rustfmt`
7272
# $FEATURE_BIN: Path to the rustfmt feature binary. Created when running `compile_rustfmt`
7373
# $OPTIONAL_RUSTFMT_CONFIGS: Optional configs passed to the script from $4
74+
# $OUTPUT_DIR: Path to an output directory for storing the diff files. Set in `main`
7475
function check_diff() {
7576
echo "running rustfmt (master) on $1"
7677
create_diff $RUSFMT_BIN rustfmt_diff.txt
@@ -89,10 +90,18 @@ function check_diff() {
8990
--unified=0 --no-index rustfmt_diff.txt feature_diff.txt 2>&1 | tail -n +6 | cut -c 2-
9091
)
9192

93+
# COPY diffs into output dir
94+
mkdir $OUTPUT_DIR/$1
95+
echo "Copying diffs to $OUTPUT_DIR/$1"
96+
cp rustfmt_diff.txt $OUTPUT_DIR/$1/rustfmt_diff.txt
97+
cp feature_diff.txt $OUTPUT_DIR/$1/feature_diff.txt
98+
9299
if [ -z "$diff" ]; then
93100
echo "no diff detected between rustfmt and the feture branch"
94101
return 0
95102
else
103+
echo "Copying diffs between rustfmt and feature branch to $OUTPUT_DIR/$1/diff.txt"
104+
echo "$diff" >> $OUTPUT_DIR/$1/diff.txt
96105
echo "$diff"
97106
return 1
98107
fi
@@ -160,11 +169,27 @@ function check_repo() {
160169
cd $WORKDIR
161170
}
162171

172+
# Zip up all the diff changes detected by the script
173+
#
174+
# Globlas:
175+
# $OUTPUT_DIR: Output directory where all `*diif.txt` files are written to. Set in `main`.
176+
# $CURRENT_DIR: The directory where the script was run from. Set in `main`.
177+
function zip_up_diffs() {
178+
cd $OUTPUT_DIR
179+
180+
# Just to clean things up we'll make sure to remove empty files and directories
181+
find . -type f -empty -delete
182+
find . -type d -empty -delete
183+
zip -q -r $CURRENT_DIR/diff-check .
184+
}
185+
163186
function main() {
187+
CURRENT_DIR=$(pwd)
164188
tmp_dir=$(mktemp -d -t rustfmt-XXXXXXXX)
165189
echo Created tmp_dir $tmp_dir
166190

167191
compile_rustfmt $tmp_dir
192+
OUTPUT_DIR=$(mktemp -d -t diff-output-XXX)
168193

169194
# run checks
170195
check_repo "https://github.com/rust-lang/rust.git" rust-lang-rust
@@ -191,9 +216,12 @@ function main() {
191216
check_repo "https://github.com/actix/actix.git" actix
192217
check_repo "https://github.com/denoland/deno.git" denoland_deno
193218

219+
zip_up_diffs
220+
194221
# cleanup temp dir
195-
echo removing tmp_dir $tmp_dir
222+
echo removing tmp_dir $tmp_dir and $OUTPUT_DIR
196223
rm -rf $tmp_dir
224+
rm -rf $OUTPUT_DIR
197225

198226
# figure out the exit code
199227
for status in ${STATUSES[@]}

0 commit comments

Comments
 (0)