Skip to content

Commit 687d71c

Browse files
committed
Add edition + style_edition as options when running the Diff Check
Both of these options impact how code is parsed and formatted. Additionally, both `style_edition={2015,2018,2021}` and `style_edition=2024` are stable so we'll need a way to easily check both in CI to make sure we don't introduce any unexpected breaking changes.
1 parent 3b3758c commit 687d71c

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

.github/workflows/check_diff.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,24 @@ on:
88
branch_name:
99
description: 'Name of the feature branch on the forked repo'
1010
required: true
11+
edition:
12+
description: 'Which rust `edition` to use when parsing code'
13+
required: true
14+
type: choice
15+
options:
16+
- '2015'
17+
- '2018'
18+
- '2021'
19+
- '2024'
20+
default: '2015'
21+
style_edition:
22+
description: 'Which rustfmt `style_edition` to use when formatting'
23+
required: true
24+
type: choice
25+
options:
26+
- '2021' # 2015, 2018, and 2021 are all the same for `style_edition`
27+
- '2024'
28+
default: '2021'
1129
commit_hash:
1230
description: 'Optional commit hash from the feature branch'
1331
required: false
@@ -30,4 +48,4 @@ jobs:
3048
rustup target add x86_64-unknown-linux-gnu
3149
3250
- name: check diff
33-
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 }}
51+
run: bash ${GITHUB_WORKSPACE}/ci/check_diff.sh ${{ github.event.inputs.clone_url }} ${{ github.event.inputs.branch_name }} ${{ github.event.inputs.edition }} ${{ github.event.inputs.style_edition }} ${{ github.event.inputs.commit_hash || github.event.inputs.branch_name }} ${{ github.event.inputs.rustfmt_configs }}

ci/check_diff.sh

Lines changed: 7 additions & 4 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 [COMMIT_HASH] [OPTIONAL_RUSTFMT_CONFIGS]"
6+
echo "usage check_diff REMOTE_REPO FEATURE_BRANCH EDITION STYLE_EDITION [COMMIT_HASH] [OPTIONAL_RUSTFMT_CONFIGS]"
77
}
88

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

1414
REMOTE_REPO=$1
1515
FEATURE_BRANCH=$2
16-
OPTIONAL_COMMIT_HASH=$3
17-
OPTIONAL_RUSTFMT_CONFIGS=$4
16+
EDITION=${3:-2015}
17+
STYLE_EDITION=${4:-2021}
18+
OPTIONAL_COMMIT_HASH=$5
19+
OPTIONAL_RUSTFMT_CONFIGS=$6
1820

1921
# OUTPUT array used to collect all the status of running diffs on various repos
2022
STATUSES=()
@@ -55,7 +57,7 @@ function create_diff() {
5557

5658
for i in `find . | grep "\.rs$"`
5759
do
58-
$1 --unstable-features --skip-children --check --color=always $config $i >> $2 2>/dev/null
60+
$1 --edition=$EDITION --style-edition $STYLE_EDITION --unstable-features --skip-children --check --color=always $config $i >> $2 2>/dev/null
5961
done
6062
}
6163

@@ -189,6 +191,7 @@ function main() {
189191
echo Created tmp_dir $tmp_dir
190192

191193
compile_rustfmt $tmp_dir
194+
echo Parsing code with rust edition $EDITION and formatting code with style_edition $STYLE_EDITION
192195

193196
# run checks
194197
check_repo "https://github.com/rust-lang/rust.git" rust-lang-rust

0 commit comments

Comments
 (0)