From b020e8f32cd06eb522faea385d895923b7c815e6 Mon Sep 17 00:00:00 2001 From: Adrian Date: Sun, 24 Mar 2024 00:04:56 +0100 Subject: [PATCH] ci: Check that setup manifests are complete (#227) * Fix invalid manifests * Check that setup manifests are complete --- .github/utils/check_manifests.py | 49 ++++++++++++++++++++++++++++++++ .github/workflows/ci.yml | 4 +++ storage_s3/MANIFEST.in | 3 ++ themes_legacy/MANIFEST.in | 1 + 4 files changed, 57 insertions(+) create mode 100644 .github/utils/check_manifests.py create mode 100644 storage_s3/MANIFEST.in diff --git a/.github/utils/check_manifests.py b/.github/utils/check_manifests.py new file mode 100644 index 0000000..4ed5f25 --- /dev/null +++ b/.github/utils/check_manifests.py @@ -0,0 +1,49 @@ +# This file is part of the Indico plugins. +# Copyright (C) 2002 - 2024 CERN +# +# The Indico plugins are free software; you can redistribute +# them and/or modify them under the terms of the MIT License; +# see the LICENSE file for more details. + +import sys +from pathlib import Path + + +def _validate_manifest(plugin_dir: Path): + pkg_dir = plugin_dir / f'indico_{plugin_dir.name}' + data_dirs = [ + sub.name + for sub in pkg_dir.iterdir() + if sub.name not in {'__pycache__', 'client'} and sub.is_dir() and not any(sub.glob('*.py')) + ] + if not data_dirs: + return True + expected_manifest = {f'graft {pkg_dir.name}/{plugin_dir}' for plugin_dir in data_dirs} + manifest_file = plugin_dir / 'MANIFEST.in' + if not manifest_file.exists(): + print(f'::error::{plugin_dir.name} has no manifest') + for line in expected_manifest: + print(f'::error::manifest entry missing: {line}') + return False + manifest_lines = set(manifest_file.read_text().splitlines()) + if missing := (expected_manifest - manifest_lines): + print(f'::error::{plugin_dir.name} has incomplete manifest') + for line in missing: + print(f'::error::manifest entry missing: {line}') + return False + return True + + +def main(): + errors = False + for plugin_dir in Path().iterdir(): + if not plugin_dir.is_dir() or plugin_dir.name == '_meta' or not (plugin_dir / 'setup.cfg').exists(): + continue + if not _validate_manifest(plugin_dir): + errors = True + + return 1 if errors else 0 + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e2525e4..dd46e03 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -126,7 +126,11 @@ jobs: echo "VIRTUAL_ENV=$(pwd)/.venv" >> $GITHUB_ENV echo "$(pwd)/.venv/bin" >> $GITHUB_PATH + - name: Check manifests + run: python .github/utils/check_manifests.py + - name: Check import sorting + if: success() || failure() run: isort --diff --check-only . - name: Check headers diff --git a/storage_s3/MANIFEST.in b/storage_s3/MANIFEST.in new file mode 100644 index 0000000..126e3a6 --- /dev/null +++ b/storage_s3/MANIFEST.in @@ -0,0 +1,3 @@ +graft indico_storage_s3/translations + +global-exclude *.pyc __pycache__ .keep diff --git a/themes_legacy/MANIFEST.in b/themes_legacy/MANIFEST.in index 9f8b156..fe739e0 100644 --- a/themes_legacy/MANIFEST.in +++ b/themes_legacy/MANIFEST.in @@ -1,6 +1,7 @@ graft indico_themes_legacy/static graft indico_themes_legacy/templates graft indico_themes_legacy/themes +graft indico_themes_legacy/translations recursive-include indico_themes_legacy *.yaml global-exclude *.pyc __pycache__ .keep