Skip to content

Commit 7beddf9

Browse files
committed
Merge branch 'main' into mrajagopal-unit-tests
2 parents 0f1c9e6 + 6e167d3 commit 7beddf9

File tree

6 files changed

+107
-9
lines changed

6 files changed

+107
-9
lines changed

.github/scripts/verify-manifest.sh

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Exit codes:
5+
# 0 - success
6+
# 3 - missing dependency (jq)
7+
# 4 - manifest.json not found
8+
# 5 - manifest.json exists but is not a regular file
9+
# 6 - manifest.json is not valid JSON
10+
# 7 - missing required JSON keys
11+
# 8 - missing files in the supportpkg
12+
# 9 - missing files in the manifest
13+
14+
if [[ ${#} -ne 1 ]]; then
15+
usage
16+
fi
17+
18+
dir="$1"
19+
manifest="$dir/manifest.json"
20+
21+
if ! command -v jq >/dev/null 2>&1; then
22+
echo "ERROR: jq is required but not found in PATH" >&2
23+
exit 3
24+
fi
25+
26+
if [[ ! -e "$manifest" ]]; then
27+
echo "ERROR: manifest.json not found in directory: $dir" >&2
28+
exit 4
29+
fi
30+
31+
if [[ ! -f "$manifest" ]]; then
32+
echo "ERROR: $manifest exists but is not a regular file" >&2
33+
exit 5
34+
fi
35+
36+
# Validate JSON
37+
if ! jq empty "$manifest" >/dev/null 2>&1; then
38+
echo "ERROR: $manifest is not valid JSON" >&2
39+
# show where jq fails (best-effort)
40+
jq . "$manifest" 2>/dev/null || true
41+
exit 6
42+
fi
43+
44+
required=(
45+
"version"
46+
"ts.start"
47+
"ts.stop"
48+
"package_type"
49+
"root_dir"
50+
"commands"
51+
"platform_info.platform_type"
52+
"platform_info.hostname"
53+
"platform_info.serial_number"
54+
"product_info.product"
55+
"product_info.version"
56+
"product_info.build"
57+
)
58+
59+
missing=()
60+
for p in "${required[@]}"; do
61+
# Test presence: use getpath(split(".")) and check that it exists and is not null
62+
if ! jq -e --arg p "$p" 'getpath($p | split(".")) != null' "$manifest" >/dev/null 2>&1; then
63+
missing+=("$p")
64+
fi
65+
done
66+
67+
if [[ ${#missing[@]} -ne 0 ]]; then
68+
echo "ERROR: manifest.json is missing required keys:" >&2
69+
for m in "${missing[@]}"; do
70+
echo " - $m" >&2
71+
done
72+
exit 7
73+
fi
74+
75+
# Check that there is a 1:1 correspondence between manifest and tarball content
76+
77+
find "${dir}" -type f -mindepth 1 | cut -c "$(( ${#dir} + 1 ))"- > find-output.txt
78+
jq -r '.commands[].output' "${dir}"/manifest.json > manifest-output.txt
79+
printf "/manifest.json\n/supportpkg.log" >> manifest-output.txt
80+
if grep -vxFf find-output.txt manifest-output.txt >/dev/null; then
81+
echo "ERROR: Manifest contains files not present in the supportpkg:"
82+
grep -vxFf find-output.txt manifest-output.txt
83+
exit 8
84+
fi
85+
if grep -vxFf manifest-output.txt find-output.txt >/dev/null; then
86+
echo "ERROR: Supportpkg contains files not present in the manifest:"
87+
grep -vxFf manifest-output.txt find-output.txt
88+
exit 9
89+
fi
90+
91+
# All good if we reached this point
92+
93+
echo "OK: $manifest is valid and consistent with the supportpkg contents"
94+
exit 0

.github/workflows/docker-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
run: echo "Starting Release Build for ${RELEASE_VERSION}"
2222

2323
- name: Checkout code
24-
uses: actions/checkout@v4.2.2
24+
uses: actions/checkout@v5
2525

2626
- name: List repository files
2727
run: ls -R .; pwd

.github/workflows/fossa.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
if: ${{ github.event.repository.fork == false }}
2323
steps:
2424
- name: Checkout Repository
25-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
25+
uses: actions/checkout@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493 # v4.2.2
2626

2727
- name: Scan
2828
uses: fossas/fossa-action@3ebcea1862c6ffbd5cf1b4d0bd6b3fe7bd6f2cac # v1.7.0

.github/workflows/integration-test.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ jobs:
1212

1313
steps:
1414
- name: Checkout code
15-
uses: actions/checkout@v4
15+
uses: actions/checkout@v5
1616

1717
- name: Set up Go
18-
uses: actions/setup-go@v4
18+
uses: actions/setup-go@v6
1919
with:
2020
go-version: '1.24'
2121

@@ -106,6 +106,10 @@ jobs:
106106
# Verify expected files exist
107107
bash .github/scripts/verify-contents.sh extracted_test
108108
109+
- name: Validate manifest file
110+
run: |
111+
bash .github/scripts/verify-manifest.sh extracted_test
112+
109113
- name: Upload test artifacts
110114
if: always()
111115
uses: actions/upload-artifact@v4

.github/workflows/release-builder.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@ env:
1212

1313
jobs:
1414
build:
15-
if: endsWith(github.event.release.tag_name, '-krew')
15+
if: "!endsWith(github.event.release.tag_name, '-docker')"
1616
permissions:
1717
contents: write
1818

1919
runs-on: ubuntu-latest
2020

2121
steps:
2222
- name: Checkout code
23-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
23+
uses: actions/checkout@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493 # v4.2.2
2424

2525
- name: Set Release Version
2626
run: echo "RELEASE_VERSION=${RELEASE_VERSION%-krew}" >> $GITHUB_ENV
2727

2828
- name: Set up Go
29-
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
29+
uses: actions/setup-go@19bb51245e9c80abacb2e91cc42b33fa478b8639 # v4.2.1
3030
with:
3131
go-version: '1.24.3'
3232

.github/workflows/scorecards.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525

2626
steps:
2727
- name: "Checkout code"
28-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
28+
uses: actions/checkout@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493 # v4.2.2
2929
with:
3030
persist-credentials: false
3131

@@ -55,6 +55,6 @@ jobs:
5555

5656
# Upload the results to GitHub's code scanning dashboard.
5757
- name: "Upload to code-scanning"
58-
uses: github/codeql-action/upload-sarif@2d92b76c45b91eb80fc44c74ce3fce0ee94e8f9d # v3.30.0
58+
uses: github/codeql-action/upload-sarif@f443b600d91635bebf5b0d9ebc620189c0d6fba5 # v4.30.8
5959
with:
6060
sarif_file: results.sarif

0 commit comments

Comments
 (0)