Skip to content

Commit de4e3e7

Browse files
committed
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.
1 parent e51147d commit de4e3e7

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

.github/workflows/check_diff.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ on:
88
branch_name:
99
description: 'Name of the feature branch on the forked repo'
1010
required: true
11+
language_edition:
12+
description: 'Language edition to run both rustfmt with; can be overridden by language edition settings in `rustfmt_configs`'
13+
required: true
1114
style_edition:
1215
description: 'Style edition to run both rustfmt with; can be overridden by style edition settings in `rustfmt_configs`'
1316
required: true
@@ -33,4 +36,4 @@ jobs:
3336
rustup target add x86_64-unknown-linux-gnu
3437
3538
- name: check diff
36-
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 }}
39+
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 }}

ci/check_diff.sh

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
set -e
44

55
function print_usage() {
6-
echo "usage check_diff REMOTE_REPO FEATURE_BRANCH STYLE_EDITION [COMMIT_HASH] [OPTIONAL_RUSTFMT_CONFIGS]"
6+
echo "usage check_diff REMOTE_REPO FEATURE_BRANCH LANGUAGE_EDITION STYLE_EDITION [COMMIT_HASH] [OPTIONAL_RUSTFMT_CONFIGS]"
77
}
88

99
if [ $# -le 1 ]; then
@@ -13,12 +13,17 @@ fi
1313

1414
REMOTE_REPO=$1
1515
FEATURE_BRANCH=$2
16-
# Can still be overridden by style edition configuration in `OPTIONAL_RUSTFMT_CONFIGS`. This is a
17-
# separate arg mostly to make sure it's not forgotten when manually dispatching the Diff Check
16+
17+
# Required language edition and style edition inputs.
18+
#
19+
# Can still be overridden by style edition configuration in `OPTIONAL_RUSTFMT_CONFIGS`. They are
20+
# separate arg mostly to make sure they are not forgotten when manually dispatching the Diff Check
1821
# workflow.
19-
STYLE_EDITION=$3
20-
OPTIONAL_COMMIT_HASH=$4
21-
OPTIONAL_RUSTFMT_CONFIGS=$5
22+
LANGUAGE_EDITION=$3
23+
STYLE_EDITION=$4
24+
25+
OPTIONAL_COMMIT_HASH=$5
26+
OPTIONAL_RUSTFMT_CONFIGS=$6
2227

2328
# OUTPUT array used to collect all the status of running diffs on various repos
2429
STATUSES=()
@@ -48,13 +53,22 @@ function init_submodules() {
4853
# $3: Any additional configuration options to pass to rustfmt
4954
#
5055
# Globals:
56+
# $LANGUAGE_EDITION: Language edition. When not specified, `rustfmt` (like
57+
# `rustc`) will default to Edition 2015, which for the projects being
58+
# compared will likely cause parse errors since they tend to be on
59+
# Edition 2024 (or later). Can still be override by language edition
60+
# specified in `$OPTIONAL_RUSTFMT_CONFIGS`.
5161
# $STYLE_EDITION: Style edition; can be overridden by style edition specified in
5262
# `$OPTIONAL_RUSTFMT_CONFIGS`.
5363
# $OPTIONAL_RUSTFMT_CONFIGS: Optional configs passed to the script
5464
function create_diff() {
5565
local config;
5666
# Unconditionally set
5767
config="--config=error_on_line_overflow=false,error_on_unformatted=false"
68+
# Can still be overridden by later `edition` configurations in
69+
# `$OPTIONAL_RUSTFMT_CONFIGS`.
70+
config="$config,edition=$LANGUAGE_EDITION"
71+
5872
# Can still be overridden by later `style_edition` configurations in
5973
# `$OPTIONAL_RUSTFMT_CONFIGS`.
6074
config="$config,style_edition=$STYLE_EDITION"
@@ -201,6 +215,8 @@ function log_inputs() {
201215
echo "$REMOTE_REPO"
202216
echo "Feature branch:"
203217
echo "$FEATURE_BRANCH"
218+
echo "Language edition:"
219+
echo "$LANGUAGE_EDITION"
204220
echo "Style edition:"
205221
echo "$STYLE_EDITION"
206222
echo "(Optional) Commit hash:"

0 commit comments

Comments
 (0)