-
Notifications
You must be signed in to change notification settings - Fork 2
Add manifest validation to integration test #219
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
2dab5f8
feat: add manifest validation to integration test
dareste f3b256c
Update .github/scripts/verify-manifest.sh
dareste a73b9c3
Update .github/scripts/verify-manifest.sh
dareste 91a568a
feat: check correspondence between files in supportpkg and manifest
dareste File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| # Exit codes: | ||
| # 0 - success | ||
| # 2 - usage / bad args | ||
| # 3 - missing dependency (jq) | ||
| # 4 - manifest.json not found | ||
| # 5 - manifest.json exists but is not a regular file | ||
| # 6 - manifest.json is not valid JSON | ||
| # 7 - missing required JSON keys | ||
|
|
||
| if [[ ${#} -ne 1 ]]; then | ||
| usage | ||
| fi | ||
|
|
||
| dir="$1" | ||
| manifest="$dir/manifest.json" | ||
|
|
||
| if ! command -v jq >/dev/null 2>&1; then | ||
| echo "ERROR: jq is required but not found in PATH" >&2 | ||
| exit 3 | ||
| fi | ||
|
|
||
| if [[ ! -e "$manifest" ]]; then | ||
| echo "ERROR: manifest.json not found in directory: $dir" >&2 | ||
| exit 4 | ||
| fi | ||
|
|
||
| if [[ ! -f "$manifest" ]]; then | ||
| echo "ERROR: $manifest exists but is not a regular file" >&2 | ||
| exit 5 | ||
| fi | ||
|
|
||
| # Validate JSON | ||
| if ! jq empty "$manifest" >/dev/null 2>&1; then | ||
| echo "ERROR: $manifest is not valid JSON" >&2 | ||
| # show where jq fails (best-effort) | ||
| jq . "$manifest" 2>/dev/null || true | ||
| exit 6 | ||
| fi | ||
|
|
||
| required=( | ||
| "version" | ||
| "ts.start" | ||
| "ts.stop" | ||
| "package_type" | ||
| "root_dir" | ||
| "commands" | ||
| "platform_info.platform_type" | ||
| "platform_info.hostname" | ||
| "platform_info.serial_number" | ||
| "product_info.product" | ||
| "product_info.version" | ||
| "product_info.build" | ||
| ) | ||
|
|
||
| missing=() | ||
| for p in "${required[@]}"; do | ||
| # split dot-separated path into array elements and build a jq array literal | ||
| IFS='.' read -r -a parts <<< "$p" | ||
| # build JSON array like ["a","b"] | ||
| jq_array="[" | ||
| first=1 | ||
| for part in "${parts[@]}"; do | ||
| if [[ $first -eq 1 ]]; then | ||
| jq_array+="\"${part}\"" | ||
| first=0 | ||
| else | ||
| jq_array+=",\"${part}\"" | ||
| fi | ||
| done | ||
| jq_array+="]" | ||
|
|
||
| # Test presence: use getpath(array) and check that it exists and is not null | ||
| if ! jq -e "getpath($jq_array) != null" "$manifest" >/dev/null 2>&1; then | ||
dareste marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| missing+=("$p") | ||
| fi | ||
| done | ||
|
|
||
| if [[ ${#missing[@]} -ne 0 ]]; then | ||
| echo "ERROR: manifest.json is missing required keys:" >&2 | ||
| for m in "${missing[@]}"; do | ||
| echo " - $m" >&2 | ||
| done | ||
| exit 7 | ||
| fi | ||
|
|
||
| echo "OK: $manifest is valid and contains all required keys" | ||
| exit 0 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.