Skip to content

feat: production-grade overhaul — testability, test coverage, CI optimization#9

Merged
PKramek merged 6 commits into
developfrom
feat/production-grade-overhaul
Apr 9, 2026
Merged

feat: production-grade overhaul — testability, test coverage, CI optimization#9
PKramek merged 6 commits into
developfrom
feat/production-grade-overhaul

Conversation

@PKramek

@PKramek PKramek commented Apr 8, 2026

Copy link
Copy Markdown
Owner

Summary

Production-grade overhaul of the installer, test suite, and CI pipeline addressing testability, coverage gaps, robustness, and a fundamentally broken completions feature.

install.sh refactor + 11 bug fixes

  • main() guard: all execution logic wrapped in main() with BASH_SOURCE guard — install.sh can now be sourced safely for unit testing individual functions
  • pacman -Sy-Syu (avoid Arch partial upgrade)
  • Fix spurious ERR trap in cleanup
  • Broaden ANSI stripping (ESC(B, ESC=, ESC>)
  • Clean claude --version output via head -n1
  • Normalize boolean options case-insensitively
  • Restrict detect_remote_user UID range to 1000-60000
  • Whitespace skip uses [^[:space:]]
  • Add curl timeouts (30s connect, 300s max)
  • Create fish completions dir if missing

Static shell completions (replaces broken dynamic generation)

The previous approach ran claude completions bash at Docker build time, which never worked — it requires authentication unavailable during builds. After 8+ fix iterations polishing a cleanup pipeline for a code path that never succeeded, this PR replaces the entire approach:

  • Ship pre-generated bash/zsh/fish completion scripts covering all subcommands and flags
  • setup_completions() is now a simple file copy (30 lines replacing 140 lines of ANSI/CRLF/timeout pipeline)
  • Completions are always installed — users get working tab completion on first container start
  • Delete generate_completion() and the entire dynamic generation pipeline

Test suite overhaul (10 → 17 scenarios)

  • completions_pipeline: validates static files are installed, have correct permissions (644), contain expected subcommands and pass integrity checks
  • negative_validation: input validation rejection tests for all 3 validators
  • security_permissions: file permission and ownership validation
  • custom_node_version: nodeVersion=22 binary download path
  • fedora_default: RHEL/Fedora code path coverage
  • upgrade_version: version upgrade test
  • install_path_with_completions: option combination test
  • Strengthened 7 existing scenarios (default_options, completions_disabled, mount_host_config, custom_install_path, idempotency, node_preinstalled, multi_feature_combo)
  • New helpers: check_completion_file_integrity, check_file_contains, check_file_not_contains, check_no_world_writable
  • Completions tests now assert presence — no more "auth likely unavailable" pass-on-absence fallbacks
  • Removed orphaned duplicate.sh

CI optimization (27 → 8 images)

  • PR matrix reduced from 27 to 8 images (same code path coverage, ~60% faster)
  • Nightly extended matrix with 5 additional images
  • shfmt download verified with SHA256 checksum
  • Positive success assertion in all test jobs (prevents false greens)

Test plan

  • All 17 scenarios pass
  • All 8 image matrix jobs pass
  • arm64 tests pass (ubuntu:24.04, alpine:3.21)
  • ShellCheck + shfmt clean
  • Completion files always present when shellCompletions=true
  • Completion content contains known subcommands (auth, mcp, update)
  • Negative validation tests reject all invalid inputs
  • Security permissions tests verify correct file modes
  • Zero WARNING lines from completions in build logs

PKramek added 4 commits April 9, 2026 11:57
Structural:
- Wrap execution logic in main() with BASH_SOURCE guard
- Replace dynamic completions pipeline with static files
- Ship bash/zsh/fish completion scripts in src/claude-code/completions/
- Delete generate_completion() (66 lines of ANSI/CRLF/timeout cleanup)
- Rewrite setup_completions() as simple file copy (140 → 30 lines)

Bug fixes:
- CQ-1: pacman -Sy → -Syu
- CQ-2: cleanup() uses if/then (fix ERR trap)
- CQ-3: broaden ANSI stripping
- CQ-10: claude --version via head -n1
- CQ-11: boolean normalization via ${VAR,,}
- CQ-12: detect_remote_user UID 1000-60000
- CQ-14: whitespace skip [^[:space:]]
- CQ-15: curl timeouts
- CQ-17: create fish completions dir if missing
…sence

- 7 new scenarios: completions_pipeline, negative_validation, security_permissions,
  custom_node_version, fedora_default, upgrade_version, install_path_with_completions
- Completions tests assert files MUST exist (no more pass-on-absence fallbacks)
- Content assertions verify known subcommands (auth, mcp, update) in completion files
- 4 new helpers: check_completion_file_integrity, check_file_contains,
  check_file_not_contains, check_no_world_writable
- Strengthened existing scenarios (mount_host_config, custom_install_path, idempotency, etc.)
- Removed orphaned duplicate.sh
@PKramek PKramek force-pushed the feat/production-grade-overhaul branch from 814b55d to ca725d2 Compare April 9, 2026 10:00
@PKramek PKramek merged commit 43f05a2 into develop Apr 9, 2026
13 checks passed
@PKramek PKramek deleted the feat/production-grade-overhaul branch April 9, 2026 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant