Skip to content

Commit bb579dc

Browse files
committed
Improve domain handling and status checking of updated examples.
All the examples cloned from Mercurial should use the new os.mbed.com domain. Thus update corrects that. A new option has been added to the update.py script , -s which shows the status of any PRs raised against the examples that are tagged with the current release label.
1 parent 0e1cc56 commit bb579dc

File tree

2 files changed

+88
-24
lines changed

2 files changed

+88
-24
lines changed

tools/test/examples/examples.json

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@
77
},
88
"via-branch" : {
99
"help" : "-b cmd line option. Update dst branch, created from src branch",
10-
"src-branch" : "mbed-os-5.5.0-rc1-oob",
11-
"dst-branch" : "mbed-os-5.5.0-rc2-oob"
10+
"src-branch" : "mbed-os-5.6.0-oob2",
11+
"dst-branch" : "mbed-os-5.6.0-oob2"
1212
},
13-
"tag" : "mbed-os-5.5.0-rc2"
13+
"tag" : "mbed-os-5.6.2"
1414
},
1515
"examples": [
1616
{
1717
"name": "mbed-os-example-blinky",
1818
"github": "https://github.com/ARMmbed/mbed-os-example-blinky",
1919
"mbed": [
20-
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-blinky"
20+
"https://os.mbed.com/teams/mbed-os-examples/code/mbed-os-example-blinky"
2121
],
2222
"test-repo-source": "github",
2323
"features" : [],
@@ -32,10 +32,10 @@
3232
"name": "mbed-os-example-tls",
3333
"github": "https://github.com/ARMmbed/mbed-os-example-tls",
3434
"mbed": [
35-
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-tls-benchmark",
36-
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-tls-tls-client",
37-
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-tls-hashing",
38-
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-tls-authcrypt"
35+
"https://os.mbed.com/teams/mbed-os-examples/code/mbed-os-example-tls-benchmark",
36+
"https://os.mbed.com/teams/mbed-os-examples/code/mbed-os-example-tls-tls-client",
37+
"https://os.mbed.com/teams/mbed-os-examples/code/mbed-os-example-tls-hashing",
38+
"https://os.mbed.com/teams/mbed-os-examples/code/mbed-os-example-tls-authcrypt"
3939
],
4040
"test-repo-source": "mbed",
4141
"features" : [],
@@ -50,7 +50,7 @@
5050
"name": "mbed-os-example-mesh-minimal",
5151
"github":"https://github.com/ARMmbed/mbed-os-example-mesh-minimal",
5252
"mbed": [
53-
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-mesh-minimal"
53+
"https://os.mbed.com/teams/mbed-os-examples/code/mbed-os-example-mesh-minimal"
5454
],
5555
"test-repo-source": "github",
5656
"features" : [],
@@ -68,14 +68,14 @@
6868
"name": "mbed-os-example-ble",
6969
"github":"https://github.com/ARMmbed/mbed-os-example-ble",
7070
"mbed": [
71-
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-ble-Beacon",
72-
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-ble-HeartRate",
73-
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-ble-Thermometer",
74-
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-ble-LEDBlinker",
75-
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-ble-LED",
76-
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-ble-GAPButton",
77-
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-ble-Button",
78-
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-ble-BatteryLevel"
71+
"https://os.mbed.com/teams/mbed-os-examples/code/mbed-os-example-ble-Beacon",
72+
"https://os.mbed.com/teams/mbed-os-examples/code/mbed-os-example-ble-HeartRate",
73+
"https://os.mbed.com/teams/mbed-os-examples/code/mbed-os-example-ble-Thermometer",
74+
"https://os.mbed.com/teams/mbed-os-examples/code/mbed-os-example-ble-LEDBlinker",
75+
"https://os.mbed.com/teams/mbed-os-examples/code/mbed-os-example-ble-LED",
76+
"https://os.mbed.com/teams/mbed-os-examples/code/mbed-os-example-ble-GAPButton",
77+
"https://os.mbed.com/teams/mbed-os-examples/code/mbed-os-example-ble-Button",
78+
"https://os.mbed.com/teams/mbed-os-examples/code/mbed-os-example-ble-BatteryLevel"
7979
],
8080
"test-repo-source": "mbed",
8181
"features" : ["BLE"],
@@ -90,7 +90,7 @@
9090
"name": "mbed-os-example-client",
9191
"github":"https://github.com/ARMmbed/mbed-os-example-client",
9292
"mbed": [
93-
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-client"
93+
"https://os.mbed.com/teams/mbed-os-examples/code/mbed-os-example-client"
9494
],
9595
"test-repo-source": "github",
9696
"features" : ["LWIP"],
@@ -101,6 +101,19 @@
101101
"export": false,
102102
"auto-update" : true
103103
},
104+
{
105+
"name": "mbed-cloud-client-example-internal",
106+
"github":"https://github.com/ARMmbed/mbed-cloud-client-example-internal",
107+
"mbed": [],
108+
"test-repo-source": "github",
109+
"features" : ["LWIP"],
110+
"targets" : [],
111+
"toolchains" : [],
112+
"exporters": [],
113+
"compile" : false,
114+
"export": false,
115+
"auto-update" : true
116+
},
104117
{
105118
"name": "mbed-os-example-sockets",
106119
"github":"https://github.com/ARMmbed/mbed-os-example-sockets",
@@ -172,7 +185,7 @@
172185
"name": "mbed-os-example-bootloader",
173186
"github":"https://github.com/ARMmbed/mbed-os-example-bootloader",
174187
"mbed": [
175-
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-bootloader"
188+
"https://os.mbed.com/teams/mbed-os-examples/code/mbed-os-example-bootloader"
176189
],
177190
"test-repo-source": "github",
178191
"features" : [],
@@ -187,7 +200,7 @@
187200
"name": "mbed-os-example-fat-filesystem",
188201
"github":"https://github.com/ARMmbed/mbed-os-example-fat-filesystem",
189202
"mbed": [
190-
"https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-fat-filesystem"
203+
"https://os.mbed.com/teams/mbed-os-examples/code/mbed-os-example-fat-filesystem"
191204
],
192205
"test-repo-source": "github",
193206
"features" : [],

tools/test/examples/update.py

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#
3737
# Command usage:
3838
#
39-
# update.py -c <config file> - T <github_token> -l <logging level> -f -b
39+
# update.py -c <config file> - T <github_token> -f -b -s
4040
#
4141
# Where:
4242
# -c <config file> - Optional path to an examples file.
@@ -47,8 +47,10 @@
4747
# -b - Update branched repos. This will use the "src-branch" and
4848
# "dst-branch" parameters in the 'via-branch' section. The destination
4949
# branch is created from the source branch (if it doesn't already exist).
50+
# -s - Show the status of any pull requests with a tag matching that in the
51+
# json config file
5052
#
51-
# The options -f and -b are mutually exlusive. Only one can be specified.
53+
# The options -f, -b and -s are mutually exlusive. Only one can be specified.
5254
#
5355
#
5456

@@ -431,6 +433,47 @@ def create_work_directory(path):
431433

432434
os.makedirs(path)
433435

436+
def check_update_status(examples, github, tag):
437+
""" Check the status of previously raised update pull requests
438+
439+
Args:
440+
examples - list of examples which should have had PRs raised against them.
441+
github - github rest API instance
442+
tag - release tag used for the update
443+
444+
"""
445+
446+
for example in examples:
447+
448+
repo_name = ''.join(['ARMmbed/', example['name']])
449+
try:
450+
repo = github.get_repo(repo_name, False)
451+
452+
except Exception as exc:
453+
text = "Cannot access: " + str(repo_name)
454+
userlog.error(text)
455+
userlog.exception(exc)
456+
sys.exit(1)
457+
458+
# Create the full repository filter component
459+
org_str = ''.join(['repo:', 'ARMmbed/', example['name']])
460+
filt = ' '.join([org_str, 'is:pr', tag])
461+
merged = False
462+
463+
issues = github.search_issues(query=(filt))
464+
pr_list = [repo.get_pull(issue.number) for issue in issues]
465+
466+
# Should only be one matching PR but just in case, go through paginated list
467+
for pr in pr_list:
468+
if pr.merged:
469+
userlog.info("%s - '%s': MERGED", example['name'], pr.title)
470+
elif pr.state == 'open':
471+
userlog.info("%s - '%s': PENDING", example['name'], pr.title)
472+
elif pr.state == 'closed':
473+
userlog.info("%s - '%s': CLOSED NOT MERGED", example['name'], pr.title)
474+
else:
475+
userlog.error("%s: Cannot find a pull request for %s", example['name'], tag)
476+
434477
if __name__ == '__main__':
435478

436479
parser = argparse.ArgumentParser(description=__doc__,
@@ -441,6 +484,7 @@ def create_work_directory(path):
441484
exclusive = parser.add_mutually_exclusive_group(required=True)
442485
exclusive.add_argument('-f', '--fork', help="Update a fork", action='store_true')
443486
exclusive.add_argument('-b', '--branch', help="Update a branch", action='store_true')
487+
exclusive.add_argument('-s', '--status', help="Show examples update status", action='store_true')
444488

445489
args = parser.parse_args()
446490

@@ -451,8 +495,6 @@ def create_work_directory(path):
451495
sys.exit(1)
452496
json_data = json.load(config)
453497

454-
# Create working directory
455-
create_work_directory('examples')
456498

457499
github = Github(args.github_token)
458500
config = json_data['update-config']
@@ -462,6 +504,15 @@ def create_work_directory(path):
462504
src = "master"
463505
dst = None
464506

507+
if args.status:
508+
509+
# This option should only be called after an update has been performed
510+
check_update_status(json_data['examples'], github, tag)
511+
exit(0)
512+
513+
# Create working directory
514+
create_work_directory('examples')
515+
465516
if args.fork:
466517
user = config['via-fork']['github-user']
467518
elif args.branch:

0 commit comments

Comments
 (0)