Skip to content

Automated end-to-end tests, CI and contributor docs (phase 2 of #1) - #3

Closed
CODER7657 wants to merge 4 commits into
fix/phase-1-criticalfrom
test/ci-and-simulation
Closed

CODER7657 wants to merge 4 commits into
fix/phase-1-criticalfrom
test/ci-and-simulation

Conversation

@CODER7657

Copy link
Copy Markdown
Collaborator

Part of #1 (phase 2: tests you can trust). Stacked on #2: this PR's base is fix/phase-1-critical. Once #2 is merged, GitHub retargets it to main automatically.

What this adds

Automated tests that run the real scripts (no Wi-Fi hardware needed)

tests/run.sh             # everything
tests/run.sh daemon      # one suite: daemon | prompt | install

This builds a small Debian image and runs, in a throwaway Docker container:

  1. ShellCheck on every script and test double
  2. systemd-analyze security: fails if the unit's exposure goes above 5.0 (currently 4.2). This is the check that would have caught the v1.5.0 PrivateTmp problem.
  3. 27 bats tests that drive the real fiero-hotspot.sh, fiero-prompt.sh, install.sh and uninstall.sh against test doubles in tests/mocks/:
    • create_ap: reproduces its on-disk contract (config dir, pid, wifi_iface, hostapd command line, USR1 clean exit, --config, --no-virt)
    • iw: uses the exact output formats of iw 6.9
    • notify-send, systemctl, sudo, and a fake charger in /sys/class/power_supply
Suite Covers
daemon.bats (13) start/status/clients/stop, waiting for create_ap's cleanup, passphrase never in ps, other tools' hotspots left alone, --no-virt, channel drift, hung create_ap, lost upstream, unsupported channel, help/version without root
prompt.bats (7) timeout doesn't start, Start click, AUTO_START_ON_TIMEOUT, unplug cancels an open prompt, debounce, stop on unplug, AUTO_PROMPT=false
install.bats (7) fresh install perms, root-shell refusal, bad sudoers never installed, re-install keeps config, password rules, two Wi-Fi cards, uninstall --keep-config

The suites replace system commands, so they refuse to run outside the container. They can't damage a developer's machine.

The same command works on Linux, macOS and Git Bash on Windows (it handles the Windows path conversion).

CI (.github/workflows/ci.yml)

Runs tests/run.sh on every PR and on pushes to main. It's set up the way security-conscious projects do it:

  • actions/checkout pinned to a full commit SHA (v7.0.1)
  • permissions: {} at the top, contents: read for the job
  • persist-credentials: false
  • 20-minute job timeout, and 120 seconds per test so a hang fails fast

dependabot.yml keeps the pinned action up to date, with a 7-day cooldown.

Contributor docs

  • CONTRIBUTING.md: how to report, branch/PR/commit conventions, how to run both test levels
  • Issue forms: Bug report (asks for the card, iw list combinations and the journal) and Hardware report, which feeds a future compatibility list. Security reports are pointed to private vulnerability reporting.
  • README: automated tests section and a CI badge

test_harness.sh stays as the on-hardware check. The two complement each other: the container suite catches logic regressions on every PR, and the harness proves it works with a real card.

Suggestion for the repo settings (owner only)

Once this is merged, consider protecting main (Settings → Branches → add rule): require a pull request and require the CI status check to pass. Then a broken release like v1.5.0 can't reach main again.

🤖 Generated with Claude Code

CODER7657 and others added 3 commits September 26, 2026 18:31
tests/run.sh builds a small Debian image and runs, in a throwaway
container (identical locally - including Git Bash on Windows - and in CI):

- ShellCheck on every script and test double
- systemd-analyze security: exposure must stay <= 5.0 (currently 4.2),
  so a sandboxing change can no longer silently break or weaken the unit
- bats suites that run the *real* fiero-hotspot.sh, fiero-prompt.sh,
  install.sh and uninstall.sh against test doubles of create_ap, iw,
  notify-send, systemctl, sudo and a fake charger (27 tests):
  lifecycle, passphrase handling, other tools' hotspots, --no-virt,
  channel drift, hung create_ap, lost upstream, prompt timeouts and
  stale prompts, sudoers validation, re-install, uninstall

The create_ap double reproduces create_ap's on-disk contract (confdir,
pid, wifi_iface, hostapd command line, USR1 clean exit) and the iw
double uses iw 6.9's exact output formats. The suites refuse to run
outside the container because they replace system commands.

CI (.github/workflows/ci.yml): pinned actions/checkout SHA, permissions
{} with contents: read, no persisted credentials. Dependabot keeps the
pin current with a 7-day cooldown.

test_harness.sh stays as the on-hardware check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- CONTRIBUTING.md: how to report, branch/PR/commit conventions, how to
  run the automated suite and the on-hardware harness (exit code 2)
- issue forms for bug reports (asks for card, iw combinations, journal)
  and hardware reports (feeds a compatibility list); security reports
  are pointed to private vulnerability reporting
- README: automated tests section and CI badge

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On Linux hosts (GitHub Actions) Docker's default AppArmor profile denies
every write under /sys inside the container - even to the tmpfs mounted
at /sys/class/power_supply - so the prompt and install suites failed in
setup with "mkdir: cannot create directory '/sys/class/power_supply/AC':
Permission denied". Docker Desktop on Windows has no AppArmor, which is
why it passed locally.

tests/run.sh now mounts one scratch volume twice: at
/sys/class/power_supply, where the scripts read the charger state, and at
/fake-power, where the tests write it. The volume is removed after the
run. Reproduced locally by mounting the /sys path read-only: the previous
tests fail exactly like CI, these pass (27/27).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Fiero1186
Fiero1186 deleted the branch fix/phase-1-critical September 27, 2026 16:24
@Fiero1186 Fiero1186 closed this Sep 27, 2026

@Fiero1186 Fiero1186 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved Phase 2 CI workflows and community templates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants