Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/linux-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,19 @@ jobs:
- name: Init tools submodule
run: git submodule update --init tools

# Rehydrate Linux binaries (Option B): the sparse prebuilt checkout above
# has manifests only. Fetch + checksum-verify the Linux artifact set into
# prebuilt/ so it is baked into the docker build context. The sparse cone
# scopes which manifests exist, so only those tools' binaries are pulled.
- name: Fetch prebuilt binaries (Option B)
env:
DEVKIT_ARTIFACT_BASE: ${{ vars.DEVKIT_ARTIFACT_BASE }}
run: |
VER=$(sed -nE 's/.*AppVersion = "([^"]+)".*/\1/p' server/internal/api/version.go)
BASE="${DEVKIT_ARTIFACT_BASE:-https://github.com/airgap-devkit/devkit/releases/download/v${VER}}"
echo "Artifact base: $BASE"
DEVKIT_ARTIFACT_BASE="$BASE" bash scripts/internal/fetch-artifacts.sh --platform linux

- name: Build test image (${{ matrix.distro }})
run: |
# Pass both ARG names; each Dockerfile reads the one it declares
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/smoke-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,21 @@ jobs:
with:
submodules: recursive

# -- Rehydrate binaries (Option B) ────────────────────────────────────
# The prebuilt submodule ships manifests only; the binaries live in the
# matching release's assets. Fetch + checksum-verify this platform's set
# into prebuilt/ before installing. Base tracks version.go (overridable
# via the DEVKIT_ARTIFACT_BASE repo/env var for a mirror).
- name: Fetch prebuilt binaries (Option B)
shell: bash
env:
DEVKIT_ARTIFACT_BASE: ${{ vars.DEVKIT_ARTIFACT_BASE }}
run: |
VER=$(sed -nE 's/.*AppVersion = "([^"]+)".*/\1/p' server/internal/api/version.go)
BASE="${DEVKIT_ARTIFACT_BASE:-https://github.com/airgap-devkit/devkit/releases/download/v${VER}}"
echo "Artifact base: $BASE"
DEVKIT_ARTIFACT_BASE="$BASE" bash scripts/internal/fetch-artifacts.sh --platform ${{ matrix.os_flag }}

# -- Install ─────────────────────────────────────────────────────────
- name: Install tools
shell: bash
Expand Down
84 changes: 52 additions & 32 deletions scripts/internal/check-prebuilt-manifests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@
# check-prebuilt-manifests.sh
#
# Fail if any prebuilt manifest.json declares a per-platform artifact
# (platforms.<plat>.archive or .installer) that is NOT staged — neither as a
# whole file nor as split parts. This catches the class of bug where a global
# gitignore (e.g. *.exe) silently drops a Windows installer from the submodule,
# so the manifest promises an install the UI/CLI can never deliver.
# (platforms.<plat>.archive/.installer, or an extensions/files entry) that has
# NO resolvable SHA256 to verify it against. This catches the class of bug where
# a manifest promises an install the UI/CLI can never deliver — a missing or
# malformed checksum means fetch-artifacts.sh cannot fetch-and-verify the file,
# and the fail-closed installer aborts.
#
# SEMANTICS: presence is judged against git-TRACKED files (git ls-files), NOT
# the working tree. A fresh clone — CI or an air-gapped bundle — only ever has
# tracked content, so an artifact that exists on disk but was never committed
# (e.g. blocked by a global *.exe gitignore) must fail. A working-tree-only move
# or deletion is therefore intentionally NOT flagged; commit state is the source
# of truth. To also guard local on-disk presence, add a separate check.
# SEMANTICS (Option B): the binaries themselves live OUTSIDE git — they are
# published as release artifacts and rehydrated by fetch-artifacts.sh, which
# verifies each file against the checksum recorded here. The repo tracks only
# manifests. So "deliverable" is judged by checksum presence + well-formedness
# (a whole-file sha256, or a complete part_sha256 split set), NOT by whether a
# binary is committed. A declared artifact with no valid checksum is therefore
# the Option-B analog of the old "missing file" and must fail.
#
# USAGE: bash scripts/internal/check-prebuilt-manifests.sh [prebuilt-dir]
# EXIT: 0 = every declared artifact is tracked; 1 = one or more missing.
# EXIT: 0 = every declared artifact has a valid checksum; 1 = one or more do not.
# =============================================================================
set -euo pipefail

Expand All @@ -29,42 +31,60 @@ PY="$(command -v python3 || command -v python || true)"
[[ -n "$PY" ]] || { echo "[!!] python3 not found on PATH" >&2; exit 1; }

if "$PY" - "$PREBUILT" <<'EOF'
import json, os, glob, sys, subprocess
import json, os, glob, re, sys
root = sys.argv[1]
# Check against git-TRACKED files, not the working tree: a fresh clone (CI, an
# air-gapped bundle) only has tracked content, so an artifact that exists locally
# but was never committed (e.g. blocked by a global *.exe gitignore) must fail.
try:
tracked = set(subprocess.check_output(['git', '-C', root, 'ls-files'], text=True).splitlines())
except Exception as e:
print(f'ERROR: could not list tracked files in {root}: {e}')
sys.exit(2)
HEX64 = re.compile(r'^[0-9a-fA-F]{64}$')

def valid(sha):
return isinstance(sha, str) and bool(HEX64.match(sha.strip()))

def has_checksum(entry):
"""True if this entry carries a verifiable SHA256 — a whole-file hash or a
non-empty part_sha256 split set whose every part is a valid 64-hex digest."""
parts = entry.get("part_sha256")
if parts:
return len(parts) > 0 and all(valid(v) for v in parts.values())
for key in ("sha256", "installer_sha256", "portable_sha256"):
if valid(entry.get(key)):
return True
return False

missing = []
for m in glob.glob(os.path.join(root, '**', 'manifest.json'), recursive=True):
d = os.path.dirname(m)
rel_m = os.path.relpath(m, root).replace(os.sep, '/')
try:
j = json.load(open(m))
except Exception:
continue

# Platform-keyed payloads (tool archives / installers).
for k, v in (j.get('platforms') or {}).items():
name = (v or {}).get('archive') or (v or {}).get('installer')
if not name:
if not isinstance(v, dict):
continue
rel = os.path.relpath(os.path.join(d, name), root).replace(os.sep, '/')
if rel in tracked or any(t.startswith(rel + '.part-') for t in tracked):
name = v.get('archive') or v.get('installer') or v.get('package') or v.get('portable')
if not name:
continue
missing.append((os.path.relpath(m, root).replace(os.sep, '/'), k, name))
if not has_checksum(v):
missing.append((rel_m, k, name))

# Filename-keyed payloads (vscode extensions, generic files/wheels).
for schema in ('extensions', 'files'):
for name, entry in (j.get(schema) or {}).items():
if isinstance(entry, dict) and not has_checksum(entry):
missing.append((rel_m, schema, name))

for man, k, name in sorted(missing):
print(f'MISSING {k:16} {name} (declared in {man})')
print(f'NO CHECKSUM {k:16} {name} (declared in {man})')
sys.exit(1 if missing else 0)
EOF
then
echo "[OK] every manifest-declared artifact is staged."
echo "[OK] every manifest-declared artifact has a verifiable SHA256."
else
echo "" >&2
echo "[!!] Some declared artifacts are missing from prebuilt/." >&2
echo " Stage the file(s) above (a global *.exe gitignore is a common cause —" >&2
echo " prebuilt/.gitignore re-includes them, so use 'git add' after staging)," >&2
echo " or drop the undeliverable platform key from the manifest." >&2
echo "[!!] Some declared artifacts have no resolvable checksum." >&2
echo " Under Option B the binaries live in release artifacts, not git — but" >&2
echo " each must still carry a whole-file 'sha256' or a complete 'part_sha256'" >&2
echo " set so fetch-artifacts.sh can verify it. Regenerate the manifest with" >&2
echo " generate-manifest.py, or drop the undeliverable platform key." >&2
exit 1
fi