mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-10-14 08:47:45 -04:00
Hygiene update to manifest verification in CI (#671)
As the manifest verification script has been moved to FreeRTOS/CI-CD-Github-Actions as a GitHub Action along with the added functionality of verifying that manifest.yml versions match the current submoduled pointers in the repository, this PR updates the CI check for manifest verification to take advantage of the new manifest-verifier action from the repository.
This commit is contained in:
parent
5f21507703
commit
9f426a4a54
3 changed files with 9 additions and 98 deletions
91
.github/scripts/verify_manifest.py
vendored
91
.github/scripts/verify_manifest.py
vendored
|
@ -1,91 +0,0 @@
|
|||
#!/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)
|
||||
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
pyyaml
|
||||
gitpython
|
14
.github/workflows/ci.yml
vendored
14
.github/workflows/ci.yml
vendored
|
@ -128,14 +128,18 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: true
|
||||
- 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
|
||||
python-version: '3.x'
|
||||
- name: Run manifest verifier
|
||||
uses: FreeRTOS/CI-CD-Github-Actions/manifest-verifier@main
|
||||
with:
|
||||
path: ./
|
||||
exclude-submodules: FreeRTOS-Plus/Test/CMock,FreeRTOS/Test/CMock/CMock,FreeRTOS/Test/litani
|
||||
fail-on-incorrect-version: true
|
||||
|
||||
memory-statistics:
|
||||
runs-on: ubuntu-latest
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue