Skip to content

Commit 27ee43c

Browse files
committed
Merge remote-tracking branch 'upstream/master' into syncing-strategy-refactoring-part-3
# Conflicts: # substrate/client/network/sync/src/strategy/chain_sync.rs
2 parents 87be088 + aeebf2f commit 27ee43c

File tree

1,496 files changed

+63953
-27279
lines changed

Some content is hidden

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

1,496 files changed

+63953
-27279
lines changed

.github/actions/set-up-gh/action.yml

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
name: 'install gh'
2-
description: 'Install the gh cli in a debian based distro and switches to the PR branch.'
1+
name: "install gh"
2+
description: "Install the gh cli in a debian based distro and switches to the PR branch."
33
inputs:
44
pr-number:
55
description: "Number of the PR"
@@ -9,28 +9,20 @@ inputs:
99
required: true
1010
outputs:
1111
branch:
12-
description: 'Branch name for the PR'
12+
description: "Branch name for the PR"
1313
value: ${{ steps.branch.outputs.branch }}
1414
runs:
1515
using: "composite"
1616
steps:
17-
- name: Instal gh cli
18-
shell: bash
19-
# Here it would get the script from previous step
20-
run: |
21-
(type -p wget >/dev/null || (apt update && apt-get install wget -y))
22-
mkdir -p -m 755 /etc/apt/keyrings
23-
wget -qO- https://cli.github.com/packages/githubcli-archive-keyring.gpg | tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null
24-
chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg
25-
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null
26-
apt update
27-
apt install gh -y
28-
git config --global --add safe.directory '*'
29-
- run: gh pr checkout ${{ inputs.pr-number }}
30-
shell: bash
31-
env:
32-
GITHUB_TOKEN: ${{ inputs.GH_TOKEN }}
33-
- name: Export branch name
34-
shell: bash
35-
run: echo "branch=$(git rev-parse --abbrev-ref HEAD)" >> "$GITHUB_OUTPUT"
36-
id: branch
17+
- name: Set up git
18+
shell: bash
19+
# Here it would get the script from previous step
20+
run: git config --global --add safe.directory '*'
21+
- run: gh pr checkout ${{ inputs.pr-number }}
22+
shell: bash
23+
env:
24+
GITHUB_TOKEN: ${{ inputs.GH_TOKEN }}
25+
- name: Export branch name
26+
shell: bash
27+
run: echo "branch=$(git rev-parse --abbrev-ref HEAD)" >> "$GITHUB_OUTPUT"
28+
id: branch

.github/env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
IMAGE="docker.io/paritytech/ci-unified:bullseye-1.77.0-2024-04-10-v202407161507"
1+
IMAGE="docker.io/paritytech/ci-unified:bullseye-1.81.0-2024-09-11-v202409111034"

.github/scripts/cmd/cmd.py

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,30 @@
1515
runtimeNames = list(map(lambda x: x['name'], runtimesMatrix))
1616

1717
common_args = {
18-
'--continue-on-fail': {"action": "store_true", "help": "Won't exit(1) on failed command and continue with next steps. "},
1918
'--quiet': {"action": "store_true", "help": "Won't print start/end/failed messages in PR"},
2019
'--clean': {"action": "store_true", "help": "Clean up the previous bot's & author's comments in PR"},
2120
'--image': {"help": "Override docker image '--image docker.io/paritytech/ci-unified:latest'"},
2221
}
2322

23+
def print_and_log(message, output_file='/tmp/cmd/command_output.log'):
24+
print(message)
25+
with open(output_file, 'a') as f:
26+
f.write(message + '\n')
27+
28+
def setup_logging():
29+
if not os.path.exists('/tmp/cmd'):
30+
os.makedirs('/tmp/cmd')
31+
open('/tmp/cmd/command_output.log', 'w')
32+
2433
parser = argparse.ArgumentParser(prog="/cmd ", description='A command runner for polkadot-sdk repo', add_help=False)
2534
parser.add_argument('--help', action=_HelpAction, help='help for help if you need some help') # help for help
2635
for arg, config in common_args.items():
2736
parser.add_argument(arg, **config)
2837

2938
subparsers = parser.add_subparsers(help='a command to run', dest='command')
3039

40+
setup_logging()
41+
3142
"""
3243
BENCH
3344
"""
@@ -39,8 +50,8 @@
3950
Runs benchmarks for pallet_balances and pallet_multisig for all runtimes which have these pallets. **--quiet** makes it to output nothing to PR but reactions
4051
%(prog)s --pallet pallet_balances pallet_xcm_benchmarks::generic --quiet
4152
42-
Runs bench for all pallets for westend runtime and continues even if some benchmarks fail
43-
%(prog)s --runtime westend --continue-on-fail
53+
Runs bench for all pallets for westend runtime and fails fast on first failed benchmark
54+
%(prog)s --runtime westend --fail-fast
4455
4556
Does not output anything and cleans up the previous bot's & author command triggering comments in PR
4657
%(prog)s --runtime westend rococo --pallet pallet_balances pallet_multisig --quiet --clean
@@ -53,6 +64,7 @@
5364

5465
parser_bench.add_argument('--runtime', help='Runtime(s) space separated', choices=runtimeNames, nargs='*', default=runtimeNames)
5566
parser_bench.add_argument('--pallet', help='Pallet(s) space separated', nargs='*', default=[])
67+
parser_bench.add_argument('--fail-fast', help='Fail fast on first failed benchmark', action='store_true')
5668

5769
"""
5870
FMT
@@ -77,7 +89,7 @@
7789
spec.loader.exec_module(generate_prdoc)
7890

7991
parser_prdoc = subparsers.add_parser('prdoc', help='Generates PR documentation')
80-
generate_prdoc.setup_parser(parser_prdoc)
92+
generate_prdoc.setup_parser(parser_prdoc, pr_required=False)
8193

8294
def main():
8395
global args, unknown, runtimesMatrix
@@ -100,11 +112,11 @@ def main():
100112

101113
# loop over remaining runtimes to collect available pallets
102114
for runtime in runtimesMatrix.values():
103-
os.system(f"forklift cargo build -p {runtime['package']} --profile {profile} --features runtime-benchmarks")
115+
os.system(f"forklift cargo build -p {runtime['package']} --profile {profile} --features={runtime['bench_features']}")
104116
print(f'-- listing pallets for benchmark for {runtime["name"]}')
105117
wasm_file = f"target/{profile}/wbuild/{runtime['package']}/{runtime['package'].replace('-', '_')}.wasm"
106118
output = os.popen(
107-
f"frame-omni-bencher v1 benchmark pallet --no-csv-header --no-storage-info --no-min-squares --no-median-slopes --all --list --runtime={wasm_file}").read()
119+
f"frame-omni-bencher v1 benchmark pallet --no-csv-header --no-storage-info --no-min-squares --no-median-slopes --all --list --runtime={wasm_file} {runtime['bench_flags']}").read()
108120
raw_pallets = output.strip().split('\n')
109121

110122
all_pallets = set()
@@ -156,7 +168,9 @@ def main():
156168
manifest_path = os.popen(search_manifest_path).read()
157169
if not manifest_path:
158170
print(f'-- pallet {pallet} not found in dev runtime')
159-
exit(1)
171+
if args.fail_fast:
172+
print_and_log(f'Error: {pallet} not found in dev runtime')
173+
sys.exit(1)
160174
package_dir = os.path.dirname(manifest_path)
161175
print(f'-- package_dir: {package_dir}')
162176
print(f'-- manifest_path: {manifest_path}')
@@ -182,11 +196,13 @@ def main():
182196
f"--repeat=20 " \
183197
f"--heap-pages=4096 " \
184198
f"{f'--template={template} ' if template else ''}" \
185-
f"--no-storage-info --no-min-squares --no-median-slopes"
199+
f"--no-storage-info --no-min-squares --no-median-slopes " \
200+
f"{config['bench_flags']}"
186201
print(f'-- Running: {cmd} \n')
187202
status = os.system(cmd)
188-
if status != 0 and not args.continue_on_fail:
189-
print(f'Failed to benchmark {pallet} in {runtime}')
203+
204+
if status != 0 and args.fail_fast:
205+
print_and_log(f'❌ Failed to benchmark {pallet} in {runtime}')
190206
sys.exit(1)
191207

192208
# Otherwise collect failed benchmarks and print them at the end
@@ -197,39 +213,39 @@ def main():
197213
successful_benchmarks[f'{runtime}'] = successful_benchmarks.get(f'{runtime}', []) + [pallet]
198214

199215
if failed_benchmarks:
200-
print('❌ Failed benchmarks of runtimes/pallets:')
216+
print_and_log('❌ Failed benchmarks of runtimes/pallets:')
201217
for runtime, pallets in failed_benchmarks.items():
202-
print(f'-- {runtime}: {pallets}')
218+
print_and_log(f'-- {runtime}: {pallets}')
203219

204220
if successful_benchmarks:
205-
print('✅ Successful benchmarks of runtimes/pallets:')
221+
print_and_log('✅ Successful benchmarks of runtimes/pallets:')
206222
for runtime, pallets in successful_benchmarks.items():
207-
print(f'-- {runtime}: {pallets}')
223+
print_and_log(f'-- {runtime}: {pallets}')
208224

209225
elif args.command == 'fmt':
210226
command = f"cargo +nightly fmt"
211227
print(f'Formatting with `{command}`')
212228
nightly_status = os.system(f'{command}')
213229
taplo_status = os.system('taplo format --config .config/taplo.toml')
214230

215-
if (nightly_status != 0 or taplo_status != 0) and not args.continue_on_fail:
216-
print('❌ Failed to format code')
231+
if (nightly_status != 0 or taplo_status != 0):
232+
print_and_log('❌ Failed to format code')
217233
sys.exit(1)
218234

219235
elif args.command == 'update-ui':
220236
command = 'sh ./scripts/update-ui-tests.sh'
221237
print(f'Updating ui with `{command}`')
222238
status = os.system(f'{command}')
223239

224-
if status != 0 and not args.continue_on_fail:
225-
print('❌ Failed to format code')
240+
if status != 0:
241+
print_and_log('❌ Failed to update ui')
226242
sys.exit(1)
227243

228244
elif args.command == 'prdoc':
229245
# Call the main function from ./github/scripts/generate-prdoc.py module
230246
exit_code = generate_prdoc.main(args)
231-
if exit_code != 0 and not args.continue_on_fail:
232-
print('❌ Failed to generate prdoc')
247+
if exit_code != 0:
248+
print_and_log('❌ Failed to generate prdoc')
233249
sys.exit(exit_code)
234250

235251
print('🚀 Done')

0 commit comments

Comments
 (0)