From c9e41330b2456584f441522b8cd2cb45ba42907b Mon Sep 17 00:00:00 2001 From: Jieyou Xu Date: Sun, 7 Dec 2025 15:59:06 +0800 Subject: [PATCH 1/3] [NFC] Fix `rusfmt` misspellings No functional changes. Just was bothering me :D --- ci/check_diff.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ci/check_diff.sh b/ci/check_diff.sh index 5155ec1f0be..38771f6b6eb 100755 --- a/ci/check_diff.sh +++ b/ci/check_diff.sh @@ -36,7 +36,7 @@ function init_submodules() { git submodule update --init $1 } -# Run rusfmt with the --check flag to see if a diff is produced. +# Run rustfmt with the --check flag to see if a diff is produced. # # Parameters: # $1: Path to a rustfmt binary @@ -65,12 +65,12 @@ function create_diff() { # $1: Name of the repository (used for logging) # # Globals: -# $RUSFMT_BIN: Path to the rustfmt main binary. Created when running `compile_rustfmt` +# $RUSTFMT_BIN: Path to the rustfmt main binary. Created when running `compile_rustfmt` # $FEATURE_BIN: Path to the rustfmt feature binary. Created when running `compile_rustfmt` # $OPTIONAL_RUSTFMT_CONFIGS: Optional configs passed to the script from $4 function check_diff() { echo "running rustfmt (main) on $1" - create_diff $RUSFMT_BIN rustfmt_diff.txt + create_diff $RUSTFMT_BIN rustfmt_diff.txt echo "running rustfmt (feature) on $1" create_diff $FEATURE_BIN feature_diff.txt $OPTIONAL_RUSTFMT_CONFIGS @@ -140,9 +140,9 @@ function compile_rustfmt() { echo -e "\nRuntime dependencies for rustfmt -- LD_LIBRARY_PATH: $LD_LIBRARY_PATH" - RUSFMT_BIN=$1/rustfmt - RUSTFMT_VERSION=$($RUSFMT_BIN --version) - echo -e "\nRUSFMT_BIN $RUSTFMT_VERSION\n" + RUSTFMT_BIN=$1/rustfmt + RUSTFMT_VERSION=$($RUSTFMT_BIN --version) + echo -e "\nRUSTFMT_BIN $RUSTFMT_VERSION\n" FEATURE_BIN=$1/feature_rustfmt FEATURE_VERSION=$($FEATURE_BIN --version) From e51147d53ad3f1accb647e6a33fb82e67db357cf Mon Sep 17 00:00:00 2001 From: Jieyou Xu Date: Sun, 7 Dec 2025 16:11:47 +0800 Subject: [PATCH 2/3] diff-check: introduce a required `style_edition` input So that when manually dispatching the Diff Check workflow, an explicit style edition is specified. Note that the style edition specified with `style_edition` input can still be overridden by `rustfmt_configs`, but the intention is to make sure the `style_edition` is always specified. --- .github/workflows/check_diff.yml | 5 ++++- ci/check_diff.sh | 26 +++++++++++++++++++------- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/.github/workflows/check_diff.yml b/.github/workflows/check_diff.yml index 6f139a4ace2..b3669f47537 100644 --- a/.github/workflows/check_diff.yml +++ b/.github/workflows/check_diff.yml @@ -8,6 +8,9 @@ on: branch_name: description: 'Name of the feature branch on the forked repo' required: true + style_edition: + description: 'Style edition to run both rustfmt with; can be overridden by style edition settings in `rustfmt_configs`' + required: true commit_hash: description: 'Optional commit hash from the feature branch' required: false @@ -30,4 +33,4 @@ jobs: rustup target add x86_64-unknown-linux-gnu - name: check diff - 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 }} + run: bash ${GITHUB_WORKSPACE}/ci/check_diff.sh ${{ github.event.inputs.clone_url }} ${{ github.event.inputs.branch_name }} ${{ github.events.inputs.style_edition }} ${{ github.event.inputs.commit_hash || github.event.inputs.branch_name }} ${{ github.event.inputs.rustfmt_configs }} diff --git a/ci/check_diff.sh b/ci/check_diff.sh index 38771f6b6eb..8b8ed87175b 100755 --- a/ci/check_diff.sh +++ b/ci/check_diff.sh @@ -3,7 +3,7 @@ set -e function print_usage() { - echo "usage check_diff REMOTE_REPO FEATURE_BRANCH [COMMIT_HASH] [OPTIONAL_RUSTFMT_CONFIGS]" + echo "usage check_diff REMOTE_REPO FEATURE_BRANCH STYLE_EDITION [COMMIT_HASH] [OPTIONAL_RUSTFMT_CONFIGS]" } if [ $# -le 1 ]; then @@ -13,8 +13,12 @@ fi REMOTE_REPO=$1 FEATURE_BRANCH=$2 -OPTIONAL_COMMIT_HASH=$3 -OPTIONAL_RUSTFMT_CONFIGS=$4 +# Can still be overridden by style edition configuration in `OPTIONAL_RUSTFMT_CONFIGS`. This is a +# separate arg mostly to make sure it's not forgotten when manually dispatching the Diff Check +# workflow. +STYLE_EDITION=$3 +OPTIONAL_COMMIT_HASH=$4 +OPTIONAL_RUSTFMT_CONFIGS=$5 # OUTPUT array used to collect all the status of running diffs on various repos STATUSES=() @@ -44,13 +48,19 @@ function init_submodules() { # $3: Any additional configuration options to pass to rustfmt # # Globals: -# $OPTIONAL_RUSTFMT_CONFIGS: Optional configs passed to the script from $4 +# $STYLE_EDITION: Style edition; can be overridden by style edition specified in +# `$OPTIONAL_RUSTFMT_CONFIGS`. +# $OPTIONAL_RUSTFMT_CONFIGS: Optional configs passed to the script function create_diff() { local config; + # Unconditionally set + config="--config=error_on_line_overflow=false,error_on_unformatted=false" + # Can still be overridden by later `style_edition` configurations in + # `$OPTIONAL_RUSTFMT_CONFIGS`. + config="$config,style_edition=$STYLE_EDITION" + if [ -z "$3" ]; then - config="--config=error_on_line_overflow=false,error_on_unformatted=false" - else - config="--config=error_on_line_overflow=false,error_on_unformatted=false,$OPTIONAL_RUSTFMT_CONFIGS" + config="$config,$OPTIONAL_RUSTFMT_CONFIGS" fi for i in `find . | grep "\.rs$"` @@ -191,6 +201,8 @@ function log_inputs() { echo "$REMOTE_REPO" echo "Feature branch:" echo "$FEATURE_BRANCH" + echo "Style edition:" + echo "$STYLE_EDITION" echo "(Optional) Commit hash:" echo "$OPTIONAL_COMMIT_HASH" echo "(Optional) Rustfmt configs:" From de4e3e75d8f6e3ef41f5af4bcdcdb5e566b74dae Mon Sep 17 00:00:00 2001 From: Jieyou Xu Date: Tue, 9 Dec 2025 09:17:35 +0800 Subject: [PATCH 3/3] diff-check: introduce a required `language_edition` input When a language edition is not specified, `rustfmt` will default to Edition 2015 (like `rustc`), which tends to cause parse errors in the preset set of candidate projects being used for comparison. Introduce a required `language_edition` input for the Diff Check workflow (and the `check_diff.sh` script) so that the contributor invoking the workflow is much less likely to miss specifying the language edition. Like the previous `style_edition` input, the language edition can also be overriden by `edition=...` settings in the later optional `rustfmt_configs` input for consistency. --- .github/workflows/check_diff.yml | 5 ++++- ci/check_diff.sh | 28 ++++++++++++++++++++++------ 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/.github/workflows/check_diff.yml b/.github/workflows/check_diff.yml index b3669f47537..f8e978eec19 100644 --- a/.github/workflows/check_diff.yml +++ b/.github/workflows/check_diff.yml @@ -8,6 +8,9 @@ on: branch_name: description: 'Name of the feature branch on the forked repo' required: true + language_edition: + description: 'Language edition to run both rustfmt with; can be overridden by language edition settings in `rustfmt_configs`' + required: true style_edition: description: 'Style edition to run both rustfmt with; can be overridden by style edition settings in `rustfmt_configs`' required: true @@ -33,4 +36,4 @@ jobs: rustup target add x86_64-unknown-linux-gnu - name: check diff - run: bash ${GITHUB_WORKSPACE}/ci/check_diff.sh ${{ github.event.inputs.clone_url }} ${{ github.event.inputs.branch_name }} ${{ github.events.inputs.style_edition }} ${{ github.event.inputs.commit_hash || github.event.inputs.branch_name }} ${{ github.event.inputs.rustfmt_configs }} + run: bash ${GITHUB_WORKSPACE}/ci/check_diff.sh ${{ github.event.inputs.clone_url }} ${{ github.event.inputs.branch_name }} ${{ github.events.inputs.language_edition }} ${{ github.events.inputs.style_edition }} ${{ github.event.inputs.commit_hash || github.event.inputs.branch_name }} ${{ github.event.inputs.rustfmt_configs }} diff --git a/ci/check_diff.sh b/ci/check_diff.sh index 8b8ed87175b..40b03ce5a66 100755 --- a/ci/check_diff.sh +++ b/ci/check_diff.sh @@ -3,7 +3,7 @@ set -e function print_usage() { - echo "usage check_diff REMOTE_REPO FEATURE_BRANCH STYLE_EDITION [COMMIT_HASH] [OPTIONAL_RUSTFMT_CONFIGS]" + echo "usage check_diff REMOTE_REPO FEATURE_BRANCH LANGUAGE_EDITION STYLE_EDITION [COMMIT_HASH] [OPTIONAL_RUSTFMT_CONFIGS]" } if [ $# -le 1 ]; then @@ -13,12 +13,17 @@ fi REMOTE_REPO=$1 FEATURE_BRANCH=$2 -# Can still be overridden by style edition configuration in `OPTIONAL_RUSTFMT_CONFIGS`. This is a -# separate arg mostly to make sure it's not forgotten when manually dispatching the Diff Check + +# Required language edition and style edition inputs. +# +# Can still be overridden by style edition configuration in `OPTIONAL_RUSTFMT_CONFIGS`. They are +# separate arg mostly to make sure they are not forgotten when manually dispatching the Diff Check # workflow. -STYLE_EDITION=$3 -OPTIONAL_COMMIT_HASH=$4 -OPTIONAL_RUSTFMT_CONFIGS=$5 +LANGUAGE_EDITION=$3 +STYLE_EDITION=$4 + +OPTIONAL_COMMIT_HASH=$5 +OPTIONAL_RUSTFMT_CONFIGS=$6 # OUTPUT array used to collect all the status of running diffs on various repos STATUSES=() @@ -48,6 +53,11 @@ function init_submodules() { # $3: Any additional configuration options to pass to rustfmt # # Globals: +# $LANGUAGE_EDITION: Language edition. When not specified, `rustfmt` (like +# `rustc`) will default to Edition 2015, which for the projects being +# compared will likely cause parse errors since they tend to be on +# Edition 2024 (or later). Can still be override by language edition +# specified in `$OPTIONAL_RUSTFMT_CONFIGS`. # $STYLE_EDITION: Style edition; can be overridden by style edition specified in # `$OPTIONAL_RUSTFMT_CONFIGS`. # $OPTIONAL_RUSTFMT_CONFIGS: Optional configs passed to the script @@ -55,6 +65,10 @@ function create_diff() { local config; # Unconditionally set config="--config=error_on_line_overflow=false,error_on_unformatted=false" + # Can still be overridden by later `edition` configurations in + # `$OPTIONAL_RUSTFMT_CONFIGS`. + config="$config,edition=$LANGUAGE_EDITION" + # Can still be overridden by later `style_edition` configurations in # `$OPTIONAL_RUSTFMT_CONFIGS`. config="$config,style_edition=$STYLE_EDITION" @@ -201,6 +215,8 @@ function log_inputs() { echo "$REMOTE_REPO" echo "Feature branch:" echo "$FEATURE_BRANCH" + echo "Language edition:" + echo "$LANGUAGE_EDITION" echo "Style edition:" echo "$STYLE_EDITION" echo "(Optional) Commit hash:"