Repository navigation
test: add TeX Live integration fixtures and CI job - #33
Conversation
Add fixture projects under crates/texrun-texlive/tests/fixtures and integration tests that compile them through the workspace and the latexmk engine, checking structured results (outcome, diagnostic kind/file/line, artifacts, PDF page count) instead of full logs. Security fixtures check the docs/security.md section 2 guarantees. TeX Live tests are selected at runtime: skipped with a SKIPPED note when latexmk is missing, and failing instead when TEXRUN_REQUIRE_TEXLIVE=1 (the same scheme as TEXRUN_REQUIRE_PREVIEW_TOOLS in texrun-preview). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Build the Docker dev image in CI (buildx with the GitHub Actions cache) and run the whole test suite in it with TEXRUN_REQUIRE_TEXLIVE=1 and TEXRUN_REQUIRE_PREVIEW_TOOLS=1. Pin the base image by digest and let Dependabot update it. Document how to run the integration tests. Co-Authored-By: Claude Opus 5.5 <[email protected]>
nishide-dev
left a comment
There was a problem hiding this comment.
Verdict: CHANGES_REQUESTED
全体としてよくできた PR です。fixture は Issue #10 の作業内容をほぼ全部カバーしていて、検証は構造化結果(outcome / diagnostic の kind・file・line / artifact / ページ数)に基づいています。security テストも、1 件を除いて対照実験付きで実際に防御を検出できることを確認しました(下の「実行結果」)。ただ、その 1 件が常に pass する偽陽性だったので must-fix にしています。
must-fix
1. format_line_is_ignored が常に pass する(偽陽性)
fixtures/security/format-line/main.tex の先頭行は、存在しない format 名を指定しています。ところが web2c は、%& で指定された format が見つからないとき、既定の format(pdflatex.fmt)に黙ってフォールバックします(Sorry, I can't find the format ...; will try 'pdflatex.fmt'.)。そのため、先頭行が解釈されても compile は成功し、テストは防御の有無に関係なく pass します。
確認したこと(PR の image rust:1.98.1-slim-trixie@sha256:4cd8… から build したもの):
rc.rsのRUN_COMMANDSから-no-parse-first-lineを外しても、format_line_is_ignoredは pass したままだった(失敗したのはauxiliary_tools_are_started_without_a_shellの引数検査だけ)- コンテナで
pdflatex -parse-first-lineを直接実行すると、この fixture の exit code は 0 だった
修正案: 先頭行では、実在していて LaTeX を含まない format を指定する。たとえば %&pdftex(image には pdftex / etex の fmt がある)。先頭行が解釈されると \documentclass が未定義になり、-halt-on-error で Failed になります。手元で確認した結果は次のとおりです。
%&pdftexに変えた fixture: 現行コードでは pass%&pdftexに変え、さらに-no-parse-first-lineを外した場合: FAIL(期待どおり検出できる)
テストのコメント("would look for a format that does not exist and fail")も合わせて直してください。可能なら、他の security テストと同じく、対照(先頭行を解釈させると失敗すること)を test 内に置けるとなお良いです。たとえば、同じ fixture を pdflatex 直接実行で -parse-first-line 付きで走らせ、失敗することを確かめる形です。
should-fix
2. buildx の cache-to が PR からも GHA cache に保存している
cargo cache は「save は main の push のときだけ」になっていますが、docker/build-push-action の cache-to: type=gha,scope=texrun-dev,mode=max は PR でも実行されます。このため PR からも cache が保存されます。今回の run では exporting to GitHub Actions Cache が 27.6 秒かかっていました。
GitHub の cache は ref でスコープが分かれるので、PR の cache が main から restore されることはありません。そのため、直ちに poisoning が起きるわけではありません。ただし次の問題があります。
- PR 側の保存方針が cargo cache と食い違っている
- Dockerfile を変える PR(週次の Dependabot の digest 更新を含む)のたびに、image 全層(mode=max)が PR スコープに書き込まれ、10 GB の枠を圧迫する。main の cache が evict される要因になる
- PR の実行時間が約 30 秒延びる
修正案:
cache-from: type=gha,scope=texrun-dev
cache-to: ${{ github.ref == 'refs/heads/main' && 'type=gha,scope=texrun-dev,mode=max' || '' }}合わせて、コメント("Layers are cached ...")と CONTRIBUTING.md の説明に「保存は main のみ」と書いてください。
nit
-
fast job では skip が見えない。
test (linux)のログは288 tests run: 288 passed, 0 skippedだけで、SKIPPED行は 0 件でした。nextest は test ごとに process を分け、出力も capture するためです。integration job が実行を保証しているので実害はありませんが、「0 skipped」は誤解を招きます。.config/nextest.tomlに次の override を置けば、該当する binary の stderr が末尾にまとめて表示されます(CI profile だけでも可)。[[profile.default.overrides]] filter = 'package(texrun-texlive) | binary(real_tools)' success-output = 'final'
nextest では test ごとに process が分かれるので、「binary ごとに 1 回」ではなく test ごとに表示されます。docs/development.md の記述もこの点を補足すると正確になります。
-
referencesが latexmk の stderr の文言(Kpsewhich command needed but not set up)を完全一致で見ています。これは latexmk の version に依存するログ文言なので、「構造化結果で検証」という方針から少し外れます。engine の挙動の確認ならlatexmk.rs側に移すか、失敗時のメッセージで latexmk の version 差の可能性に触れておくと、後で調べやすくなります。 -
rc の検証で置いているのは HOME 直下の
latexmkrc/.latexmkrcだけです。latexmk が読む user rc には$HOME/.config/latexmk/latexmkrc(XDG 未設定時の既定)もあるので、そこにも置いておくと保証の表の「HOME の rc」を網羅できます(-norcで全部止まるので、現状でも実害はありません)。 -
Issue #10 の security 項目は「
\write18/\immediate\write18」となっていますが、fixture は\immediate付きだけです。shipout 時に実行される非 immediate 版も 1 行足すと、Issue の記載どおりになります。 -
docs/development.md の digest 確認手順(
docker buildx imagetools inspect)は buildx 前提です。OrbStack 同梱のdockerのように buildx の無い環境向けに、docker manifest inspectなどの代替を一言添えると親切です。なお、固定した digestsha256:4cd8…が Docker Hub のrust:1.98.1-slim-trixieの multi-arch index と一致することは registry API で確認済みです。
良かった点
require_texlive!+TEXRUN_REQUIRE_TEXLIVE=1の方式は #31 とそろっています。cargo feature を採らなかった理由(--all-featuresの fast job で TeX が必須になってしまう)も妥当です。OnceLockで probe を 1 回にしている点、stderr に直接書いて libtest の capture を避けている点も良いです。- outside-paths の対照(workspace 内なら読める・書ける)と
with_temp_parentの設計は的確です。..が意図した probe を指していることを、下の mutation で確認しました。 - 補助ツールの wrapper による親プロセス・引数の検査は、shell 経由に戻すと実際に検出できます。
- Issue #9 の申し送りのうち、「
.texrun/out配下に paranoid mode で\includeの子.auxを書けるか」はmulti_fileで担保されています(texrun は-outdirを常に絶対パスで渡すので、相対パスの場合は対象外)。 ci-successへの組み込み、persist-credentials: false、top-level のpermissions: contents: read、action の SHA pin は問題ありません。PR の Dockerfile から build しますが、pull_requestでは secrets も書き込み権限もないので許容範囲です。
実行結果(レビュアー環境)
-
host(macOS、TeX Live なし):
cargo fmt --check/cargo check --all-targets --all-features --locked/cargo clippy ... -D warnings/actionlintはすべて OK。cargo test --workspace --lockedは pass し、SKIPPED行が binary ごとに表示された -
host で
TEXRUN_REQUIRE_TEXLIVE=1 cargo test --workspace --locked --no-fail-fast: TeX を使う test がすべて FAIL した(期待どおり)。TeX を使わないmissing_latexmk_is_unavailableと symlink の test は pass -
PR の Dockerfile を別 tag で build し、
TEXRUN_REQUIRE_TEXLIVE=1 TEXRUN_REQUIRE_PREVIEW_TOOLS=1 cargo test --workspace --all-features --lockedを実行: 全件 pass(texlive unit 47、latexmk 10、scenarios 11、security 14、preview real_tools 13) -
security テストの mutation 確認(一時的に engine を変更し、
--test securityを実行):変更 失敗した test openin_any=ainput_*/openin_*の 4 件openout_any=aopenout_*の 2 件-norcを削除rc_files_in_the_project_are_not_copied_or_readshell escape を有効化 shell_escape_*の 2 件補助ツールを internal経由から通常のコマンド文字列に戻すauxiliary_tools_are_started_without_a_shell-no-parse-first-lineを削除format_line_is_ignoredは pass のまま(上の must-fix 1) -
CI:
integrationは 2 分 21 秒(cache なしの初回。image build 約 1 分 42 秒のうち、GHA cache への export が 27.6 秒、cargo build が 13 秒)
#34 との方式の揃え方(merge 後の提案)
#34 の apps/texrun/tests/texlive.rs は #[ignore] + texlive_ prefix の方式です。この PR の integration job は --ignored を付けずに cargo test を実行するので、両方が merge されると #34 の TeX test は CI で一度も実行されず、黙って ignored と数えられます。そこで次の順序を提案します。
- この PR を先に merge し、#34 を rebase する。
- #34 側で
#[ignore]をやめ、TEXRUN_REQUIRE_TEXLIVE/TEXRUN_REQUIRE_PREVIEW_TOOLSによる実行時検出に置き換える(SKIPPED ... (set ...=1 to fail instead)の文言もそろえる)。texlive_prefix は filter 用に残しても構いませんが、選別の仕組みにはしない。 - helper の共有について: 当面は
apps/texrun/tests/common/mod.rsに最小限のtexlive_available()/require_texlive!/previewer()を複製する。3 つ目の利用者が出た時点で、publish = falseの dev-only crate(例:crates/texrun-test-support)に切り出す。 - fixture は
concat!(env!("CARGO_MANIFEST_DIR"), "/../../crates/texrun-texlive/tests/fixtures")で参照し、#34 のインライン文書(include・timeout・error)は既存のmulti-file/timeout/undefined-commandに寄せる。 - 再発防止として、integration job に「TeX 用の
#[ignore]が無いこと」を確認する step を入れる(例:git grep -n 'ignore = "requires TeX' && exit 1 || true)。-- --include-ignoredを付ける案もありますが、TeX とは別の理由で ignore された test まで実行されるので、grep の方が安全です。
- format-line: name an installed format without LaTeX, so honouring the first line fails the compile; add a control run of pdflatex with the first line parsed - shell-escape: also cover a non-immediate \write18 - rc files: also place ~/.config/latexmk/latexmkrc - references: stop matching latexmk's console wording Co-Authored-By: Claude Opus 5.5 <[email protected]>
… TeX tests - buildx cache-to only on main pushes, like the cargo cache - fail the integration job if a TeX Live test is #[ignore]d - show SKIPPED lines under nextest (.config/nextest.toml) - document the nextest output and the digest lookup without buildx Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
レビューありがとうございます。73b092f / 29d931e で対応しました。
🤖 Generated with Claude Code |
nishide-dev
left a comment
There was a problem hiding this comment.
Verdict: APPROVE
73b092f / 29d931e の指摘対応を確認しました。must-fix と should-fix はどちらも解消しています。退行もありません。残りは nit 1 件だけです。
前回の指摘の確認
| 前回の指摘 | 状態 | 確認したこと |
|---|---|---|
must-fix 1: format_line_is_ignored が偽陽性 |
解消 | %&pdftex に変わり、pdflatex を直接実行する対照も追加された。-no-parse-first-line を外すと format_line_is_ignored が FAIL するようになった(前回は pass のままだった) |
| should-fix 2: PR から image cache を保存している | 解消 | 最新 run の integration log に exporting to GitHub Actions Cache が無い。所要時間は 2m21s から 1m12s に短縮 |
| nit 3: fast job で skip が見えない | 解消 | test (linux) / test (macos) の log に SKIPPED 行が出るようになった(texrun-texlive の行は linux で 34 行) |
nit 4: references が latexmk の文言に依存 |
解消 | 文言の完全一致をやめ、diagnostic にならないことだけを見ている |
| nit 5: XDG の rc | 解消 | ~/.config/latexmk/latexmkrc にも置くようになった |
nit 6: 非 immediate の \write18 |
解消 | fixture に追加。marker の prefix が同じなので、既存の検査で拾える |
| nit 7: digest の確認手順 | 解消 | buildx の無い環境向けの手順を追記 |
mutation の再確認(最新 head 29d931e、PR の image)
| 変更 | 失敗した test |
|---|---|
openin_any=a |
input_* / openin_* の 4 件 |
openout_any=a |
openout_* の 2 件 |
-norc を削除 |
rc_files_in_the_project_are_not_copied_or_read |
-no-parse-first-line を削除 |
format_line_is_ignored、auxiliary_tools_are_started_without_a_shell |
| shell escape を有効化 | shell_escape_* の 2 件 |
shell escape を有効化し、fixture を非 immediate の \write18 だけにする |
shell_escape_write18_is_not_executed など 2 件(shipout 時の実行も検出できる) |
補助ツールを internal 経由から通常のコマンド文字列に戻す |
auxiliary_tools_are_started_without_a_shell |
| 変更なし | 14 件すべて pass |
実行結果
- host(macOS、TeX Live なし):
cargo fmt --check、clippy -D warnings、actionlintはすべて OK。cargo test --workspace --lockedは pass した - host で
TEXRUN_REQUIRE_TEXLIVE=1: TeX を使う test 34 件が FAIL した(期待どおり) - コンテナで両方の変数を立てた
cargo test --workspace --all-features --locked: 全件 pass(texlive unit 47、latexmk 10、scenarios 11、security 14、preview real_tools 13) - CI: 全 check が pass
nit
-
#[ignore]を検出する grep に、見逃しと誤検出があります。 使い捨ての repo でサンプルを作って試しました。- 検出できたもの: #34 の
#[ignore = "requires TeX Live with latexmk; ..."](#34 の diff にある 5 件はすべて該当します。#34 をこのまま merge すると integration が失敗するので、意図どおりの防止になっています)、TeXLive、pdflatex - 見逃すもの: 理由の無い
#[ignore]、"requires TeX"だけの理由、preview tool(mutool/pdftoppm/ "preview")、#[cfg_attr(..., ignore = "requires TeX Live")]、理由を次の行に書いた attribute - 誤検出するもの:
#[ignore]と TeX Live の両方に触れるコメント行、TeX と関係の無い ignore の理由に "latexmk" という語が入る場合
docs/development.md は「TeX Live / preview tool を使う test に
#[ignore]は使わない」と書いていますが、検査の対象は TeX Live の語だけなので、少し食い違っています。現状は repo に ignore された test が 1 件も無い(integration log の全 binary が0 ignored)ので、文字列で探すのをやめ、integration job の結果に ignored の test が 1 件も無いことを確認する方が単純で確実です。例えば、Run testsstep で test の出力をteeでファイルに残し(set -o pipefailを付けて exit code を保つ)、grep -E 'test result: .* [1-9][0-9]* ignored'が当たったら失敗させる。こうすれば理由の書き方に依存しません。TeX と無関係な ignore が将来必要になったら、そのときに許可リストを設ければ十分です。merge を止めるほどではないので、follow-up でも構いません。 - 検出できたもの: #34 の
#34 との揃え方
前回の提案から変わっていません。#33 を先に merge し、#34 は rebase して #[ignore] を require_texlive!() 方式に置き換えます。上の grep が #34 の現在の書き方を検出するので、置き換えを忘れても integration job で止まります。
## 概要 MVP の主要インターフェースとして `texrun compile [OPTIONS] <ENTRYPOINT>` を実装します(#6)。workspace 作成 → latexmk 実行 → 成功時の page preview(#8 / PR #31)→ artifact の収集 → workspace 削除を 1 コマンドで行い、結果を human-readable または JSON(`Versioned<...>`)で返します。exit code を確定し、README とヘルプに記載しました。 ## 変更内容 - **`apps/texrun`**(`cli.rs` / `compile.rs` / `report.rs` / `human.rs` / `escape.rs` / `duration.rs` / `signals.rs`) - option: `--json`、`-o, --output <DIR>`、`--root <DIR>`、`--timeout <DURATION>`(既定 `60s`、`90` / `2m` / `1500ms` 形式、0 は usage error)、`--keep-workspace`、`--source-date-epoch <SECONDS>`、`--no-preview`、`--pages <RANGE>`、`--preview-dpi <DPI>`、`--preview-backend <auto|mupdf|poppler>` - pipeline: `ProjectInput::from_host_entrypoint` → root の安全性チェック → `LatexmkEngine::probe()`(latexmk 不在をコピー前に検出し、version を結果に載せる)→ `Workspace::create` → `engine.run`(`CancelToken` 共有)→ `Succeeded` のときだけ `Previewer::render`(workspace の output dir に描画し `attach_to`)→ `collect_artifacts(.., OverwritePolicy::Replace)` → `ws.close()` - **出力先**: 既定は entrypoint 隣の `texrun-out/`。同名ファイルは atomic に置き換え、destination の symlink は拒否(#21 の collect の挙動)。過去の run の PDF / preview は削除しない(help と README に明記)。`texrun-out` は常に、root 直下の `--output` は `excluded_root_names` で、次回の workspace にコピーしない - 出力先ディレクトリへの経路は 1 component ずつ `symlink_metadata` で辿り(各ディレクトリは canonical な綴りに置き換えて比較するので、大文字小文字や Unicode 正規化を区別しない filesystem でも判定がずれない)、**project root 内にある symlink**(または非ディレクトリ)があれば `unsafe_output_path`(stage `output`、exit 3)で拒否する。compile 前に一度確認し、コピー時に `create_dir` で 1 段ずつ作りながら再確認する(`apps/texrun/src/output.rs`)。project 外の symlink(macOS の `/tmp` や、user が明示した `--output` の link)は辿る - root の 2 段以上下の `--output` は次回の workspace にコピーされるため、warning(`notes[].kind = output_inside_project`)を出す。パスでの除外は #36 - **root の扱い**: `/` は常に拒否。`$HOME` と system temp dir(`TMPDIR`、`/tmp`、`/var/tmp`)は、既定 root になる場合は `unsafe_root`(exit 2)で拒否し、`--root` で明示された場合は stderr に warning を出して続行 - **exit code**(help / README に記載) | code | 意味 | | --- | --- | | 0 | 成功(PDF あり) | | 1 | 文書の compile 失敗(diagnostics あり。output limit 超過も含む) | | 2 | usage / input error(clap の usage error、entrypoint 不在・root 外、symlink が root 外、入力上限、unsafe root、engine の `InvalidRequest`) | | 3 | runtime error(latexmk 不在 / 起動失敗、I/O、artifact の収集失敗) | | 4 | timeout | | 128+N | signal による中断(SIGINT 130 / SIGTERM 143 / SIGHUP 129)。compile 後の preview 中に中断した場合も含む | signal 以外では preview は exit code に影響しない(失敗は notice)。`WorkspaceErrorKind::is_input_error()` を 2、それ以外を 3 にしています - **Ctrl-C**: `signal-hook`(iterator のみ)で SIGINT / SIGTERM / SIGHUP を受け、`CancelToken` を立てるだけにしました。engine と previewer がそれを見て process group を kill し、通常経路で collect・workspace drop を行ってから `main` が `ExitCode` を返します(`process::exit` は使いません)。2 回目以降の signal は「停止中」と表示するだけです - **human-readable**(stdout = 結果、stderr = texrun 自身の warning / error) - diagnostics: `file:line: error: message`。error → warning → note の順で、同一内容は `(xN)` にまとめ、各 20 件まで(残りは件数と `--json` の案内)。file は user が打った root 基準(例 `paper/chapters/intro.tex:3:`) - 状態行(`Compiled` / `Failed to compile` / `Timed out ... (limit 60s; raise it with --timeout)` / `Cancelled`)と経過時間、PDF(失敗時は log)と preview のパス、preview notice - workspace で除外した latexmkrc / biber.conf、`*.fmt`、dangling symlink 等を stderr に warning 表示(docs/security.md §3.3)。`--keep-workspace` のパスは compile 前に stderr に出す - 表示時は制御文字(C0 / DEL / C1、改行を含む)、Unicode Cf(bidi 制御・ゼロ幅・U+FEFF 等)、U+2028/2029 を `\u{XXXX}` で escape(docs/security.md §2)。JSON はそのまま - `MissingFile` の message に `../` がある場合、「`--root` を付けても entrypoint のディレクトリより上は読めない。entrypoint を include 先を含むディレクトリに移す」旨の note を出す(§3.5)。JSON では `notes` に入る - latexmk 不在時は `hint`(PATH に latexmk を入れる / Docker 開発環境)を付ける。entrypoint が root 外を指す symlink の場合は、その旨を hint に出す - **JSON**: stdout には JSON 1 つだけ(成功・失敗・timeout・runtime error・`--json` 付きの usage error いずれも)。 - `texrun_exit_code`(texrun 自身の exit code)と、`CompileResult` を flatten したもの(`outcome` / `engine` / `exit` / `elapsed_ms` / `diagnostics` / `artifacts`)。`exit` は latexmk プロセスの終了状態で、README と doc に明記した(名前は core の `CompileResult` のまま) - `preview`(`PreviewReport`)、`output_dir`(絶対パス)、`artifacts_not_copied`(コピーが途中で失敗したときの未コピー分)、`notes`(`parent_directory_input` / `broad_project_root` / `output_inside_project`)、`project`(canonical root と entrypoint)、`workspace`(excluded / excluded_total / vanished / kept_path)、`error`(`stage` / `kind` / `category` / `message` / `hint`) - artifact は 1 件ずつコピーし、失敗した時点で止める。`artifacts` はコピー済みのものだけ、残りは `artifacts_not_copied` に入る。human 表示では「Compiled ..., but the output could not be copied to DIR」と未コピーの一覧を出す - `error.kind` の一覧(CLI / engine / workspace)を README に記載し、CLI 固有の code が README にあることを unit test で確認する - artifact の path は core の契約どおり output root 相対のままにし、絶対パスは `output_dir` 1 箇所だけに持たせました(preview を含め `output_dir` + `path` で解決できるため、per-artifact の絶対パスは付けていません) - host path は UTF-8 前提です。entrypoint / `--root` / `--output` が UTF-8 でない場合は `non_utf8_path`(exit 2)で拒否します - **`SOURCE_DATE_EPOCH`**: option 指定時だけ `LatexmkConfig::with_source_date_epoch` に渡します。環境変数は読みません(§3.9) - **README**: CLI 節を実装に合わせて書き換え(option 表、出力の方針、JSON 形状、exit code 表)。Status の「未実装」を更新 - **docs/security.md**: §3 冒頭の「timeout 以外を CLI で上書きできるかは #6 で決める」を、決定内容(timeout と preview のページ範囲・DPI のみ)に置き換え - **依存追加**: `signal-hook 0.4.4`(`default-features = false, features = ["iterator"]`、MIT OR Apache-2.0) ## 確認方法 - [x] `cargo check --workspace --all-targets --all-features --locked` - [x] `cargo fmt --all -- --check` - [x] `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`(host の macOS と dev container の Linux) - [x] `cargo test --workspace --locked`(host) - [x] `cargo deny --locked check` - [x] dev container: `docker compose run --rm -e TEXRUN_REQUIRE_TEXLIVE=1 -e TEXRUN_REQUIRE_PREVIEW_TOOLS=1 dev cargo test --workspace --all-features --locked` で全件成功(`apps/texrun` の TeX Live E2E 6 件を含む。ignored は 0 件) test: - unit: escape(ANSI / bidi / ゼロ幅 / C1 / タグ文字)、duration の parse / 表示、exit code の対応、error chain、JSON の形(error のみ / flatten)、human 表示(位置付き diagnostics、集約と件数上限、escape、timeout、preview 行と notice)、clap 定義、root の安全性チェック、output dir が root 直下かの判定 - `tests/cli.rs`(TeX 不要。`PATH` を sandbox の bin だけにし、fake の `latexmk` / `pdfinfo` / `pdftoppm` shell script を置く。`TMPDIR` / `HOME` も test ごとに分離): help / version、usage error(JSON あり・なし)、成功時の出力先と JSON 形状、`--output` / `--root`、文書エラー(exit 1、diagnostics の file / line、表示時の escape と JSON の生文字列)、latexmk 不在(exit 3、`stage: probe`、`kind: unavailable`)、入力エラー(exit 2)、`$HOME` / temp dir の root 拒否、latexmkrc の warning、timeout(exit 4、子の停止)、SIGINT / SIGTERM(exit 130 / 143、子の停止、temp dir に何も残らない)、`--keep-workspace`、`--source-date-epoch`(環境変数は渡らない)、出力先の symlink(exit 3 だが `outcome` は残る)、preview の描画と収集・`--pages`・失敗時は preview なし・tool 不在は warning のみで exit 0 - `tests/texlive.rs`(#33 と同じ実行時検出方式。`require_texlive!()` / `require_preview_tools!()`、helper は `tests/common` に最小限複製。名前は `texlive_` prefix): 実 TeX Live での成功(include あり)、`crates/texrun-texlive/tests/fixtures` の `minimal` を `-o` 付きで compile して fixture 側に何も書かないこと、位置付きエラー(`chapters/intro.tex:3`)、preview(3 ページ、`--pages 2 --preview-dpi 72`)、timeout(`timeout` fixture)、SIGINT で exit 130 と temp dir の cleanup - `output.rs` の macOS 専用 unit test: 大文字小文字違い・NFC/NFD 違いの path でも project 内の symlink を拒否すること ## 関連 Issue Closes #6 Refs #12 ## 補足 - **Windows**: `apps/texrun` が `texrun-workspace` / `texrun-texlive` / `texrun-preview` に依存するので、CLI は Unix 専用になります(README の System requirements どおり) - **Ctrl-C のタイミング**: probe 中に signal を受けた場合は workspace を作らずに `cancelled` を返す。workspace のコピー中は中断できないが、コピー後は engine が latexmk を起動しない - **follow-up**: #35(missing package の行番号・fatal error の件数、#7 系)、#36(root 配下の深い出力先をパスで除外) - **#29 からの申し送り(`WorkspaceChanged` の分離)**: CLI 側では `ArtifactNotFile` をそのまま `kind` に出し、分離はしていません。外から区別する手段がないため、分けるなら workspace crate 側に variant を足すのが筋だと考えています(`#[non_exhaustive]` なので追加は非破壊) - **stale な出力**: 失敗した run では過去の `main.pdf` や、ページ数が減ったときの古い `preview/page-NNN.png` が出力先に残ります。user の `--output` を消すのは避け、JSON の `artifacts` / exit code を正とする方針にしました - **preview の cancel**: preview 中の Ctrl-C は preview を止め(notice `cancelled`)、`outcome` は `succeeded` のまま、exit code は 130 になります - **nit 候補(今回は未対応)**: `--latexmk <path>` は出していません(#30 の指摘どおり相対パス解決の罠があるため、必要になったら別 Issue で)。TeX 由来でない上限(出力サイズ等)は CLI から変更できません - **CI**: #33 再レビューの提案どおり、`integration` job の `#[ignore]` 検出を「test 出力に ignored が 1 件でもあれば失敗」(`tee` + `pipefail` で `test result: .* [1-9][0-9]* ignored` を検出)に置き換えました(`git grep` の step は削除)。docs/development.md の該当箇所も更新しています 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
## 概要 `v*` の tag を push するだけで、検証 → engine image の公開 → **release notes 付き** の GitHub release の作成(source tar 添付)まで完了するようにする。release notes は前の版の tag から今回の tag までの commit(= squash merge した PR タイトル、Conventional Commits)を git-cliff で分類して生成し、インストール方法・image の tag / digest・`gh attestation verify`・source tar の説明を定型で付ける。既存 release の notes だけを作り直す workflow も追加する(v0.1.0 の notes を埋めるのに使う)。 ## 変更内容 - `cliff.toml`(新規): git-cliff の設定。type で分類(`feat` → Features / `fix` → Bug fixes / `perf` → Performance / `docs` → Documentation / `refactor`・`test`・`build`・`chore` → Other changes)。`chore(deps)` は Dependencies に「N dependency updates: #a, #b」の 1 行にまとめる(PR 番号はタイトル行の末尾の `(#N)` だけから取る。番号の無いものは件数にだけ数える)。`!` / `BREAKING CHANGE:` は Breaking changes にも載せる。Conventional でない commit も Other changes に残す。**すべての行は commit のタイトル(1 行目 = PR タイトル)だけから作り**、PR 本文や footer の文面は載せない。末尾の `(#N)` を PR へのリンクにし、`@name` は mention にならないよう code にし、前の版との compare リンクを付ける。 - `.github/scripts/release-notes-test.sh` / `release-notes-test.expected.md`(新規): 使い捨ての repository に main の squash merge と同じ形の fixture の commit(PR 本文付き、実際の Dependabot 形式の本文付き(単独・group)、PR 番号の無い `chore(deps)`、日本語の `BREAKING CHANGE:` footer + attribution、GitHub の Revert、`@name` を含むタイトル)を作り、notes の「What's changed」を期待値と比べる。PR の `notes` job で毎回実行する。 - `.github/scripts/release-notes.sh`(新規): `release-notes.sh <tag> [<digest>]` で notes の Markdown を出力する。 - 安定版は前の安定版から(間の prerelease を畳み込む: `--ignore-tags '^v.*-'`)、prerelease は直前の tag から、最初の版は全履歴。git-cliff の `--context` から対象 tag の release だけを選んで `--from-context` で描画するので、HEAD が tag より先(main)でも同じ notes になる。 - tag がまだ無い場合は「最後の tag 〜 HEAD」をその版としてプレビューする。digest を省略すると placeholder。 - tag が HEAD の祖先でない、semver でない、digest の形式が違う、対象の commit が無い、などはエラー。 - `.github/workflows/engine-image.yml` - `publish` が `digest` を output する。 - `release` が checkout(`fetch-depth: 0`)→ git-cliff(`taiki-e/install-action` を SHA pin、`[email protected]`。install-action が checksum を検証)→ notes 生成(job summary にも出す)→ release の作成(`--notes-file`。版に `-` があれば prerelease にする既存の扱いを維持)。 - release が既にある場合(手で作った / 再実行)は、notes を生成したもので **上書き** してから asset を upload する。 - `.github/workflows/release-notes.yml`(新規): notes の生成だけを行う workflow。image の公開・release の作成はしない。 - `pull_request`(`cliff.toml`・script・この workflow の変更時): fixture の test の後、PR の head commit(merge ref ではなく。`Merge … into …` の行が入らない)で、最後の tag(現状 v0.1.0、全履歴)の notes と、次の版(patch + 1)としての「最後の tag 以降」の notes を job summary と artifact `release-notes` に出す。digest は GHCR から引く(未公開の版は placeholder)。 - `workflow_dispatch`(`tag`、`update`): `update=false`(既定)は dry run。`update=true` は `gh release edit --notes-file` で既存 release の notes を置き換える(main か tag 上の実行のみ。image が GHCR に無い版は失敗)。 - 権限: 生成する `notes` job は `contents: read`。書き込む `update` job だけが `contents: write` で、repository の code は実行しない(artifact を受け取って `gh release edit` するだけ)。 - docs - `docs/development.md`: release 手順を「tag を push するだけ」に更新し、「release notes」節(分類の規則、notes の文面は PR タイトルで決まること、ローカルでの生成方法、作り直し方)を追加。 - `CONTRIBUTING.md`: PR タイトルが release notes の 1 行になること、type / description の書き方の注意、notes の PR check を追記。 - `docs/security.md`(権限の記述)、`docs/engine-image.md`(digest は release notes に載る)を追随。 ## 設計判断 - **git-cliff を採用**(GitHub の自動生成 + `.github/release.yml` ではなく): この repo は PR にラベルを付けない運用で、GitHub の自動生成はラベルでしか分類できない。git-cliff は commit の type で分類でき、PR タイトル = commit タイトルの運用にそのまま合う。API を使わず(`--offline`)git の履歴だけで決まるので、PR 上やローカルでも同じ結果を再現できる。 - **既存 release の notes は上書き**: notes は git の履歴と公開済みの digest から決定的に作られるので、再実行で上書きしても結果は同じ。手で先に release を作った場合も、生成した notes に揃える(docs に明記。公開後の手修正は、作り直すと消える)。 - **CHANGELOG.md は置かない**: tag ごとに CHANGELOG 更新の commit / PR が必要になり、運用が増えるため。GitHub release を changelog とし、必要なら同じ `cliff.toml` から `git cliff` でいつでも全履歴を出せる。 - **notes の作り直しは別 workflow**: engine-image.yml の `workflow_dispatch` は image の公開と結び付いているので、notes だけの経路を分けた。image は再公開せず、digest は GHCR にある既存の版から引く。 - **notes の生成は image の公開後**: digest が要るため `release` job で生成する。設定の誤りは PR 上の `Release notes / notes` で先に検出する。万一 `release` で失敗しても image は公開済みで、`gh run rerun --failed` でやり直せる(既存の手順どおり)。 - **git-cliff の版**: `2.14.2` を両 workflow で固定(install-action の manifest の sha256 で検証)。install-action 自体は SHA pin で、Dependabot の対象。 ## 確認方法 - [x] `actionlint`(全 workflow)、`shellcheck .github/scripts/release-notes.sh` - [x] ローカルで git-cliff 2.14.2(公式 release の tar を sha512 で確認)を使って生成 - `release-notes.sh v0.1.0 sha256:b611…` → 下記(v0.1.0 までの全履歴、32 commit) - `release-notes.sh v0.1.1` → v0.1.0 以降の差分(この PR の commit のみ)のプレビュー - 使い捨ての clone で `v0.2.0-rc.1` / `v0.2.0-rc.2` / `v0.2.0` を打って確認: rc.2 は rc.1 からの差分、v0.2.0 は v0.1.0 からの全部(rc の分を畳み込む)。tag が HEAD の祖先でない場合・semver でない tag・不正な digest はエラーになる - `release-notes-test.sh`: 期待値どおり(下記)。修正前の `cliff.toml` に戻して実行すると、Dependabot の行が `3 dependency updates (Dependabot):,,` に、Breaking changes が日本語の footer + `🤖 Generated with …` に、Revert の行が本文付きに、`@octocat` が mention になり、test が失敗することを確認した - レビュー対応の後も v0.1.0 の notes は変わらない(前回の出力と diff なし) - [x] `CONTRIBUTING.md` / `docs/development.md`: タイトルだけが載ること、`@name` を書かないこと、`jq` が要ること、`update` は通常 `--ref main` で実行すること(v0.1.0 の tag の上には workflow が無い)、fixture の test を追記 - [x] PR 上の `Release notes / notes` が、v0.1.0 と v0.1.1(プレビュー)の notes を job summary と artifact に出す(GHCR から v0.1.0 の digest を引く) - `workflow_dispatch` の dry run は、新規 workflow が default branch に入るまで dispatch できないため、merge 後に `gh workflow run release-notes.yml --ref main -f tag=v0.1.0` で確認する(PR 上の `pull_request` の実行が同じ生成を行う) - tag の push・release の作成 / 編集・publish を有効にした実行はしていない - Rust のコードは変更していない(cargo の品質ゲートは CI で確認) ### 生成例: v0.1.0(digest は GHCR の実際の値) <details> <summary>v0.1.0 の notes(全文)</summary> ````markdown ## What's changed ### Features - **core**: Define compile domain model and engine interface ([#20](#20)) - **workspace**: Add isolated compile workspaces ([#21](#21)) - **diagnostics**: Parse LaTeX logs into structured diagnostics ([#23](#23)) - **texlive**: Add latexmk engine ([#30](#30)) - **preview**: Render PDF pages to PNG previews ([#31](#31)) - **cli**: Add compile command ([#34](#34)) - **workspace**: Exclude nested output directories by path ([#38](#38)) - **diagnostics**: Locate missing packages and fold fatal errors ([#40](#40)) - **diagnostics**: Report BibTeX failures ([#42](#42)) - **process**: Apply resource limits before exec through a gate ([#44](#44)) - **process**: Limit CPU, memory and process count ([#45](#45)) - **sandbox**: Add a container backend for the TeX engine ([#50](#50)) - **sandbox**: Render previews inside the container ([#52](#52)) - **sandbox**: Reclaim containers left by killed runs and report the process limit ([#53](#53)) - **sandbox**: Reclaim leftovers from a previous boot ([#58](#58)) ### Bug fixes - **workspace**: Refine exclusion and collection edge cases ([#29](#29)) - **texlive**: Restore the build after #39 and #40 ([#43](#43)) - **sandbox**: Accept engine images without labels ([#55](#55)) - **sandbox**: Support rootless Podman and refuse rootless Docker ([#57](#57)) - **sandbox**: Detect OOM kills reliably on Docker ([#61](#61)) ### Documentation - Add contribution guidelines and MIT license ([#15](#15)) - Add initial README ([#18](#18)) - **security**: Define the MVP security model and execution limits ([#22](#22)) - Update README to reflect the completed MVP ([#37](#37)) - Rewrite the README ([#59](#59)) ### Other changes - Initialize repository - Bootstrap Rust workspace and toolchain ([#16](#16)) - **ci**: Add quality gates and dependency checks ([#19](#19)) - **docker**: Add TeX Live development environment ([#17](#17)) - Add TeX Live integration fixtures and CI job ([#33](#33)) - **process**: Extract shared subprocess execution ([#39](#39)) - **ci**: Publish the engine image to GHCR ([#51](#51)) ## Install ```bash cargo install --locked --git https://github.com/nishide-dev/texrun --tag v0.1.0 texrun ``` See the [README](https://github.com/nishide-dev/texrun/blob/v0.1.0/README.md#installation) for the requirements and the tools each backend needs. ## Engine image The container backend (`--backend container`) runs TeX in the engine image of this version, `ghcr.io/nishide-dev/texrun-engine:0.1.0` (linux/amd64, linux/arm64). texrun never pulls it; pull it once: ```bash docker pull ghcr.io/nishide-dev/texrun-engine:0.1.0 ``` Published versions are never overwritten. To use exactly this image, pin its digest: ```bash docker pull ghcr.io/nishide-dev/texrun-engine@sha256:b611748f16d50c00982da2e52b51939d50167bebbc22b35ab8741d1c39e00d1b texrun compile --backend container --container-image ghcr.io/nishide-dev/texrun-engine@sha256:b611748f16d50c00982da2e52b51939d50167bebbc22b35ab8741d1c39e00d1b main.tex ``` The image has an SBOM, SLSA provenance and a signed GitHub artifact attestation: ```bash gh attestation verify oci://ghcr.io/nishide-dev/texrun-engine:0.1.0 -R nishide-dev/texrun ``` ## Source of the engine image `texrun-engine-0.1.0-sources.tar` (below) has the Debian source packages (`.dsc`, `.orig.tar.*`, `.debian.tar.*`) of every package in the image, for both platforms, at exactly the installed versions (`packages.txt` and `SHA256SUMS` inside): the corresponding source of its GPL / AGPL programs. See [docs/engine-image.md](https://github.com/nishide-dev/texrun/blob/v0.1.0/docs/engine-image.md#licenses). ```` </details> ### 生成例: v0.1.0 以降の main の差分(次の版のプレビュー) ````markdown ## What's changed ### Bug fixes - **ci**: Build release notes lines from commit titles only ### Other changes - **ci**: Generate release notes from conventional commits - **ci**: Write release notes on tag push and add a notes-only workflow **Full diff**: [v0.1.0...v0.1.1](v0.1.0...v0.1.1) ```` (以下の Install / Engine image / Source は v0.1.0 と同じ形で、digest は placeholder。squash merge 後は 1 commit になる) ### 生成例: fixture(`release-notes-test.expected.md`) ````markdown ## What's changed ### Breaking changes - **cli**: Rename --json flag to --format json ([#4](#4)) ### Features - **cli**: Rename --json flag to --format json ([#4](#4)) ### Bug fixes - **diagnostics**: Report the error `@octocat` found ([#7](#7)) ### Other changes - Revert "fix(core): handle empty logs ([#5](#5))" ([#6](#6)) ### Dependencies - 3 dependency updates: [#2](#2), [#3](#3) **Full diff**: [v0.1.0...v0.2.0](v0.1.0...v0.2.0) ```` ## 補足 - merge 後、v0.1.0 の notes を埋めるには: `gh workflow run release-notes.yml --ref main -f tag=v0.1.0`(dry run、summary で確認)の後に `gh workflow run release-notes.yml --ref main -f tag=v0.1.0 -f update=true`。 - notes の文面は PR タイトルで決まる。merge 後に誤りに気付いた場合は release を手で編集できるが、作り直すと消える。 - 推奨(任意): `release-notes.yml` の `update` job にも、engine-image.yml と同様に `environment` を付けることを検討できる(docs/security.md の「release の入口」)。 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
概要
TeX Live を使う integration test 用の fixture(#10)と、それを CI で実行する
integrationjob(#11 の残り)を追加します。fixture は workspace の作成から latexmk engine の compile までを通して実行し、構造化された結果で検証します。docs/security.md §2 の保証を確かめる security fixture も含みます。
TeX Live が必要な test の選び方は、#31 の
TEXRUN_REQUIRE_PREVIEW_TOOLSと同じ「実行時に検出し、環境変数で必須にする」方式にそろえました。変更内容
選別方式(
TEXRUN_REQUIRE_TEXLIVE)require_texlive!()で始める。latexmkが見つからなければ skip する。skip したことは、test binary ごとに 1 回、stderr にSKIPPED ... (set TEXRUN_REQUIRE_TEXLIVE=1 to fail instead)と出す。libtest の capture を通さないのでcargo testで見えるTEXRUN_REQUIRE_TEXLIVE=1のときは skip ではなく失敗にする。preview tool は既存のTEXRUN_REQUIRE_PREVIEW_TOOLS=1をそのまま使う(texlive 側の PDF ページ数と preview の確認もこれに従う)#[ignore](tests/latexmk.rsの全 test と、src/engine.rsの unit test 1 件)はこの方式に置き換えた。repo 内に TeX 用の#[ignore]は残っていない#[ignore]や cargo feature を採らなかった理由:--all-featuresを付けた fast job で TeX 必須になってしまうfixture(
crates/texrun-texlive/tests/fixtures/)texrun-workspace/texrun-previewを持つ)がここにあるためWorkspace::createに渡す。コピーして使うので、test が fixture の隣に書き込むことはないscenarios.rs)minimalSucceeded・exit 0・error 0 件、artifact は PDF と log だけ(size は実ファイルと一致、PDF は 1 ページ)、collect_artifactsで host にコピーされるsyntax-error\begin{itemize}を\end{enumerate}で閉じる:Failed、PDF なし、latex_error@main.tex:5undefined-commandFailed、undefined_control_sequence@main.tex:5missing-packageFailed、missing_file(file =main.tex。TeX は停止位置しか出さないので、line は検証しない)references.bblに解決した key がある。未定義の\ref/\citeは warning(@main.tex:5)で、outcome はSucceeded。kpsewhich 無効の stderr が diagnostic にならないoverfull-boxoverfull_boxwarning @main.tex:5timeout\def\x{\x}\xを timeout 2 秒で実行:TimedOut、SIGKILL、PDF なし、process group が残らないmulti-file\input/\include: workspace へのコピー、子ファイルの.auxが output dir にできる、3 ページ、未定義の参照はchapters/body.tex:4に帰属する。\inputした子ファイルの error はchapters/broken.tex:2に帰属する。preview 3 ページを生成し、attach_toとcollect_artifactsまで確認するunicode-names論文 下書き.tex(日本語 + 空白)と全角 空白.tex(U+3000)。artifact 名と、章/節1.tex:3への帰属security fixture(
fixtures/security/、security.rs)docs/security.md §2 の「保証する」項目を、workspace + engine の経路で検証する。
fixture は防御が効いていることを確かめる最小限の内容だけにし、コメントに手法の解説は書いていない。
読み書きの拒否を確かめる test では、workspace 内なら同じ仕組みで読み書きできることを対照として確認する。これで、fixture の誤りによって「拒否された」ように見えることを防ぐ。
\write18と pipe による\inputで marker file ができないlatexmkrc/.latexmkrcがToolConfigとして除外される。さらに、compile 前に workspace と HOME へ rc を置いても読まれない(読まれたら compile が失敗する内容)%&行の無効化Succeededlatexmkであることを確認する。空白を含むファイル名が 1 つの引数のまま渡ること、pdflatex に-no-shell-escape/-no-parse-first-lineが付くことも確認する。latexmk 既定の設定では親がshになることを事前に確かめ、この検査で違いを検出できることを確認した\input/\openin/\openoutを拒否..の両方。workspace の親ディレクトリを test 用に指定し(with_temp_parent)、そこに probe を置いて使う。書き込みは、その tree のどこにもファイルができないことで確認するSymlinkOutsideRootになる(TeX 不要なので常に実行)docs/security.md に、保証と test の対応表(「保証の検証」)を追加した。
kpathsea の paranoid mode を
aに戻すと outside-paths の probe が読み書きされることを、コンテナ内で pdflatex を直接実行して確かめた。CI(
integrationjob)docker/setup-buildx-action+docker/build-push-actionで dev image を build する(cache-from/to: type=gha、mode=max)TEXRUN_REQUIRE_TEXLIVE=1 TEXRUN_REQUIRE_PREVIEW_TOOLS=1 cargo test --workspace --all-features --lockedを実行する。TeX Live と preview tool のどちらが無くても失敗する。feat(preview): render PDF pages to PNG previews #31 の preview 実ツール test もここで実行されるtarget/dockerと cargo registry はactions/cacheの restore / save で持ち越す(save は main の push のときだけ)Tool versionsstep で、cargo / latexmk / pdfTeX / mutool / pdfinfo の version を表示するci-successのneedsにintegrationを加えた(所要時間は下記)。branch protection の必須 check 名(ci-success/pr-title)は変えていないrust:1.98.1-slim-trixie@sha256:4cd8…)。ARGを使ったFROMは Dependabot が解釈できないので、固定値にした/docker/dev)を追加した。digest の更新だけを受け取り、Rust の version(tag)はrust-toolchain.tomlと一緒に手で上げるので、semver の更新は ignore している文書
docs/development.md: 「TeX Live integration test」節を書き直した(環境変数の表、実行コマンド、test と fixture の構成)。base image の digest 固定の説明も追加したCONTRIBUTING.md: integration test の実行方法と、CI の check 表にintegrationを追加した確認方法
cargo check --workspace --all-targets --all-features --lockedcargo fmt --all -- --checkcargo clippy --workspace --all-targets --all-features --locked -- -D warningscargo test --workspace --locked(host の macOS、TeX Live なし): TeX の test はSKIPPEDを表示して pass するTEXRUN_REQUIRE_TEXLIVE=1を付けると、TeX の test が失敗することを確認したdocker compose run --rm -e TEXRUN_REQUIRE_TEXLIVE=1 -e TEXRUN_REQUIRE_PREVIEW_TOOLS=1 dev cargo test --workspace --all-features --locked: 全件 pass(texlive: unit 47、latexmk 10、scenarios 11、security 14。preview の real_tools 13 を含む)docker compose build dev(digest を固定した Dockerfile)actionlint関連 Issue
Closes #10
Closes #11
補足
texrun-previewのinspectで読む(dev-dependency を追加した)。preview の compile → render → collect の end-to-end はmulti_file_previewsで確認しているunusual-namesfixture と同じ挙動)。そのため、unicode-namesの子ファイル名には空白を含めていない。entrypoint には空白を含めているapps/texrun(Add thetexrun compileCLI command #6)と README には触れていない。CLI の end-to-end test は、Add thetexrun compileCLI command #6 で同じ fixture(crates/texrun-texlive/tests/fixtures)を参照して追加できる🤖 Generated with Claude Code