summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArchit Aggarwal <architag@amazon.com>2021-05-07 15:15:00 -0700
committerGitHub <noreply@github.com>2021-05-07 15:15:00 -0700
commite117bdcd178c4074fd0d255958487807a7b50032 (patch)
treeb9264524ecfa5e3607ee8d70b8b60eb9090c26d2
parent420a82151440dc2f3ede84cfb4299369de7b4c98 (diff)
downloadfreertos-git-e117bdcd178c4074fd0d255958487807a7b50032.tar.gz
Add CI check for verifying manifest.yml (#590)
-rw-r--r--.github/scripts/verify_manifest.py91
-rw-r--r--.github/scripts/verify_manifest_requirements.txt2
-rw-r--r--.github/workflows/ci.yml12
3 files changed, 105 insertions, 0 deletions
diff --git a/.github/scripts/verify_manifest.py b/.github/scripts/verify_manifest.py
new file mode 100644
index 000000000..b800f6088
--- /dev/null
+++ b/.github/scripts/verify_manifest.py
@@ -0,0 +1,91 @@
+#!/usr/bin/env python3
+
+import os, sys
+from yaml import load
+from yaml import CLoader as Loader
+
+from git import Repo
+from argparse import ArgumentParser
+
+REPO_PATH=''
+
+# List of submodules excluded from manifest.yml file
+IGNORE_SUBMODULES_LIST = [
+ 'FreeRTOS-Plus/Test/CMock',
+ 'FreeRTOS/Test/CMock/CMock',
+ 'FreeRTOS/Test/litani'
+ ]
+
+# Obtain submodule path of all entries in manifest.yml file.
+def read_manifest():
+ path_list = []
+
+ # Read YML file
+ path_manifest = os.path.join(REPO_PATH, 'manifest.yml')
+ assert os.path.exists(path_manifest), 'Missing manifest.yml'
+ with open(path_manifest, 'r') as fp:
+ manifest_data = fp.read()
+ yml = load(manifest_data, Loader=Loader)
+ assert 'dependencies' in yml, 'Manifest YML parsing error'
+
+ # Iterate over all the "dependencies" entries, verify that
+ # each contains entries for the following hierarchy:
+ # name: "<library-name>"
+ # version: "<version>"
+ # repository:
+ # type: "git"
+ # url: <library-github-url>
+ # path: <path-to-submodule-in-repository>
+ #
+ for dep in yml['dependencies']:
+ assert 'version' in dep, "Failed to parse 'version/tag' for submodule"
+ assert 'repository' in dep and 'path' in dep['repository'] and 'url' in dep['repository'], "Failed to parse 'repository' object for submodule"
+ path_list.append(dep['repository']['path'])
+
+ return sorted(path_list)
+
+# Generate list of submodules path in repository, excluding the
+# path in IGNORES_SUBMODULES_LIST.
+def get_all_submodules():
+ path_list = []
+ repo = Repo(REPO_PATH)
+ for submodule in repo.submodules:
+ path = submodule.abspath.replace(REPO_PATH+'/', '')
+ if path not in IGNORE_SUBMODULES_LIST:
+ path_list.append(path)
+
+ return sorted(path_list)
+
+if __name__ == '__main__':
+ parser = ArgumentParser(description='manifest.yml verifier')
+ parser.add_argument('--repo-root-path',
+ type=str,
+ required=None,
+ default=os.getcwd(),
+ help='Path to the repository root.')
+
+ args = parser.parse_args()
+
+ # Convert any relative path (like './') in passed argument to absolute path.
+ REPO_PATH = os.path.abspath(args.repo_root_path)
+
+ libraries_in_manifest_file = read_manifest()
+ git_submodules_list = get_all_submodules()
+
+ print(REPO_PATH)
+ print(git_submodules_list)
+
+ # Check that manifest.yml contains entries for all submodules
+ # present in repository.
+ if libraries_in_manifest_file == git_submodules_list:
+ print('Manifest.yml is verified!')
+ sys.exit(0)
+ else:
+ print('Manifest.yml is missing entries for:')
+ # Find list of library submodules missing in manifest.yml
+ for git_path in git_submodules_list:
+ if git_path not in libraries_in_manifest_file:
+ print(git_path)
+ sys.exit(1)
+
+
diff --git a/.github/scripts/verify_manifest_requirements.txt b/.github/scripts/verify_manifest_requirements.txt
new file mode 100644
index 000000000..f83cdd5a9
--- /dev/null
+++ b/.github/scripts/verify_manifest_requirements.txt
@@ -0,0 +1,2 @@
+pyyaml
+gitpython \ No newline at end of file
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 4399ab1e7..402fced62 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -59,4 +59,16 @@ jobs:
name: doxygen.zip-${{ github.sha }}
path: ./freertos/doxygen.zip
retention-days: 2
+ verify-manifest:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: Install Python3
+ uses: actions/setup-python@v2
+ with:
+ python-version: '3.8'
+ - name: Install dependencies
+ run: python3 -m pip install -r .github/scripts/verify_manifest_requirements.txt
+ - name: Run script to verify manifest.yml
+ run: python3 .github/scripts/verify_manifest.py