Skip to content

Commit c0f1a20

Browse files
committed
Changed all scripts and CI to use split manifest
Signed-off-by: Andrew Helwer <[email protected]>
1 parent 9beb57f commit c0f1a20

11 files changed

+49
-64
lines changed

.github/scripts/check_manifest_features.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def check_features(parser, queries, manifest, examples_root):
183183
Validates every field of the manifest that can be validated.
184184
"""
185185
success = True
186-
for spec in manifest['specifications']:
186+
for spec in manifest:
187187
if spec['title'] == '':
188188
success = False
189189
logging.error(f'Spec {spec["path"]} does not have a title')
@@ -235,18 +235,16 @@ def check_features(parser, queries, manifest, examples_root):
235235

236236
if __name__ == '__main__':
237237
parser = ArgumentParser(description='Checks metadata in tlaplus/examples manifest.json against module and model files in repository.')
238-
parser.add_argument('--manifest_path', help='Path to the tlaplus/examples manifest.json file', required=True)
238+
parser.add_argument('--examples_root', help='Root directory of the tlaplus/examples repository', required=True)
239239
args = parser.parse_args()
240240

241-
manifest_path = normpath(args.manifest_path)
242-
manifest = tla_utils.load_json(manifest_path)
243-
examples_root = dirname(manifest_path)
241+
manifest = tla_utils.load_all_manifests(args.examples_root)
244242

245243
TLAPLUS_LANGUAGE = Language(tree_sitter_tlaplus.language())
246244
parser = Parser(TLAPLUS_LANGUAGE)
247245
queries = build_queries(TLAPLUS_LANGUAGE)
248246

249-
if check_features(parser, queries, manifest, examples_root):
247+
if check_features(parser, queries, manifest, args.examples_root):
250248
logging.info('SUCCESS: metadata in manifest is correct')
251249
exit(0)
252250
else:

.github/scripts/check_manifest_files.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,15 @@
1111
import glob
1212
import tla_utils
1313

14-
parser = ArgumentParser(description='Checks tlaplus/examples manifest.json against module and model files in repository.')
15-
parser.add_argument('--manifest_path', help='Path to the tlaplus/examples manifest.json file', required=True)
14+
parser = ArgumentParser(description='Checks manifests against module and model files in repository.')
1615
parser.add_argument('--ci_ignore_path', help='Path to the .ciignore file', required=True)
1716
args = parser.parse_args()
1817

19-
manifest_path = normpath(args.manifest_path)
2018
ci_ignore_path = normpath(args.ci_ignore_path)
21-
examples_root = dirname(manifest_path)
22-
manifest = tla_utils.load_json(manifest_path)
19+
examples_root = dirname(ci_ignore_path)
20+
manifest = tla_utils.load_all_manifests(examples_root)
2321

24-
module_lists = [spec["modules"] for spec in manifest["specifications"]]
22+
module_lists = [spec["modules"] for spec in manifest]
2523
modules = [module for module_list in module_lists for module in module_list]
2624
model_lists = [module["models"] for module in modules]
2725

.github/scripts/check_markdown_table.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from argparse import ArgumentParser
66
from dataclasses import dataclass
7-
from os.path import normpath
7+
from os.path import normpath, dirname
88
from typing import Any, Set
99
import tla_utils
1010
import mistletoe
@@ -75,11 +75,10 @@ def from_json(spec):
7575
)
7676

7777
parser = ArgumentParser(description='Validates the spec table in README.md against the manifest.json.')
78-
parser.add_argument('--manifest_path', help='Path to the tlaplus/examples manifest.json file', required=True)
7978
parser.add_argument('--readme_path', help='Path to the tlaplus/examples README.md file', required=True)
8079
args = parser.parse_args()
8180

82-
manifest = tla_utils.load_json(normpath(args.manifest_path))
81+
manifest = tla_utils.load_all_manifests(dirname(args.readme_path))
8382

8483
readme = None
8584
with open(normpath(args.readme_path), 'r', encoding='utf-8') as readme_file:
@@ -88,7 +87,7 @@ def from_json(spec):
8887
spec_table = next((child for child in readme.children if isinstance(child, Table)))
8988

9089
table_specs = dict([(record.path, record) for record in [from_markdown(node) for node in spec_table.children]])
91-
manifest_specs = dict([(record.path, record) for record in [from_json(spec) for spec in manifest['specifications']]])
90+
manifest_specs = dict([(record.path, record) for record in [from_json(spec) for spec in manifest]])
9291

9392
# Checks that set of specs in manifest and table are equivalent
9493
success = True

.github/scripts/check_proofs.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,23 @@
1111

1212
parser = ArgumentParser(description='Validate all proofs in all modules with TLAPM.')
1313
parser.add_argument('--tlapm_path', help='Path to TLAPM install dir; should have bin and lib subdirs', required=True)
14-
parser.add_argument('--manifest_path', help='Path to the tlaplus/examples manifest.json file', required=True)
14+
parser.add_argument('--examples_root', help='Root directory of the tlaplus/examples repository', required=True)
1515
parser.add_argument('--skip', nargs='+', help='Space-separated list of .tla modules to skip checking', required=False, default=[])
1616
parser.add_argument('--only', nargs='+', help='If provided, only check proofs in this space-separated list', required=False, default=[])
1717
parser.add_argument('--verbose', help='Set logging output level to debug', action='store_true')
1818
args = parser.parse_args()
1919

2020
tlapm_path = normpath(args.tlapm_path)
21-
manifest_path = normpath(args.manifest_path)
22-
manifest = tla_utils.load_json(manifest_path)
23-
examples_root = dirname(manifest_path)
21+
examples_root = args.examples_root
22+
manifest = tla_utils.load_all_manifests(examples_root)
2423
skip_modules = args.skip
2524
only_modules = args.only
2625

2726
logging.basicConfig(level = logging.DEBUG if args.verbose else logging.INFO)
2827

2928
proof_module_paths = [
3029
module['path']
31-
for spec in manifest['specifications']
30+
for spec in manifest
3231
for module in spec['modules']
3332
if 'proof' in module['features']
3433
and module['path'] not in skip_modules

.github/scripts/check_small_models.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
parser.add_argument('--apalache_path', help='Path to the Apalache directory', required=True)
1717
parser.add_argument('--tlapm_lib_path', help='Path to the TLA+ proof manager module directory; .tla files should be in this directory', required=True)
1818
parser.add_argument('--community_modules_jar_path', help='Path to the CommunityModules-deps.jar file', required=True)
19-
parser.add_argument('--manifest_path', help='Path to the tlaplus/examples manifest.json file', required=True)
19+
parser.add_argument('--examples_root', help='Root directory of the tlaplus/examples repository', required=True)
2020
parser.add_argument('--skip', nargs='+', help='Space-separated list of models to skip checking', required=False, default=[])
2121
parser.add_argument('--only', nargs='+', help='If provided, only check models in this space-separated list', required=False, default=[])
2222
parser.add_argument('--verbose', help='Set logging output level to debug', action='store_true')
@@ -29,8 +29,7 @@
2929
apalache_path = normpath(args.apalache_path)
3030
tlapm_lib_path = normpath(args.tlapm_lib_path)
3131
community_jar_path = normpath(args.community_modules_jar_path)
32-
manifest_path = normpath(args.manifest_path)
33-
examples_root = dirname(manifest_path)
32+
examples_root = args.examples_root
3433
skip_models = args.skip
3534
only_models = args.only
3635
enable_assertions = args.enable_assertions
@@ -87,11 +86,11 @@ def check_model(module, model, expected_runtime):
8786
return False
8887

8988
# Ensure longest-running modules go first
90-
manifest = tla_utils.load_json(manifest_path)
89+
manifest = tla_utils.load_all_manifests(examples_root)
9190
small_models = sorted(
9291
[
9392
(module, model, tla_utils.parse_timespan(model['runtime']))
94-
for spec in manifest['specifications']
93+
for spec in manifest
9594
for module in spec['modules']
9695
for model in module['models']
9796
if model['size'] == 'small'

.github/scripts/parse_modules.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
parser.add_argument('--apalache_path', help='Path to the Apalache directory', required=True)
1616
parser.add_argument('--tlapm_lib_path', help='Path to the TLA+ proof manager module directory; .tla files should be in this directory', required=True)
1717
parser.add_argument('--community_modules_jar_path', help='Path to the CommunityModules-deps.jar file', required=True)
18-
parser.add_argument('--manifest_path', help='Path to the tlaplus/examples manifest.json file', required=True)
18+
parser.add_argument('--examples_root', help='Root directory of the tlaplus/examples repository', required=True)
1919
parser.add_argument('--skip', nargs='+', help='Space-separated list of .tla modules to skip parsing', required=False, default=[])
2020
parser.add_argument('--only', nargs='+', help='If provided, only parse models in this space-separated list', required=False, default=[])
2121
parser.add_argument('--verbose', help='Set logging output level to debug', action='store_true')
@@ -28,8 +28,7 @@
2828
apalache_jar_path = normpath(join(args.apalache_path, 'lib', 'apalache.jar'))
2929
tlaps_modules = normpath(args.tlapm_lib_path)
3030
community_modules = normpath(args.community_modules_jar_path)
31-
manifest_path = normpath(args.manifest_path)
32-
examples_root = dirname(manifest_path)
31+
examples_root = args.examples_root
3332
skip_modules = args.skip
3433
only_modules = args.only
3534
enable_assertions = args.enable_assertions
@@ -64,12 +63,12 @@ def parse_module(path):
6463
logging.error(output)
6564
return False
6665

67-
manifest = tla_utils.load_json(manifest_path)
66+
manifest = tla_utils.load_all_manifests(examples_root)
6867

6968
# List of all modules to parse and whether they should use TLAPS imports
7069
modules = [
7170
tla_utils.from_cwd(examples_root, module['path'])
72-
for spec in manifest['specifications']
71+
for spec in manifest
7372
for module in spec['modules']
7473
if module['path'] not in skip_modules
7574
and (only_modules == [] or module['path'] in only_modules)

.github/scripts/smoke_test_large_models.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
parser.add_argument('--apalache_path', help='Path to the Apalache directory', required=True)
1717
parser.add_argument('--tlapm_lib_path', help='Path to the TLA+ proof manager module directory; .tla files should be in this directory', required=True)
1818
parser.add_argument('--community_modules_jar_path', help='Path to the CommunityModules-deps.jar file', required=True)
19-
parser.add_argument('--manifest_path', help='Path to the tlaplus/examples manifest.json file', required=True)
19+
parser.add_argument('--examples_root', help='Root directory of the tlaplus/examples repository', required=True)
2020
parser.add_argument('--skip', nargs='+', help='Space-separated list of models to skip checking', required=False, default=[])
2121
parser.add_argument('--only', nargs='+', help='If provided, only check models in this space-separated list', required=False, default=[])
2222
parser.add_argument('--verbose', help='Set logging output level to debug', action='store_true')
@@ -27,8 +27,7 @@
2727
apalache_path = normpath(args.apalache_path)
2828
tlapm_lib_path = normpath(args.tlapm_lib_path)
2929
community_jar_path = normpath(args.community_modules_jar_path)
30-
manifest_path = normpath(args.manifest_path)
31-
examples_root = dirname(manifest_path)
30+
examples_root = args.examples_root
3231
skip_models = args.skip
3332
only_models = args.only
3433
enable_assertions = args.enable_assertions
@@ -80,11 +79,11 @@ def check_model(module, model):
8079

8180
logging.basicConfig(level = logging.DEBUG if args.verbose else logging.INFO)
8281

83-
manifest = tla_utils.load_json(manifest_path)
82+
manifest = tla_utils.load_all_manifests(examples_root)
8483

8584
large_models = [
8685
(module, model)
87-
for spec in manifest['specifications']
86+
for spec in manifest
8887
for module in spec['modules']
8988
for model in module['models']
9089
if model['size'] != 'small'

.github/scripts/translate_pluscal.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
parser = ArgumentParser(description='Run PlusCal translation on all modules.')
1515
parser.add_argument('--tools_jar_path', help='Path to the tla2tools.jar file', required=True)
16-
parser.add_argument('--manifest_path', help='Path to the tlaplus/examples manifest.json file', required=True)
16+
parser.add_argument('--examples_root', help='Root directory of the tlaplus/examples repository', required=True)
1717
parser.add_argument('--skip', nargs='+', help='Space-separated list of .tla modules to skip converting', required=False, default=[])
1818
parser.add_argument('--only', nargs='+', help='If provided, only convert models in this space-separated list', required=False, default=[])
1919
parser.add_argument('--verbose', help='Set logging output level to debug', action='store_true')
@@ -23,18 +23,17 @@
2323
logging.basicConfig(level = logging.DEBUG if args.verbose else logging.INFO)
2424

2525
tools_path = normpath(args.tools_jar_path)
26-
manifest_path = normpath(args.manifest_path)
27-
examples_root = dirname(manifest_path)
26+
examples_root = args.examples_root
2827
skip_modules = args.skip
2928
only_modules = args.only
3029
enable_assertions = args.enable_assertions
3130

32-
manifest = tla_utils.load_json(manifest_path)
31+
manifest = tla_utils.load_all_manifests(examples_root)
3332

3433
# List of all modules to translate
3534
modules = [
3635
tla_utils.from_cwd(examples_root, module['path'])
37-
for spec in manifest['specifications']
36+
for spec in manifest
3837
for module in spec['modules']
3938
if 'pluscal' in module['features']
4039
and module['path'] not in skip_modules

.github/scripts/unicode_conversion.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
parser = ArgumentParser(description='Converts all TLA+ modules from ASCII to Unicode or vice-versa.')
1515
parser.add_argument('--tlauc_path', help='Path to the TLAUC executable', required=True)
16-
parser.add_argument('--manifest_path', help='Path to the tlaplus/examples manifest.json file', required=True)
16+
parser.add_argument('--examples_root', help='Root directory of the tlaplus/examples repository', required=True)
1717
parser.add_argument('--to_ascii', help='Convert to ASCII instead of Unicode', action='store_true')
1818
parser.add_argument('--skip', nargs='+', help='Space-separated list of .tla modules to skip converting', required=False, default=[])
1919
parser.add_argument('--only', nargs='+', help='If provided, only convert models in this space-separated list', required=False, default=[])
@@ -24,17 +24,16 @@
2424

2525
tlauc_path = normpath(args.tlauc_path)
2626
to_ascii = args.to_ascii
27-
manifest_path = normpath(args.manifest_path)
28-
examples_root = dirname(manifest_path)
27+
examples_root = args.examples_root
2928
skip_modules = args.skip
3029
only_modules = args.only
3130

32-
manifest = tla_utils.load_json(manifest_path)
31+
manifest = tla_utils.load_all_manifests(examples_root)
3332

3433
# List of all modules to convert
3534
modules = [
3635
tla_utils.from_cwd(examples_root, module['path'])
37-
for spec in manifest['specifications']
36+
for spec in manifest
3837
for module in spec['modules']
3938
if module['path'] not in skip_modules
4039
and (only_modules == [] or module['path'] in only_modules)

.github/scripts/unicode_number_set_shim.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,13 @@ def write_module(examples_root, module_path, module_bytes):
110110

111111
if __name__ == '__main__':
112112
parser = ArgumentParser(description='Adds ℕ/ℤ/ℝ Unicode number set shim definitions to modules as needed.')
113-
parser.add_argument('--manifest_path', help='Path to the tlaplus/examples manifest.json file', required=True)
113+
parser.add_argument('--examples_root', help='Root directory of the tlaplus/examples repository', required=True)
114114
parser.add_argument('--skip', nargs='+', help='Space-separated list of .tla modules to skip', required=False, default=[])
115115
parser.add_argument('--only', nargs='+', help='If provided, only modify models in this space-separated list', required=False, default=[])
116116
args = parser.parse_args()
117117

118-
manifest_path = normpath(args.manifest_path)
119-
manifest = tla_utils.load_json(manifest_path)
120-
examples_root = dirname(manifest_path)
118+
examples_root = args.examples_root
119+
manifest = tla_utils.load_all_manifests(examples_root)
121120
skip_modules = args.skip
122121
only_modules = args.only
123122

@@ -127,7 +126,7 @@ def write_module(examples_root, module_path, module_bytes):
127126

128127
modules = [
129128
module['path']
130-
for spec in manifest['specifications']
129+
for spec in manifest
131130
for module in spec['modules']
132131
if module['path'] not in skip_modules
133132
and (only_modules == [] or module['path'] in only_modules)

0 commit comments

Comments
 (0)