Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/george/restore-gav-tx-ext' into …
Browse files Browse the repository at this point in the history
…gui-george-tx-ext-stable
  • Loading branch information
gui1117 committed Sep 20, 2024
2 parents 9d1a8ca + c02478b commit 04af1fc
Show file tree
Hide file tree
Showing 509 changed files with 15,438 additions and 6,005 deletions.
1 change: 1 addition & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ rustdocflags = [
# Needed for musl builds so user doesn't have to install musl-tools.
CC_x86_64_unknown_linux_musl = { value = ".cargo/musl-gcc", force = true, relative = true }
CXX_x86_64_unknown_linux_musl = { value = ".cargo/musl-g++", force = true, relative = true }
CARGO_WORKSPACE_ROOT_DIR = { value = "", relative = true }
15 changes: 0 additions & 15 deletions .github/actions/set-up-mac/README.md

This file was deleted.

43 changes: 0 additions & 43 deletions .github/actions/set-up-mac/action.yml

This file was deleted.

21 changes: 19 additions & 2 deletions .github/scripts/cmd/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
import json
import argparse
import _help
import importlib.util

_HelpAction = _help._HelpAction

f = open('.github/workflows/runtimes-matrix.json', 'r')
runtimesMatrix = json.load(f)

print(f'runtimesMatrix: {runtimesMatrix}\n')

runtimeNames = list(map(lambda x: x['name'], runtimesMatrix))

common_args = {
Expand Down Expand Up @@ -69,6 +68,17 @@
for arg, config in common_args.items():
parser_ui.add_argument(arg, **config)

"""
PRDOC
"""
# Import generate-prdoc.py dynamically
spec = importlib.util.spec_from_file_location("generate_prdoc", ".github/scripts/generate-prdoc.py")
generate_prdoc = importlib.util.module_from_spec(spec)
spec.loader.exec_module(generate_prdoc)

parser_prdoc = subparsers.add_parser('prdoc', help='Generates PR documentation')
generate_prdoc.setup_parser(parser_prdoc)

def main():
global args, unknown, runtimesMatrix
args, unknown = parser.parse_known_args()
Expand Down Expand Up @@ -215,6 +225,13 @@ def main():
print('❌ Failed to format code')
sys.exit(1)

elif args.command == 'prdoc':
# Call the main function from ./github/scripts/generate-prdoc.py module
exit_code = generate_prdoc.main(args)
if exit_code != 0 and not args.continue_on_fail:
print('❌ Failed to generate prdoc')
sys.exit(exit_code)

print('🚀 Done')

if __name__ == '__main__':
Expand Down
18 changes: 18 additions & 0 deletions .github/scripts/cmd/test_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,18 @@ def setUp(self):
self.patcher3 = patch('argparse.ArgumentParser.parse_known_args')
self.patcher4 = patch('os.system', return_value=0)
self.patcher5 = patch('os.popen')
self.patcher6 = patch('importlib.util.spec_from_file_location', return_value=MagicMock())
self.patcher7 = patch('importlib.util.module_from_spec', return_value=MagicMock())
self.patcher8 = patch('cmd.generate_prdoc.main', return_value=0)

self.mock_open = self.patcher1.start()
self.mock_json_load = self.patcher2.start()
self.mock_parse_args = self.patcher3.start()
self.mock_system = self.patcher4.start()
self.mock_popen = self.patcher5.start()
self.mock_spec_from_file_location = self.patcher6.start()
self.mock_module_from_spec = self.patcher7.start()
self.mock_generate_prdoc_main = self.patcher8.start()

# Ensure that cmd.py uses the mock_runtimes_matrix
import cmd
Expand All @@ -48,6 +54,9 @@ def tearDown(self):
self.patcher3.stop()
self.patcher4.stop()
self.patcher5.stop()
self.patcher6.stop()
self.patcher7.stop()
self.patcher8.stop()

def test_bench_command_normal_execution_all_runtimes(self):
self.mock_parse_args.return_value = (argparse.Namespace(
Expand Down Expand Up @@ -317,5 +326,14 @@ def test_update_ui_command(self, mock_system, mock_parse_args):
mock_exit.assert_not_called()
mock_system.assert_called_with('sh ./scripts/update-ui-tests.sh')

@patch('argparse.ArgumentParser.parse_known_args', return_value=(argparse.Namespace(command='prdoc', continue_on_fail=False), []))
@patch('os.system', return_value=0)
def test_prdoc_command(self, mock_system, mock_parse_args):
with patch('sys.exit') as mock_exit:
import cmd
cmd.main()
mock_exit.assert_not_called()
self.mock_generate_prdoc_main.assert_called_with(mock_parse_args.return_value[0])

if __name__ == '__main__':
unittest.main()
3 changes: 2 additions & 1 deletion .github/scripts/deny-git-deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
'simple-mermaid': ['xcm-docs'],
# Fix in <https://github.com/paritytech/polkadot-sdk/issues/2922>
'bandersnatch_vrfs': ['sp-core'],
'subwasmlib': ['polkadot-zombienet-sdk-tests'],
}

root = sys.argv[1] if len(sys.argv) > 1 else os.getcwd()
Expand All @@ -24,7 +25,7 @@
def check_dep(dep, used_by):
if dep.location != DependencyLocation.GIT:
return

if used_by in KNOWN_BAD_GIT_DEPS.get(dep.name, []):
print(f'🤨 Ignoring git dependency {dep.name} in {used_by}')
else:
Expand Down
31 changes: 21 additions & 10 deletions .github/scripts/generate-prdoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,28 @@ def yaml_multiline_string_presenter(dumper, data):

yaml.add_representer(str, yaml_multiline_string_presenter)

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()
# parse_args is also used by cmd/cmd.py
def setup_parser(parser=None):
if parser is None:
parser = argparse.ArgumentParser()
parser.add_argument("--pr", type=int, required=True, help="The PR number to generate the PrDoc for." )
parser.add_argument("--audience", type=str, default="TODO", help="The audience of whom the changes may concern.")
parser.add_argument("--bump", type=str, default="TODO", help="A default bump level for all crates.")
parser.add_argument("--force", type=str, help="Whether to overwrite any existing PrDoc.")

return parser

if __name__ == "__main__":
args = parse_args()
def main(args):
force = True if (args.force or "false").lower() == "true" else False
print(f"Args: {args}, force: {force}")
setup_yaml()
from_pr_number(args.pr, args.audience, args.bump, force)
try:
from_pr_number(args.pr, args.audience, args.bump, force)
return 0
except Exception as e:
print(f"Error generating prdoc: {e}")
return 1

if __name__ == "__main__":
args = setup_parser().parse_args()
main(args)
6 changes: 6 additions & 0 deletions .github/scripts/generate-prdoc.requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
requests
cargo-workspace
PyGithub
whatthepatch
pyyaml
toml
36 changes: 9 additions & 27 deletions .github/workflows/build-misc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,16 @@ permissions:
contents: read

jobs:
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
outputs:
IMAGE: ${{ steps.set_image.outputs.IMAGE }}
RUNNER: ${{ steps.set_runner.outputs.RUNNER }}
steps:
- name: Checkout
uses: actions/checkout@v4
- id: set_image
run: cat .github/env >> $GITHUB_OUTPUT
- id: set_runner
run: |
# Run merge queues on persistent runners
if [[ $GITHUB_REF_NAME == *"gh-readonly-queue"* ]]; then
echo "RUNNER=arc-runners-polkadot-sdk-beefy-persistent" >> $GITHUB_OUTPUT
else
echo "RUNNER=arc-runners-polkadot-sdk-beefy" >> $GITHUB_OUTPUT
fi

preflight:
uses: ./.github/workflows/reusable-preflight.yml

build-runtimes-polkavm:
timeout-minutes: 20
needs: [set-image]
runs-on: ${{ needs.set-image.outputs.RUNNER }}
needs: [preflight]
runs-on: ${{ needs.preflight.outputs.RUNNER }}
container:
image: ${{ needs.set-image.outputs.IMAGE }}
image: ${{ needs.preflight.outputs.IMAGE }}
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -64,10 +46,10 @@ jobs:
build-subkey:
timeout-minutes: 20
needs: [set-image]
runs-on: ${{ needs.set-image.outputs.RUNNER }}
needs: [preflight]
runs-on: ${{ needs.preflight.outputs.RUNNER }}
container:
image: ${{ needs.set-image.outputs.IMAGE }}
image: ${{ needs.preflight.outputs.IMAGE }}
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
Loading

0 comments on commit 04af1fc

Please sign in to comment.