-
-
Notifications
You must be signed in to change notification settings - Fork 0
refactor(fleet): use shared derived repo validation #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,120 +1,38 @@ | ||
| #!/usr/bin/env bash | ||
| # shellcheck disable=SC2312 | ||
| set -euo pipefail | ||
|
|
||
| repo_root="${1:-.}" | ||
| cd "${repo_root}" | ||
| strict_placeholders="${STRICT_PLACEHOLDERS:-false}" | ||
|
|
||
| fail() { | ||
| echo "template validation error: $*" >&2 | ||
| exit 1 | ||
| } | ||
|
|
||
| require_file() { | ||
| local path="$1" | ||
| [[ -f ${path} ]] || fail "missing required file: ${path}" | ||
| } | ||
|
|
||
| require_absent() { | ||
| local path="$1" | ||
| [[ ! -e ${path} ]] || fail "remove template placeholder path in derived repo: ${path}" | ||
| } | ||
|
|
||
| check_no_placeholder() { | ||
| local pattern="$1" | ||
| shift | ||
| if grep -F -n -- "${pattern}" "$@" >/dev/null 2>&1; then | ||
| fail "found unresolved placeholder '${pattern}' in: $*" | ||
| fi | ||
| } | ||
|
|
||
| require_file "Dockerfile" | ||
| require_file "README.md" | ||
| require_file "pyproject.toml" | ||
| require_file "tests/template/test_validate_template.py" | ||
| require_file "tests/integration/test_container_runtime.py" | ||
| require_file "scripts/validate-template.py" | ||
| if [[ -f components.toml ]]; then | ||
| require_file "scripts/components.py" | ||
| fi | ||
| require_file "scripts/update-template-changes.py" | ||
| require_file ".github/FUNDING.yml" | ||
| require_file "SECURITY.md" | ||
| require_file ".github/pull_request_template.md" | ||
| require_file ".github/ISSUE_TEMPLATE/bug_report.yml" | ||
| require_file ".github/ISSUE_TEMPLATE/feature_request.yml" | ||
| require_file ".github/ISSUE_TEMPLATE/installation_help.yml" | ||
| require_file ".github/ISSUE_TEMPLATE/config.yml" | ||
| require_file "renovate.json" | ||
| require_absent ".github/CODEOWNERS" | ||
|
|
||
| effective_template_xml="${TEMPLATE_XML-}" | ||
| component_template_xml=() | ||
| if [[ -f components.toml ]]; then | ||
| while IFS= read -r template_path; do | ||
| [[ -n ${template_path} ]] || continue | ||
| component_template_xml+=("${template_path}") | ||
| done < <( | ||
| python3 - <<'PY' | ||
| from scripts.components import load_components | ||
|
|
||
| for component in load_components(): | ||
| print(component.template) | ||
| PY | ||
| ) | ||
| args=(validate-derived --repo-path "${repo_root}") | ||
| if [[ ${strict_placeholders} == "true" ]]; then | ||
| args+=(--strict-placeholders) | ||
| fi | ||
|
|
||
| if [[ -z ${effective_template_xml} ]]; then | ||
| repo_name="${PWD##*/}" | ||
| inferred_repo_xml="${repo_name}.xml" | ||
| if [[ -f ${inferred_repo_xml} ]]; then | ||
| effective_template_xml="${inferred_repo_xml}" | ||
| else | ||
| root_xml_files=() | ||
| shopt -s nullglob | ||
| for xml_path in ./*.xml; do | ||
| [[ -f ${xml_path} ]] || continue | ||
| root_xml_files+=("${xml_path#./}") | ||
| done | ||
| shopt -u nullglob | ||
| if [[ ${#root_xml_files[@]} -eq 1 ]]; then | ||
| effective_template_xml="${root_xml_files[0]}" | ||
| fi | ||
| fi | ||
| if python3 -c "import aio_fleet" >/dev/null 2>&1; then | ||
| exec python3 -m aio_fleet.cli "${args[@]}" | ||
|
Comment on lines
+12
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The early Useful? React with 👍 / 👎. |
||
| fi | ||
|
|
||
| is_template_repo="false" | ||
| if [[ -f .github/workflows/publish-release.yml ]] && grep -F -q -- "Publish Release / Template" .github/workflows/publish-release.yml; then | ||
| is_template_repo="true" | ||
| script_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" | ||
| candidate_roots=() | ||
| if [[ -n ${AIO_FLEET_PATH-} ]]; then | ||
| candidate_roots+=("${AIO_FLEET_PATH}") | ||
| fi | ||
|
|
||
| if [[ -n ${effective_template_xml} ]]; then | ||
| require_file "${effective_template_xml}" | ||
| if [[ ${is_template_repo} != "true" ]]; then | ||
| require_absent "template-aio.xml" | ||
| candidate_roots+=( | ||
| "${script_dir}/../../aio-fleet" | ||
| "${script_dir}/../../../aio-fleet" | ||
| "../aio-fleet" | ||
| "../../aio-fleet" | ||
| ) | ||
|
|
||
| for candidate in "${candidate_roots[@]}"; do | ||
| if [[ -d ${candidate}/src/aio_fleet ]]; then | ||
| PYTHONPATH="${candidate}/src${PYTHONPATH:+:${PYTHONPATH}}" exec python3 -m aio_fleet.cli "${args[@]}" | ||
| fi | ||
| fi | ||
|
|
||
| xml_files=() | ||
| for xml_path in "${component_template_xml[@]}"; do | ||
| require_file "${xml_path}" | ||
| xml_files+=("${xml_path}") | ||
| done | ||
| if [[ -n ${effective_template_xml} ]] && [[ -f ${effective_template_xml} ]]; then | ||
| xml_files+=("${effective_template_xml}") | ||
| fi | ||
|
|
||
| if [[ ${strict_placeholders} == "true" ]]; then | ||
| check_no_placeholder "Replace this starter base with the real upstream image once the derived repo is wired." "Dockerfile" | ||
| if [[ ${#xml_files[@]} -gt 0 ]]; then | ||
| check_no_placeholder "yourapp-aio" "${xml_files[@]}" | ||
| check_no_placeholder "Replace this overview with the real app description and first-run guidance." "${xml_files[@]}" | ||
| check_no_placeholder "replace-with-real-search-terms" "${xml_files[@]}" | ||
| check_no_placeholder "Replace this with any real operational prerequisites or remove it." "${xml_files[@]}" | ||
| check_no_placeholder "https://github.com/JSONbored/yourapp-aio/releases" "${xml_files[@]}" | ||
| fi | ||
| check_no_placeholder "aio-template starter app" rootfs/etc/services.d/app/run rootfs/usr/local/bin/aio-template-app.py | ||
| fi | ||
|
|
||
| echo "Derived repo validation passed." | ||
| cat >&2 <<'EOF' | ||
| template validation error: aio-fleet is required for derived repo validation. | ||
| Install aio-fleet or set AIO_FLEET_PATH to a local aio-fleet checkout. | ||
| EOF | ||
| exit 1 | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change makes
scripts/validate-derived-repo.shfail in a normal checkout unlessaio_fleetis preinstalled or a siblingaio-fleetrepo exists, which is a regression from the previous self-contained validator behavior. In this repository as committed, runningbash scripts/validate-derived-repo.sh .exits with the new error path, so local validation (and any CI job that only installs this repo’s own dev deps) breaks immediately instead of validating derived-repo contents.Useful? React with 👍 / 👎.