Skip to content

Commit f04c92f

Browse files
committed
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.
1 parent a71bacc commit f04c92f

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
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+
style_edition:
12+
description: 'Style edition to run both rustfmt with; can be overridden by style edition settings in `rustfmt_configs`'
13+
required: true
1114
commit_hash:
1215
description: 'Optional commit hash from the feature branch'
1316
required: false
@@ -30,4 +33,4 @@ jobs:
3033
rustup target add x86_64-unknown-linux-gnu
3134
3235
- 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 }}
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 }}

ci/check_diff.sh

Lines changed: 19 additions & 7 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 STYLE_EDITION [COMMIT_HASH] [OPTIONAL_RUSTFMT_CONFIGS]"
77
}
88

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

1414
REMOTE_REPO=$1
1515
FEATURE_BRANCH=$2
16-
OPTIONAL_COMMIT_HASH=$3
17-
OPTIONAL_RUSTFMT_CONFIGS=$4
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
18+
# workflow.
19+
STYLE_EDITION=$3
20+
OPTIONAL_COMMIT_HASH=$4
21+
OPTIONAL_RUSTFMT_CONFIGS=$5
1822

1923
# OUTPUT array used to collect all the status of running diffs on various repos
2024
STATUSES=()
@@ -44,13 +48,19 @@ function init_submodules() {
4448
# $3: Any additional configuration options to pass to rustfmt
4549
#
4650
# Globals:
47-
# $OPTIONAL_RUSTFMT_CONFIGS: Optional configs passed to the script from $4
51+
# $STYLE_EDITION: Style edition; can be overridden by style edition specified in
52+
# `$OPTIONAL_RUSTFMT_CONFIGS`.
53+
# $OPTIONAL_RUSTFMT_CONFIGS: Optional configs passed to the script
4854
function create_diff() {
4955
local config;
56+
# Unconditionally set
57+
config="--config=error_on_line_overflow=false,error_on_unformatted=false"
58+
# Can still be overridden by later `style_edition` configurations in
59+
# `$OPTIONAL_RUSTFMT_CONFIGS`.
60+
config="$config,style_edition=$STYLE_EDITION"
61+
5062
if [ -z "$3" ]; then
51-
config="--config=error_on_line_overflow=false,error_on_unformatted=false"
52-
else
53-
config="--config=error_on_line_overflow=false,error_on_unformatted=false,$OPTIONAL_RUSTFMT_CONFIGS"
63+
config="$config,$OPTIONAL_RUSTFMT_CONFIGS"
5464
fi
5565

5666
for i in `find . | grep "\.rs$"`
@@ -191,6 +201,8 @@ function log_inputs() {
191201
echo "$REMOTE_REPO"
192202
echo "Feature branch:"
193203
echo "$FEATURE_BRANCH"
204+
echo "Style edition:"
205+
echo "$STYLE_EDITION"
194206
echo "(Optional) Commit hash:"
195207
echo "$OPTIONAL_COMMIT_HASH"
196208
echo "(Optional) Rustfmt configs:"

0 commit comments

Comments
 (0)