Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 69ebe43

Browse files
authored
Use 'et format' in CI. Check formatting of all files in CI (#50810)
This PR changes the format check on CI to use the command added in #50747. Additionally, while making this change, I noticed that the CI check was not checking the formatting of all files, and that as a result, files were present in the repo with incorrect formatting. I have fixed the formatting and fixed the check to always check all files.
1 parent 52ffcaa commit 69ebe43

File tree

93 files changed

+564
-1233
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+564
-1233
lines changed

build/copy_info_plist.py

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@
2323

2424
def get_clang_version():
2525
clang_executable = str(
26-
os.path.join(
27-
'..', '..', 'buildtools', 'mac-x64', 'clang', 'bin', 'clang++'
28-
)
26+
os.path.join('..', '..', 'buildtools', 'mac-x64', 'clang', 'bin', 'clang++')
2927
)
3028
version = subprocess.check_output([clang_executable, '--version'])
3129
return version.splitlines()[0]
@@ -39,32 +37,20 @@ def main():
3937
)
4038

4139
parser.add_argument(
42-
'--source',
43-
help='Path to Info.plist source template',
44-
type=str,
45-
required=True
40+
'--source', help='Path to Info.plist source template', type=str, required=True
4641
)
4742
parser.add_argument(
48-
'--destination',
49-
help='Path to destination Info.plist',
50-
type=str,
51-
required=True
52-
)
53-
parser.add_argument(
54-
'--minversion', help='Minimum device OS version like "9.0"', type=str
43+
'--destination', help='Path to destination Info.plist', type=str, required=True
5544
)
45+
parser.add_argument('--minversion', help='Minimum device OS version like "9.0"', type=str)
5646

5747
args = parser.parse_args()
5848

5949
text = open(args.source).read()
6050
engine_path = os.path.join(os.getcwd(), '..', '..', 'flutter')
6151
revision = git_revision.get_repository_version(engine_path)
6252
clang_version = get_clang_version()
63-
text = text.format(
64-
revision=revision,
65-
clang_version=clang_version,
66-
min_version=args.minversion
67-
)
53+
text = text.format(revision=revision, clang_version=clang_version, min_version=args.minversion)
6854

6955
with open(args.destination, 'w') as outfile:
7056
outfile.write(text)

build/dart/tools/dart_pkg.py

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616

1717
USE_LINKS = sys.platform != 'win32'
1818

19-
DART_ANALYZE = os.path.join(
20-
os.path.dirname(os.path.abspath(__file__)), 'dart_analyze.py'
21-
)
19+
DART_ANALYZE = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'dart_analyze.py')
2220

2321

2422
def dart_filter(path):
@@ -164,10 +162,7 @@ def analyze_entrypoints(dart_sdk, package_root, entrypoints):
164162
def main():
165163
parser = argparse.ArgumentParser(description='Generate a dart-pkg')
166164
parser.add_argument(
167-
'--dart-sdk',
168-
action='store',
169-
metavar='dart_sdk',
170-
help='Path to the Dart SDK.'
165+
'--dart-sdk', action='store', metavar='dart_sdk', help='Path to the Dart SDK.'
171166
)
172167
parser.add_argument(
173168
'--package-name',
@@ -183,28 +178,14 @@ def main():
183178
required=True
184179
)
185180
parser.add_argument(
186-
'--package-root',
187-
metavar='package_root',
188-
help='packages/ directory',
189-
required=True
190-
)
191-
parser.add_argument(
192-
'--stamp-file',
193-
metavar='stamp_file',
194-
help='timestamp file',
195-
required=True
181+
'--package-root', metavar='package_root', help='packages/ directory', required=True
196182
)
183+
parser.add_argument('--stamp-file', metavar='stamp_file', help='timestamp file', required=True)
197184
parser.add_argument(
198-
'--entries-file',
199-
metavar='entries_file',
200-
help='script entries file',
201-
required=True
185+
'--entries-file', metavar='entries_file', help='script entries file', required=True
202186
)
203187
parser.add_argument(
204-
'--package-sources',
205-
metavar='package_sources',
206-
help='Package sources',
207-
nargs='+'
188+
'--package-sources', metavar='package_sources', help='Package sources', nargs='+'
208189
)
209190
parser.add_argument(
210191
'--package-entrypoints',
@@ -259,16 +240,12 @@ def main():
259240
sdkext_path = os.path.join(lib_path, '_sdkext')
260241
if mappings:
261242
with open(sdkext_path, 'w') as stream:
262-
json.dump(
263-
mappings, stream, sort_keys=True, indent=2, separators=(',', ': ')
264-
)
243+
json.dump(mappings, stream, sort_keys=True, indent=2, separators=(',', ': '))
265244
else:
266245
remove_if_exists(sdkext_path)
267246

268247
# Copy or symlink package sources into pkg directory.
269-
common_source_prefix = os.path.dirname(
270-
os.path.commonprefix(args.package_sources)
271-
)
248+
common_source_prefix = os.path.dirname(os.path.commonprefix(args.package_sources))
272249
for source in args.package_sources:
273250
relative_source = os.path.relpath(source, common_source_prefix)
274251
target = os.path.join(target_dir, relative_source)
@@ -291,9 +268,7 @@ def main():
291268
target = os.path.join(sdk_ext_dir, relative_source)
292269
copy_or_link(source, target)
293270

294-
common_source_prefix = os.path.dirname(
295-
os.path.commonprefix(args.sdk_ext_files)
296-
)
271+
common_source_prefix = os.path.dirname(os.path.commonprefix(args.sdk_ext_files))
297272
for source in args.sdk_ext_files:
298273
relative_source = os.path.relpath(source, common_source_prefix)
299274
target = os.path.join(sdk_ext_dir, relative_source)

build/generate_coverage.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,15 @@
1313

1414

1515
def get_llvm_bin_directory():
16-
buildtool_dir = os.path.join(
17-
os.path.dirname(os.path.realpath(__file__)), '../../buildtools'
18-
)
16+
buildtool_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), '../../buildtools')
1917
platform_dir = ''
2018
if sys.platform.startswith('linux'):
2119
platform_dir = 'linux-x64'
2220
elif sys.platform == 'darwin':
2321
platform_dir = 'mac-x64'
2422
else:
2523
raise Exception('Unknown/Unsupported platform.')
26-
llvm_bin_dir = os.path.abspath(
27-
os.path.join(buildtool_dir, platform_dir, 'clang/bin')
28-
)
24+
llvm_bin_dir = os.path.abspath(os.path.join(buildtool_dir, platform_dir, 'clang/bin'))
2925
if not os.path.exists(llvm_bin_dir):
3026
raise Exception('LLVM directory %s double not be located.' % llvm_bin_dir)
3127
return llvm_bin_dir
@@ -61,9 +57,7 @@ def collect_profiles(args):
6157
print('Path %s does not exist.' % absolute_test_path)
6258
return -1
6359

64-
unstripped_test_path = os.path.join(
65-
absolute_test_dir, 'exe.unstripped', test_name
66-
)
60+
unstripped_test_path = os.path.join(absolute_test_dir, 'exe.unstripped', test_name)
6761

6862
if os.path.exists(unstripped_test_path):
6963
binaries.append(unstripped_test_path)
@@ -74,10 +68,7 @@ def collect_profiles(args):
7468

7569
remove_if_exists(raw_profile)
7670

77-
print(
78-
'Running test %s to gather profile.' %
79-
os.path.basename(absolute_test_path)
80-
)
71+
print('Running test %s to gather profile.' % os.path.basename(absolute_test_path))
8172

8273
test_command = [absolute_test_path]
8374

@@ -105,8 +96,7 @@ def merge_profiles(llvm_bin_dir, raw_profiles, output):
10596
print('Merging %d raw profile(s) into single profile.' % len(raw_profiles))
10697
merged_profile_path = os.path.join(output, 'all.profile')
10798
remove_if_exists(merged_profile_path)
108-
merge_command = [profdata_binary, 'merge', '-sparse'
109-
] + raw_profiles + ['-o', merged_profile_path]
99+
merge_command = [profdata_binary, 'merge', '-sparse'] + raw_profiles + ['-o', merged_profile_path]
110100
subprocess.check_call(merge_command)
111101
print('Done.')
112102
return merged_profile_path

build/git_revision.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ def main():
4040
parser = argparse.ArgumentParser()
4141

4242
parser.add_argument(
43-
'--repository',
44-
action='store',
45-
help='Path to the Git repository.',
46-
required=True
43+
'--repository', action='store', help='Path to the Git repository.', required=True
4744
)
4845

4946
args = parser.parse_args()

build/zip.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,10 @@ def _zip_dir(path, zip_file, prefix):
2525
for file in files:
2626
if os.path.islink(os.path.join(root, file)):
2727
add_symlink(
28-
zip_file, os.path.join(root, file),
29-
os.path.join(root.replace(path, prefix), file)
28+
zip_file, os.path.join(root, file), os.path.join(root.replace(path, prefix), file)
3029
)
3130
continue
32-
zip_file.write(
33-
os.path.join(root, file),
34-
os.path.join(root.replace(path, prefix), file)
35-
)
31+
zip_file.write(os.path.join(root, file), os.path.join(root.replace(path, prefix), file))
3632

3733

3834
def add_symlink(zip_file, source, target):
@@ -80,12 +76,7 @@ def main(args):
8076

8177
if __name__ == '__main__':
8278
parser = argparse.ArgumentParser(description='This script creates zip files.')
83-
parser.add_argument(
84-
'-o',
85-
dest='output',
86-
action='store',
87-
help='The name of the output zip file.'
88-
)
79+
parser.add_argument('-o', dest='output', action='store', help='The name of the output zip file.')
8980
parser.add_argument(
9081
'-i',
9182
dest='input_pairs',
@@ -94,9 +85,6 @@ def main(args):
9485
help='The input file and its destination location in the zip archive.'
9586
)
9687
parser.add_argument(
97-
'-f',
98-
dest='source_file',
99-
action='store',
100-
help='The path to the file list to zip.'
88+
'-f', dest='source_file', action='store', help='The path to the file list to zip.'
10189
)
10290
sys.exit(main(parser.parse_args()))

ci/builders/linux_unopt.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,13 @@
3737
},
3838
"tests": [
3939
{
40-
"name": "test:format_and_dart_test",
41-
"script": "flutter/ci/format.sh"
40+
"name": "test: Check formatting",
41+
"script": "flutter/bin/et",
42+
"parameters": [
43+
"format",
44+
"--dry-run",
45+
"--all"
46+
]
4247
},
4348
{
4449
"nane": "test:GeneratedPluginRegistant.java omitted",

ci/compatibility_helper.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,4 @@ def byte_str_decode(str_or_bytes):
2121
the possible value changes depending on the version of python
2222
used.
2323
"""
24-
return str_or_bytes if isinstance(str_or_bytes,
25-
str) else str_or_bytes.decode(ENCODING)
24+
return str_or_bytes if isinstance(str_or_bytes, str) else str_or_bytes.decode(ENCODING)

ci/impeller_cmake_build_test.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
# out/impeller-cmake-example, so the build can then be performed with
1616
# e.g. ninja -C out/impeller-cmake-example-out.
1717

18-
SRC_ROOT = os.path.dirname(
19-
os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
20-
)
18+
SRC_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
2119

2220

2321
def parse_args(argv):
@@ -122,9 +120,7 @@ def main(argv):
122120
return 0
123121

124122
if args.cmake:
125-
cmake_path = os.path.join(
126-
SRC_ROOT, 'buildtools', 'mac-x64', 'cmake', 'bin', 'cmake'
127-
)
123+
cmake_path = os.path.join(SRC_ROOT, 'buildtools', 'mac-x64', 'cmake', 'bin', 'cmake')
128124
cmake_command = [
129125
cmake_path,
130126
'--preset',

ci/scan_deps.py

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -79,27 +79,20 @@ def extract_deps(deps_file):
7979
continue
8080

8181
dep_split = dep.rsplit('@', 1)
82-
ancestor_result = get_common_ancestor([dep_split[0], dep_split[1]],
83-
deps_list)
82+
ancestor_result = get_common_ancestor([dep_split[0], dep_split[1]], deps_list)
8483
if ancestor_result:
8584
filtered_osv_deps.append({
8685
'package': {'name': ancestor_result[1], 'commit': ancestor_result[0]}
8786
})
8887

8988
try:
9089
# Clean up cloned upstream dependency directory.
91-
shutil.rmtree(
92-
DEP_CLONE_DIR
93-
) # Use shutil.rmtree since dir could be non-empty.
90+
shutil.rmtree(DEP_CLONE_DIR) # Use shutil.rmtree since dir could be non-empty.
9491
except OSError as clone_dir_error:
95-
print(
96-
'Error cleaning up clone directory: %s : %s' %
97-
(DEP_CLONE_DIR, clone_dir_error.strerror)
98-
)
92+
print('Error cleaning up clone directory: %s : %s' % (DEP_CLONE_DIR, clone_dir_error.strerror))
9993

10094
osv_result = {
101-
'packageSource': {'path': deps_file, 'type': 'lockfile'},
102-
'packages': filtered_osv_deps
95+
'packageSource': {'path': deps_file, 'type': 'lockfile'}, 'packages': filtered_osv_deps
10396
}
10497
return osv_result
10598

@@ -150,19 +143,12 @@ def get_common_ancestor(dep, deps_list):
150143
upstream = deps_list.get(UPSTREAM_PREFIX + dep_name)
151144
temp_dep_dir = DEP_CLONE_DIR + '/' + dep_name
152145
# Clone dependency from mirror.
153-
subprocess.check_output(['git', 'clone', '--quiet', '--', dep[0], dep_name],
154-
cwd=DEP_CLONE_DIR)
146+
subprocess.check_output(['git', 'clone', '--quiet', '--', dep[0], dep_name], cwd=DEP_CLONE_DIR)
155147

156148
# Create branch that will track the upstream dep.
157-
print(
158-
'attempting to add upstream remote from: {upstream}'.format(
159-
upstream=upstream
160-
)
161-
)
162-
subprocess.check_output(['git', 'remote', 'add', 'upstream', upstream],
163-
cwd=temp_dep_dir)
164-
subprocess.check_output(['git', 'fetch', '--quiet', 'upstream'],
165-
cwd=temp_dep_dir)
149+
print('attempting to add upstream remote from: {upstream}'.format(upstream=upstream))
150+
subprocess.check_output(['git', 'remote', 'add', 'upstream', upstream], cwd=temp_dep_dir)
151+
subprocess.check_output(['git', 'fetch', '--quiet', 'upstream'], cwd=temp_dep_dir)
166152
# Get name of the default branch for upstream (e.g. main/master/etc.).
167153
default_branch = subprocess.check_output(
168154
'git remote show upstream ' + "| sed -n \'/HEAD branch/s/.*: //p\'",
@@ -174,14 +160,12 @@ def get_common_ancestor(dep, deps_list):
174160

175161
# Make upstream branch track the upstream dep.
176162
subprocess.check_output([
177-
'git', 'checkout', '--force', '-b', 'upstream', '--track',
178-
'upstream/' + default_branch
163+
'git', 'checkout', '--force', '-b', 'upstream', '--track', 'upstream/' + default_branch
179164
],
180165
cwd=temp_dep_dir)
181166
# Get the most recent commit from default branch of upstream.
182167
commit = subprocess.check_output(
183-
'git for-each-ref ' +
184-
"--format=\'%(objectname:short)\' refs/heads/upstream",
168+
'git for-each-ref ' + "--format=\'%(objectname:short)\' refs/heads/upstream",
185169
cwd=temp_dep_dir,
186170
shell=True
187171
)
@@ -211,9 +195,7 @@ def get_common_ancestor(dep, deps_list):
211195

212196
def parse_args(args):
213197
args = args[1:]
214-
parser = argparse.ArgumentParser(
215-
description='A script to find common ancestor commit SHAs'
216-
)
198+
parser = argparse.ArgumentParser(description='A script to find common ancestor commit SHAs')
217199

218200
parser.add_argument(
219201
'--deps',

display_list/skia/dl_sk_conversions_unittests.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,9 @@ TEST(DisplayListSkConversions, ToSkSamplingOptions) {
142142
FUNC(kLastSeparableMode) \
143143
FUNC(kLastMode)
144144

145-
TEST(DisplayListSkConversions, ToSkBlendMode) {
145+
TEST(DisplayListSkConversions, ToSkBlendMode){
146146
#define CHECK_TO_SKENUM(V) ASSERT_EQ(ToSk(DlBlendMode::V), SkBlendMode::V);
147-
FOR_EACH_BLEND_MODE_ENUM(CHECK_TO_SKENUM)
147+
FOR_EACH_BLEND_MODE_ENUM(CHECK_TO_SKENUM)
148148
#undef CHECK_TO_SKENUM
149149
}
150150

display_list/testing/dl_rendering_unittests.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2232,8 +2232,8 @@ class CanvasCompareTester {
22322232
return DirectoryStatus::kCreated;
22332233
}
22342234
FML_LOG(ERROR) << "Could not create directory (" << dir
2235-
<< ") for impeller failure images"
2236-
<< ", ret = " << ret.get() << ", errno = " << errno;
2235+
<< ") for impeller failure images" << ", ret = " << ret.get()
2236+
<< ", errno = " << errno;
22372237
return DirectoryStatus::kFailed;
22382238
}
22392239

0 commit comments

Comments
 (0)