diff options
| author | Zach White <skullydazed@gmail.com> | 2021-05-10 11:18:44 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-05-10 11:18:44 -0700 |
| commit | a3e7f3e7c58ee98596ead5c213f3a9ed8340cd80 (patch) | |
| tree | ef0cb85205fad7562045f23caa8a16384e43bbb5 /lib/python/qmk/cli/generate | |
| parent | 66ed80ad3a0edecd9d7abbef71fc2a6e3e59b541 (diff) | |
| download | qmk_firmware-a3e7f3e7c58ee98596ead5c213f3a9ed8340cd80.tar.gz qmk_firmware-a3e7f3e7c58ee98596ead5c213f3a9ed8340cd80.zip | |
Improve our CI tests (#11476)
* add a test and dry-run to qmk generate-api
* add a dry-run to qmk pyformat
* Add a --dry-run to qmk cformat
* reverse the order of nose2 and flake8 tests
* run CI test against cformat and pyformat
* fix programming errors
* tweak job name
* fix argument
* refine the files we select
* fix stack trace in --ci
* make cformat exit clean
* fix c file extensions
* decouple CI from pyformat
* remove --ci arg
* make ci happy
* use the environment var instead
* change output to text
* fix log message
* replace tabs
Diffstat (limited to 'lib/python/qmk/cli/generate')
| -rwxr-xr-x | lib/python/qmk/cli/generate/api.py | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/lib/python/qmk/cli/generate/api.py b/lib/python/qmk/cli/generate/api.py index 70019428f..8ab7522a7 100755 --- a/lib/python/qmk/cli/generate/api.py +++ b/lib/python/qmk/cli/generate/api.py | |||
| @@ -13,6 +13,7 @@ from qmk.json_schema import json_load | |||
| 13 | from qmk.keyboard import list_keyboards | 13 | from qmk.keyboard import list_keyboards |
| 14 | 14 | ||
| 15 | 15 | ||
| 16 | @cli.argument('-n', '--dry-run', arg_only=True, action='store_true', help="Don't write the data to disk.") | ||
| 16 | @cli.subcommand('Creates a new keymap for the keyboard of your choosing', hidden=False if cli.config.user.developer else True) | 17 | @cli.subcommand('Creates a new keymap for the keyboard of your choosing', hidden=False if cli.config.user.developer else True) |
| 17 | def generate_api(cli): | 18 | def generate_api(cli): |
| 18 | """Generates the QMK API data. | 19 | """Generates the QMK API data. |
| @@ -40,10 +41,14 @@ def generate_api(cli): | |||
| 40 | keyboard_readme_src = Path('keyboards') / keyboard_name / 'readme.md' | 41 | keyboard_readme_src = Path('keyboards') / keyboard_name / 'readme.md' |
| 41 | 42 | ||
| 42 | keyboard_dir.mkdir(parents=True, exist_ok=True) | 43 | keyboard_dir.mkdir(parents=True, exist_ok=True) |
| 43 | keyboard_info.write_text(json.dumps({'last_updated': current_datetime(), 'keyboards': {keyboard_name: kb_all[keyboard_name]}})) | 44 | keyboard_json = json.dumps({'last_updated': current_datetime(), 'keyboards': {keyboard_name: kb_all[keyboard_name]}}) |
| 45 | if not cli.args.dry_run: | ||
| 46 | keyboard_info.write_text(keyboard_json) | ||
| 47 | cli.log.debug('Wrote file %s', keyboard_info) | ||
| 44 | 48 | ||
| 45 | if keyboard_readme_src.exists(): | 49 | if keyboard_readme_src.exists(): |
| 46 | copyfile(keyboard_readme_src, keyboard_readme) | 50 | copyfile(keyboard_readme_src, keyboard_readme) |
| 51 | cli.log.debug('Copied %s -> %s', keyboard_readme_src, keyboard_readme) | ||
| 47 | 52 | ||
| 48 | if 'usb' in kb_all[keyboard_name]: | 53 | if 'usb' in kb_all[keyboard_name]: |
| 49 | usb = kb_all[keyboard_name]['usb'] | 54 | usb = kb_all[keyboard_name]['usb'] |
| @@ -57,20 +62,26 @@ def generate_api(cli): | |||
| 57 | if 'vid' in usb and 'pid' in usb: | 62 | if 'vid' in usb and 'pid' in usb: |
| 58 | usb_list[usb['vid']][usb['pid']][keyboard_name] = usb | 63 | usb_list[usb['vid']][usb['pid']][keyboard_name] = usb |
| 59 | 64 | ||
| 60 | # Write the global JSON files | 65 | # Generate data for the global files |
| 61 | keyboard_all_file.write_text(json.dumps({'last_updated': current_datetime(), 'keyboards': kb_all}, cls=InfoJSONEncoder)) | ||
| 62 | usb_file.write_text(json.dumps({'last_updated': current_datetime(), 'usb': usb_list}, cls=InfoJSONEncoder)) | ||
| 63 | |||
| 64 | keyboard_list = sorted(kb_all) | 66 | keyboard_list = sorted(kb_all) |
| 65 | keyboard_list_file.write_text(json.dumps({'last_updated': current_datetime(), 'keyboards': keyboard_list}, cls=InfoJSONEncoder)) | ||
| 66 | |||
| 67 | keyboard_aliases = json_load(Path('data/mappings/keyboard_aliases.json')) | 67 | keyboard_aliases = json_load(Path('data/mappings/keyboard_aliases.json')) |
| 68 | keyboard_aliases_file.write_text(json.dumps({'last_updated': current_datetime(), 'keyboard_aliases': keyboard_aliases}, cls=InfoJSONEncoder)) | ||
| 69 | |||
| 70 | keyboard_metadata = { | 68 | keyboard_metadata = { |
| 71 | 'last_updated': current_datetime(), | 69 | 'last_updated': current_datetime(), |
| 72 | 'keyboards': keyboard_list, | 70 | 'keyboards': keyboard_list, |
| 73 | 'keyboard_aliases': keyboard_aliases, | 71 | 'keyboard_aliases': keyboard_aliases, |
| 74 | 'usb': usb_list, | 72 | 'usb': usb_list, |
| 75 | } | 73 | } |
| 76 | keyboard_metadata_file.write_text(json.dumps(keyboard_metadata, cls=InfoJSONEncoder)) | 74 | |
| 75 | # Write the global JSON files | ||
| 76 | keyboard_all_json = json.dumps({'last_updated': current_datetime(), 'keyboards': kb_all}, cls=InfoJSONEncoder) | ||
| 77 | usb_json = json.dumps({'last_updated': current_datetime(), 'usb': usb_list}, cls=InfoJSONEncoder) | ||
| 78 | keyboard_list_json = json.dumps({'last_updated': current_datetime(), 'keyboards': keyboard_list}, cls=InfoJSONEncoder) | ||
| 79 | keyboard_aliases_json = json.dumps({'last_updated': current_datetime(), 'keyboard_aliases': keyboard_aliases}, cls=InfoJSONEncoder) | ||
| 80 | keyboard_metadata_json = json.dumps(keyboard_metadata, cls=InfoJSONEncoder) | ||
| 81 | |||
| 82 | if not cli.args.dry_run: | ||
| 83 | keyboard_all_file.write_text(keyboard_all_json) | ||
| 84 | usb_file.write_text(usb_json) | ||
| 85 | keyboard_list_file.write_text(keyboard_list_json) | ||
| 86 | keyboard_aliases_file.write_text(keyboard_aliases_json) | ||
| 87 | keyboard_metadata_file.write_text(keyboard_metadata_json) | ||
