forked from paritytech/polkadot-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
286 changed files
with
11,008 additions
and
7,301 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
#!/usr/bin/env python3 | ||
|
||
""" | ||
Generate the PrDoc for a Pull Request with a specific number, audience and bump level. | ||
It downloads and parses the patch from the GitHub API to opulate the prdoc with all modified crates. | ||
This will delete any prdoc that already exists for the PR if `--force` is passed. | ||
Usage: | ||
python generate-prdoc.py --pr 1234 --audience "TODO" --bump "TODO" | ||
""" | ||
|
||
import argparse | ||
import os | ||
import re | ||
import sys | ||
import subprocess | ||
import toml | ||
import yaml | ||
import requests | ||
|
||
from github import Github | ||
import whatthepatch | ||
from cargo_workspace import Workspace | ||
|
||
# Download the patch and pass the info into `create_prdoc`. | ||
def from_pr_number(n, audience, bump, force): | ||
print(f"Fetching PR '{n}' from GitHub") | ||
g = Github() | ||
|
||
repo = g.get_repo("paritytech/polkadot-sdk") | ||
pr = repo.get_pull(n) | ||
|
||
patch_url = pr.patch_url | ||
patch = requests.get(patch_url).text | ||
|
||
create_prdoc(n, audience, pr.title, pr.body, patch, bump, force) | ||
|
||
def create_prdoc(pr, audience, title, description, patch, bump, force): | ||
path = f"prdoc/pr_{pr}.prdoc" | ||
|
||
if os.path.exists(path): | ||
if force == True: | ||
print(f"Overwriting existing PrDoc for PR {pr}") | ||
else: | ||
print(f"PrDoc already exists for PR {pr}. Use --force to overwrite.") | ||
sys.exit(1) | ||
else: | ||
print(f"No preexisting PrDoc for PR {pr}") | ||
|
||
prdoc = { "doc": [{}], "crates": [] } | ||
|
||
prdoc["title"] = title | ||
prdoc["doc"][0]["audience"] = audience | ||
prdoc["doc"][0]["description"] = description | ||
|
||
workspace = Workspace.from_path(".") | ||
|
||
modified_paths = [] | ||
for diff in whatthepatch.parse_patch(patch): | ||
modified_paths.append(diff.header.new_path) | ||
|
||
modified_crates = {} | ||
for p in modified_paths: | ||
# Go up until we find a Cargo.toml | ||
p = os.path.join(workspace.path, p) | ||
while not os.path.exists(os.path.join(p, "Cargo.toml")): | ||
p = os.path.dirname(p) | ||
|
||
with open(os.path.join(p, "Cargo.toml")) as f: | ||
manifest = toml.load(f) | ||
|
||
if not "package" in manifest: | ||
print(f"File was not in any crate: {p}") | ||
continue | ||
|
||
crate_name = manifest["package"]["name"] | ||
if workspace.crate_by_name(crate_name).publish: | ||
modified_crates[crate_name] = True | ||
else: | ||
print(f"Skipping unpublished crate: {crate_name}") | ||
|
||
print(f"Modified crates: {modified_crates.keys()}") | ||
|
||
for crate_name in modified_crates.keys(): | ||
entry = { "name": crate_name } | ||
|
||
if bump == 'silent' or bump == 'ignore' or bump == 'no change': | ||
entry["validate"] = False | ||
else: | ||
entry["bump"] = bump | ||
|
||
print(f"Adding crate {entry}") | ||
prdoc["crates"].append(entry) | ||
|
||
# write the parsed PR documentation back to the file | ||
with open(path, "w") as f: | ||
yaml.dump(prdoc, f) | ||
|
||
def parse_args(): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("--pr", type=int, required=True) | ||
parser.add_argument("--audience", type=str, default="TODO") | ||
parser.add_argument("--bump", type=str, default="TODO") | ||
parser.add_argument("--force", type=str) | ||
return parser.parse_args() | ||
|
||
if __name__ == "__main__": | ||
args = parse_args() | ||
force = True if args.force.lower() == "true" else False | ||
print(f"Args: {args}, force: {force}") | ||
from_pr_number(args.pr, args.audience, args.bump, force) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
name: Short benchmarks (frame-omni-bencher) | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
types: [ opened, synchronize, reopened, ready_for_review, labeled ] | ||
merge_group: | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
|
||
env: | ||
ARTIFACTS_NAME: frame-omni-bencher-artifacts | ||
|
||
jobs: | ||
changes: | ||
# TODO: remove once migration is complete or this workflow is fully stable | ||
if: contains(github.event.label.name, 'GHA-migration') | ||
permissions: | ||
pull-requests: read | ||
uses: ./.github/workflows/reusable-check-changed-files.yml | ||
|
||
set-image: | ||
# GitHub Actions allows using 'env' in a container context. | ||
# However, env variables don't work for forks: https://github.com/orgs/community/discussions/44322 | ||
# This workaround sets the container image for each job using 'set-image' job output. | ||
runs-on: ubuntu-latest | ||
needs: changes | ||
if: ${{ needs.changes.outputs.rust }} | ||
outputs: | ||
IMAGE: ${{ steps.set_image.outputs.IMAGE }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- id: set_image | ||
run: cat .github/env >> $GITHUB_OUTPUT | ||
|
||
run-frame-omni-bencher: | ||
runs-on: arc-runners-polkadot-sdk-beefy | ||
needs: [ set-image, changes ] # , build-frame-omni-bencher ] | ||
if: ${{ needs.changes.outputs.rust }} | ||
timeout-minutes: 30 | ||
strategy: | ||
fail-fast: false # keep running other workflows even if one fails, to see the logs of all possible failures | ||
matrix: | ||
runtime: | ||
[ | ||
westend-runtime, | ||
rococo-runtime, | ||
asset-hub-rococo-runtime, | ||
asset-hub-westend-runtime, | ||
bridge-hub-rococo-runtime, | ||
bridge-hub-westend-runtime, | ||
collectives-westend-runtime, | ||
coretime-rococo-runtime, | ||
coretime-westend-runtime, | ||
people-rococo-runtime, | ||
people-westend-runtime, | ||
glutton-westend-runtime, | ||
] | ||
container: | ||
image: ${{ needs.set-image.outputs.IMAGE }} | ||
env: | ||
PACKAGE_NAME: ${{ matrix.runtime }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: script | ||
run: | | ||
RUNTIME_BLOB_NAME=$(echo $PACKAGE_NAME | sed 's/-/_/g').compact.compressed.wasm | ||
RUNTIME_BLOB_PATH=./target/release/wbuild/$PACKAGE_NAME/$RUNTIME_BLOB_NAME | ||
forklift cargo build --release --locked -p $PACKAGE_NAME -p frame-omni-bencher --features runtime-benchmarks | ||
echo "Running short benchmarking for PACKAGE_NAME=$PACKAGE_NAME and RUNTIME_BLOB_PATH=$RUNTIME_BLOB_PATH" | ||
ls -lrt $RUNTIME_BLOB_PATH | ||
./target/release/frame-omni-bencher v1 benchmark pallet --runtime $RUNTIME_BLOB_PATH --all --steps 2 --repeat 1 | ||
confirm-frame-omni-benchers-passed: | ||
runs-on: ubuntu-latest | ||
name: All benchmarks passed | ||
needs: run-frame-omni-bencher | ||
steps: | ||
- run: echo '### Good job! All the benchmarks passed 🚀' >> $GITHUB_STEP_SUMMARY |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.