diff --git a/.circleci/config.yml b/.circleci/config.yml index 9f090c3398..26366aa392 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -48,6 +48,13 @@ jobs: black --check ml-agents-envs black --check gym-unity + - run: + name: Verify there are no hidden/missing metafiles. + # Renaming files or deleting files can leave metafiles behind that makes Unity very unhappy. + command: | + . venv/bin/activate + python utils/validate_meta_files.py + - store_test_results: path: test-reports diff --git a/.gitignore b/.gitignore index 36937e9918..b454d891bd 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,6 @@ /UnitySDK/[Uu]nity[Pp]ackage[Mm]anager/ /UnitySDK/Assets/AssetStoreTools* /UnitySDK/Assets/Plugins* -/UnitySDK/Assets/Gizmos* /UnitySDK/Assets/Demonstrations* # Tensorflow Model Info diff --git a/UnitySDK/Assets/Gizmos.meta b/UnitySDK/Assets/Gizmos.meta new file mode 100644 index 0000000000..5d0f14a77d --- /dev/null +++ b/UnitySDK/Assets/Gizmos.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e74b9e5c364014df1a24c696734cc461 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/utils/__init__.py b/utils/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/utils/validate_meta_files.py b/utils/validate_meta_files.py new file mode 100644 index 0000000000..0ea828ee8b --- /dev/null +++ b/utils/validate_meta_files.py @@ -0,0 +1,42 @@ +import json +import os + + +def main(): + asset_path = "UnitySDK/Assets" + meta_suffix = ".meta" + python_suffix = ".py" + + num_matched = 0 + + unmatched = set() + + for root, dirs, files in os.walk(asset_path): + dirs = set(dirs) + files = set(files) + + combined = dirs | files + for f in combined: + if f.endswith(python_suffix): + # Probably this script; skip it + continue + + # We expect each non-.meta file to have a .meta file, and each .meta file to have a non-.meta file + if f.endswith(meta_suffix): + expected = f.replace(meta_suffix, "") + else: + expected = f + meta_suffix + + if expected not in combined: + unmatched.add(os.path.join(root, f)) + else: + num_matched += 1 + + if unmatched: + raise Exception(f"Mismatch between expected files and their .meta files: {sorted(unmatched)}") + + print(f"Found {num_matched} correctly matched files") + + +if __name__ == "__main__": + main() \ No newline at end of file