Skip to content

ci: run every discovered bats file and skip macOS-only ones - #441

Merged
furedea merged 4 commits into
mainfrom
ci/run-every-linux-compatible-bats-file
Nov 10, 2026
Merged

furedea merged 4 commits into
mainfrom
ci/run-every-linux-compatible-bats-file

Conversation

@furedea-agent

@furedea-agent furedea-agent Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

概要

CI の bats-tests ジョブが bats ファイルを 3 件だけ列挙していたため,残りが CI で走っていなかった.探索ベースに変更し,新しい bats ファイルが黙って漏れないようにする.

設計

  • CI(ubuntu): bats --recursive --filter-tags '!macos' tests
  • Mac(ローカル): 従来どおり bats --recursive tests で全件
  • macOS 専用テストは別ファイルに分け,先頭に # macOS only: <理由> と # bats file_tags=macos(bats 1.12 のファイルタグ)を置く.混在ファイルは <name>_macos.bats に分割する(tests/zsh/startup.bats の 1 件を startup_macos.bats へ)
  • 印の付け忘れは Linux CI で落ちるため,macOS 専用かどうかの判断が強制される
  • テストごとの require_macos ヘルパーは採用しない(印が散らばるため)
  • macOS ランナーの追加はこの PR の範囲外(必要になったら別 Issue で実測してから判断する)

変更

  • .github/workflows/ci.yml: bats-tests を探索実行 + --filter-tags '!macos' に変更
  • macOS 専用ファイルにタグと理由を追加.tests/zsh/startup.bats から macOS 専用の 1 件を startup_macos.bats に分割.tests/zsh/ssh_agent.bats は .zshrc が OSTYPE=darwin でのみ動くため,全件が Linux では空振りになるのでファイル全体を macos タグにした
  • tests/ssh-agent/load_identity.bats: BSD 専用の stat -f を find -perm 0700 に置き換え,Linux でも実行
  • tests/esa/nvim.bats: リポジトリの nvim を runtimepath に追加(~/.config/nvim が無い環境でも動く).dev shell に neovim を追加
  • README: macos タグの意味と CI での除外を追記

#438 はマージ済みで,tests/esa/format.bats は dprint で Linux 上で実行される.

分類(19 ファイル + 分割 1 件)

ファイル 分類 根拠
tests/codex/update_codex.bats linux モックのみ
tests/esa/format.bats linux dprint(dev shell 提供)
tests/esa/nvim.bats linux headless nvim と esa モック
tests/esa/zsh.bats linux モックのみ
tests/herdr/herdr_command.bats macos aarch64-darwin の Home Manager をビルド
tests/hister/server_launcher.bats linux モックのみ
tests/moshi/lifecycle.bats linux モックのみ
tests/moshi/update_moshi_hook.bats linux モックのみ
tests/nix/agent_hook.bats macos darwin の activationPackage をビルド
tests/nix/codex_notification.bats macos darwin 向け codex パッケージをビルド
tests/nix/configuration.bats macos checks.aarch64-darwin をビルド
tests/nvim/lspmux.bats linux headless nvim
tests/ssh-agent/load_identity.bats linux find -perm に置き換えて Linux 対応
tests/ssh-agent/sign_ssh.bats linux モックのみ
tests/terminal-browser/terminal_browser.bats macos darwin-arm64 バイナリを実行
tests/zsh/cache.bats linux モックのみ
tests/zsh/repository_search.bats linux モックのみ
tests/zsh/ssh_agent.bats macos OSTYPE=darwin 限定のロジックで,Linux では全件が空振りになる
tests/zsh/startup.bats linux 10 件
tests/zsh/startup_macos.bats(新規) macos darwin の Home Manager をビルド 1 件

ローカル(bats --count): 全 90 件,--filter-tags '!macos' で 72 件,macOS 専用 18 件.

Closes #440

🤖 Generated with Claude Code

@furedea

furedea commented Nov 10, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-10T17:20:26.061153Z
We couldn’t complete this review. Comment @codex review to try again.
4cae7dd Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Comment thread .github/workflows/ci.yml Outdated
- name: Run Bats tests
run: uv run bats --print-output-on-failure tests/esa/zsh.bats tests/moshi/update_moshi_hook.bats tests/codex/update_codex.bats
# Discovery keeps new files in CI; macOS-only files skip themselves with a reason.
run: uv run bats --recursive --print-output-on-failure tests

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1: Discovery now pulls in several files that build aarch64-darwin derivations, but only tests/nix/configuration.bats skips on Linux. The flake's system is aarch64-darwin, and codex, terminal_browser and friends set platforms = [ "aarch64-darwin" ]. On ubuntu-latest, these will fail because no darwin builder exists:

  • tests/nix/agent_hook.bats: nix build ...#homeConfigurations."kaito@mbp".activationPackage
  • tests/nix/codex_notification.bats: setup_file runs nix build on the darwin codex drv, which fails every test in the file
  • tests/herdr/herdr_command.bats: builds activationPackage and a home.file source
  • tests/zsh/startup.bats:276: builds activationPackage
  • tests/terminal-browser/terminal_browser.bats:36: runs nix build "$_package_drv^*" on a darwin-only package

So the comment "macOS-only files skip themselves" doesn't hold yet, and this change will likely turn bats-tests red. Add the same Darwin guard to these files, at the file level or per test where only some tests build. nix eval-only tests like ssh-agent/load_identity.bats should still be fine.

@github-actions

Copy link
Copy Markdown
Contributor

Review summary

1 blocking finding (P1)

  • P1 .github/workflows/ci.yml:49: bats --recursive tests now runs several files that nix build aarch64-darwin outputs (homeConfigurations."kaito@mbp" and darwin-only packages). Only tests/nix/configuration.bats skips on Linux. Five files still build darwin derivations without a guard, so they will likely fail on ubuntu-latest: nix/agent_hook.bats, nix/codex_notification.bats (in setup_file), herdr/herdr_command.bats, zsh/startup.bats (one test) and terminal-browser/terminal_browser.bats.

The setup_file + skip guard added to configuration.bats looks correct. Putting the same guard on the files above (per test where only some tests build) should make this mergeable.

🤖 Generated with Claude Code

@furedea

furedea commented Nov 10, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions

Copy link
Copy Markdown
Contributor

Automated review: I found no P0–P3 issues.

What I checked:

  • bats --recursive tests finds all 19 .bats files. The test-helper/*.bash files are not .bats files, so they are not run as tests.
  • require_macos sits at the start of each setup/setup_file/test it guards, before any nix build or eval, and no file has a teardown that would fail after a skip.
  • The tests that now run on Linux (ssh-agent, zsh, esa, hister, moshi, codex, nvim/lspmux) use stubs, use nix eval only for activation script text, or run headless nvim, which the new shellPkgs.neovim provides. I found no other hidden darwin dependency. sign_ssh.bats stubs stat, so the BSD stat -f call in the script does not break on Linux.

Note: as the PR description says, tests/esa/format.bats will fail in CI until #438 is merged and this branch is rebased. I didn't run the suite locally because nix and bats aren't installed in this environment.

@furedea

furedea commented Nov 10, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Comment thread .github/workflows/ci.yml Outdated
- name: Run Bats tests
run: uv run bats --print-output-on-failure tests/esa/zsh.bats tests/moshi/update_moshi_hook.bats tests/codex/update_codex.bats
# Discovery keeps new files in CI; macOS-only files skip themselves with a reason.
run: uv run bats --recursive --print-output-on-failure tests

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 — Discovery now picks up tests/esa/format.bats, which on this branch (and on current origin/main) still calls prettierd. prettierd isn't in the dev shell, so bats-tests fails on every run until #438 lands. If this merges before #438, main's CI goes red.

The PR description says this is intentional. Still, the merge order isn't enforced anywhere. Either hold this PR until #438 is merged and rebased, or skip format.bats when prettierd is missing so the job stays green in between.

@github-actions

Copy link
Copy Markdown
Contributor

Review summary

1 blocking finding (P1)

Checked, no issues found

  • require_macos in setup_file (configuration, codex_notification) skips the whole file. In setup and per-test calls it skips only the affected tests. No file defines setup_file twice.
  • The macOS-only skips match what the tests depend on: BSD stat -f, OSTYPE=darwin* in .zshrc, aarch64-darwin builds, and the darwin-arm64 binary.
  • Adding --cmd "set runtimepath^=$REPO_ROOT/nvim" makes require("esa") resolve without ~/.config/nvim linked to the repo. Adding neovim to the dev shell covers nvim.bats and lspmux.bats.
  • Recursive discovery only collects *.bats, so the test-helper/*.bash files aren't run as tests.

Not verified: I couldn't run the suite (no nix, bats or nvim on the review host) or see this PR's CI results. I haven't confirmed that the files marked Linux, which run nix eval on the darwin home configuration, evaluate cleanly on ubuntu-latest within the 15-minute timeout.

🤖 Generated with Claude Code

@furedea-agent
furedea-agent Bot force-pushed the ci/run-every-linux-compatible-bats-file branch from 1bf4c8f to dcd5d56 Compare November 10, 2026 16:45
@furedea

furedea commented Nov 10, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Comment thread tests/ssh-agent/load_identity.bats Outdated

@test "home activation restricts the SSH directory to its owner" {
load ../test-helper/macos
require_macos "the assertion uses BSD stat -f, which GNU stat lacks"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P3 — This test is skipped on Linux only because it reads the mode with BSD stat -f. The activation script it tests (sshDirectoryPermissions) is plain shell, and the test already runs it under /bin/bash. So the only thing that ties it to macOS is the assertion. You could keep this security check (~/.ssh is owner-only) running in CI with a portable mode check, e.g. stat -f %Lp "$dir" 2>/dev/null || stat -c %a "$dir", or a find "$dir" -maxdepth 0 -perm 700 test. Then you wouldn't need require_macos here. This is optional: the test was not running in CI before this PR, so nothing regresses.

@github-actions

Copy link
Copy Markdown
Contributor

Review summary

Blocking findings (P0/P1): 0

I read through the change and checked:

  • bats --recursive tests picks up all 19 .bats files. The test-helper directories hold only .bash files, so nothing extra gets run by mistake.
  • require_macos uses skip. That works from a helper called in setup, setup_file or a test body. No file that skips in setup_file has a teardown_file that would trip over unset state.
  • The macOS gating matches what the tests actually do. Every nix build of kaito@mbp/aarch64-darwin outputs is now gated. The tests still running on Linux only call nix eval on plain activation strings or package drvPaths, which needs no darwin builder.
  • tests/esa/nvim.bats now adds --cmd "set runtimepath^=$REPO_ROOT/nvim". Without it, require("esa") in init.lua only resolves when ~/.config/nvim is symlinked to the repo, so this is needed on CI. lazy.nvim is still stubbed, so no plugins are fetched.
  • neovim from nixpkgs 26.05 is new enough for the vim.lsp.config API that tests/nvim/lspmux.bats uses.
  • tests/esa/format.bats already uses dprint on this branch, so the build(dprint): format Markdown with dprint instead of prettierd #438 dependency looks resolved.

Non-blocking

  • P3 (inline comment): tests/ssh-agent/load_identity.bats could check the SSH directory mode portably instead of skipping on Linux, so the owner-only permission check runs in CI.

I couldn't run the suite here because nix and nvim aren't available, so please confirm the bats-tests job passes within its 15-minute timeout. The nix eval calls on the full Home Manager config are the slowest part.

🤖 Generated with Claude Code

furedea and others added 2 commits November 11, 2026 02:02
The specs relied on ~/.config/nvim pointing at the repository, so put the
repository nvim directory on runtimepath, and add neovim to the dev shell.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
CI discovers tests recursively and excludes files tagged macos, so a new
Bats file can no longer drop out silently. macOS-only specs get a file tag and
a reason; mixed files are split into *_macos.bats, and the SSH directory
mode check now uses a portable find -perm.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@furedea
furedea force-pushed the ci/run-every-linux-compatible-bats-file branch from dcd5d56 to 1a9fe2e Compare November 10, 2026 17:10
@furedea

furedea commented Nov 10, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Comment thread tests/esa/nvim.bats Outdated
ESA_EDIT_FILE="$ARTICLE_FILE" \
XDG_DATA_HOME="$NVIM_DATA_HOME" \
nvim --headless -u "$REPO_ROOT/nvim/init.lua" \
nvim --headless --cmd "set runtimepath^=$REPO_ROOT/nvim" -u "$REPO_ROOT/nvim/init.lua" \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 nvim/init.lua:34 calls require("lazy"). On the Mac, lazy.nvim resolves through the Home Manager neovim wrapper (programs.neovim.plugins = [ lazy-nvim ]). The dev shell's plain shellPkgs.neovim has no plugins. The stub that setup_nvim_data_stub writes to $NVIM_DATA_HOME/nvim/lazy/lazy.nvim/lua/lazy.lua is never on runtimepath, because neither init.lua nor the test adds it.

On Linux CI, init.lua therefore aborts at line 34 with module 'lazy' not found. The test passes only because require("esa").setup() ran before the error and headless nvim still exits 0 after an init error. Everything after line 34 is never run. The spec says "the Neovim configuration saves…", but it doesn't load the configuration cleanly. A later change that moves esa setup after the lazy call would fail confusingly, and this test would not point at the cause.

Suggested fix: put the stub on the runtimepath (both invocations):

nvim --headless --cmd "set runtimepath^=$REPO_ROOT/nvim,$NVIM_DATA_HOME/nvim/lazy/lazy.nvim" -u "$REPO_ROOT/nvim/init.lua" \

Optionally, also assert that stderr has no Error detected while processing.

@github-actions

Copy link
Copy Markdown
Contributor

Review summary

Switching to discovery with --recursive --filter-tags '!macos' looks correct. Bats 1.8+ file tags apply to every test in a file, and untagged files still match the negated filter. Splitting the tests into *_macos.bats with a shared helper keeps the Linux-safe cases running. The find -maxdepth 0 -perm 0700 replacement checks the exact mode portably.

Findings:

  • P2 tests/esa/nvim.bats: the lazy.nvim stub is never on runtimepath. With the dev shell's plain neovim, init.lua errors at require("lazy"). The test passes only because esa setup runs before that line and headless nvim exits 0 anyway. Details are inline.

No blocking findings. When I reviewed, bats-tests was still running on this PR, so I could not confirm the 78 Linux-runnable tests pass on ubuntu.

🤖 Generated with Claude Code

dprint prints plugin compile messages on a cold cache, which broke the exact
output checks on CI. Separate stderr in the format specs. Put the lazy.nvim
stub on runtimepath so init.lua loads fully in the Neovim specs.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@furedea

furedea commented Nov 10, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Comment thread tests/zsh/ssh_agent.bats Outdated
source "$REPO_ROOT/zsh/.zshrc"
print -r -- "${SSH_AUTH_SOCK:-unset}"
'
load test-helper/ssh_agent

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P3 These remaining tests pass trivially on Linux CI. zsh/.zshrc only looks at SSH_AUTH_SOCK inside if [[ "$OSTYPE" == darwin* ... ]], so on ubuntu the whole socket-validation block is skipped. The "refuses a regular file", "refuses a symlink", "leaves no agent set", "keeps the inherited agent" and "preserves a forwarded agent" cases all pass whatever the -S / -O / ! -L checks do. If someone deleted the symlink check, CI would stay green. This isn't a regression, since the file wasn't in CI before. But the split says these are Linux-meaningful, and they aren't. You could move them to ssh_agent_macos.bats as well, or note that Linux CI only checks that nothing changes on non-darwin hosts. (Small detail: the PR body says 4 tests stay here, but there are 6.)

@github-actions

Copy link
Copy Markdown
Contributor

Review summary

No blocking findings (0 × P0/P1).

  • P3 tests/zsh/ssh_agent.bats: the socket-validation tests kept as Linux-runnable pass trivially on ubuntu, because .zshrc gates all of that logic behind OSTYPE == darwin*. CI won't catch a regression in the -S/-O/! -L checks. (Inline comment has details.)

What I checked: discovery with --filter-tags '!macos', file-level # bats file_tags=macos placement, the shared test-helper/ssh_agent.bash load path, the find -perm 0700 replacement (exact-mode match, same as the old stat assertion), the runtimepath prepend in tests/esa/nvim.bats together with the lazy.nvim stub, and the new neovim in the dev shell. I found no correctness problems.

Caveat: this was a static review. bats, nvim and nix weren't available here, so I didn't run the newly discovered Linux suite. The CI run on this PR is what shows that every untagged file really passes on ubuntu.

🤖 Generated with Claude Code

.zshrc gates the 1Password agent logic behind OSTYPE=darwin, so the cases that
passed on Linux were vacuous. Keep them in one tagged file instead of splitting.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@furedea

furedea commented Nov 10, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions

Copy link
Copy Markdown
Contributor

Automated review summary: no findings.

Checked:

  • CI now runs bats --recursive --filter-tags '!macos' inside the flake dev shell. The pinned bats supports file tags and --filter-tags. The dev shell provides neovim (nixpkgs 26.05 has vim.lsp.config, which lspmux.bats needs) and dprint.
  • The find -maxdepth 0 -perm 0700 check is an exact-mode check, so it keeps the meaning of the old BSD stat -f %Lp check.
  • The esa/nvim.bats runtimepath change puts the repo's nvim/lua/esa and the stubbed lazy.nvim on the path, so the test no longer relies on ~/.config/nvim.
  • The startup.bats test moved into startup_macos.bats without changes, and its setup still defines REPO_ROOT and TEST_FLAKE.
  • The remaining untagged files hard-code only paths that exist on Ubuntu runners (/usr/bin/perl, /usr/bin/ssh-keygen, /usr/bin/true).

I reviewed the code but did not run the suite, so I'm relying on the CI run to confirm the newly added Linux files pass.

@furedea
furedea merged commit 8c94fc9 into main Nov 10, 2026
19 of 21 checks passed
@furedea
furedea deleted the ci/run-every-linux-compatible-bats-file branch November 10, 2026 17:31
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.

ci(bats): run every Linux-compatible bats file in CI

1 participant