Skip to content

ci: GitHub で回っていなかったユニットテストを回す - #1909

Closed
mhaya wants to merge 3 commits into
develop_v2.0.5from
ci/unit-tests-coverage
Closed

ci: GitHub で回っていなかったユニットテストを回す#1909
mhaya wants to merge 3 commits into
develop_v2.0.5from
ci/unit-tests-coverage

Conversation

@mhaya

@mhaya mhaya commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

GitHub 上で一度も実行されていないユニットテストが 390本 あった。いずれもテストコード側は健全で、CI の設定に載っていないだけだった。テストコードは変更していない。

1. unit-tests.yml のマトリクスから漏れていた3モジュール(283本)

modules/ には49ディレクトリあるが、マトリクスは44しか列挙していなかった。差分5つのうち resources / cookiecutter-weko-module はモジュールではないが、残る3つは tox.initests/ を持つ実モジュールで、単に列挙漏れだった。

モジュール 結果
weko-notifications 39 passed, 1 skipped
weko-signposting 5 passed
weko-workspace 239 passed

3モジュールとも CI と同じ経路scripts/ci/run-module-tests.sh 経由の tox)でローカル実行して確認済み。いずれも c1: commands succeededrequirements-weko-modules.txt には最初から入っているので、イメージ側の変更は不要。

コメントの「45個のマトリクス」も実数(47)に修正した。

2. api-inventory のツールテスト(107本)

api-inventory-tests.ymltools/api-inventory/ci/ に置いたまま .github/workflows/ に配置していなかったため、一度も動いていなかった。配置する。Docker も Secret も台帳も要らず数秒で終わる。

あわせて pushpull_request のパス指定を YAML アンカーで共有した。別々に書くと片方だけ古びて「PR では回るが push では回らない」という説明のつかない差になるため。ci/README.md の設置手順にも2本目を追記した(.github/workflows/ が実体、ci/ 配下が原本という関係を明記)。

確認の際に踏んだ落とし穴

ローカルで既存イメージを流用して回すと、イメージに焼き付いた古い egg-info の entry_pointweko_theme.bundles:js_preview_widget など。現行の setup.py には無い)を invenio_assets が読みにいって 191件が ImportError になる。CI は ci-images.yml がブランチからイメージを作り直すので発生しない。ローカルで再現するときは全モジュールに python setup.py egg_info を掛けてから回すこと。

レビュー時の確認点

  • unit-tests.yml のジョブが 44 → 47 に増え、追加3モジュールが緑になること
  • API Inventory Tests ワークフローが起動し、107本が緑になること

🤖 Generated with Claude Code

https://claude.ai/code/session_01UFWPMjL6mrvQ2NHBvNgviy

Summary by Sourcery

Ensure GitHub Actions executes all testable module and API inventory unit tests while preventing future CI coverage gaps.

New Features:

  • Run the previously omitted API inventory unit tests in GitHub Actions with a lightweight workflow and static-detector smoke check.

Bug Fixes:

  • Include weko-notifications, weko-signposting, and weko-workspace in the unit-test matrix so their 283 tests run in CI.
  • Prevent silent omissions between testable modules and the unit-test matrix with an automated coverage check.

Enhancements:

  • Provide local test commands that follow the same execution path as CI and add safeguards for stale images, port conflicts, and environment-related false failures.

CI:

  • Add the API Inventory Tests workflow and keep push and pull-request path filters synchronized.
  • Expand the unit-test matrix from 44 to 47 modules and validate matrix coverage automatically.

Documentation:

  • Document the CI-aligned local testing workflow, module matrix validation, API inventory workflow installation, and known local testing pitfalls.

Tests:

  • Enable automated execution of 390 previously unrun unit tests across three modules and the API inventory tool.

develop_v2.0.5 には、テスト一式を持ちながら GitHub 上で一度も実行されていない
テストが 390 本あった。いずれも**テストコード側は健全**で、CI の設定に載って
いないだけだった。

## 1. unit-tests.yml のマトリクスから漏れていた3モジュール (283本)

modules/ には49ディレクトリあるが、マトリクスは44しか列挙していなかった。
差分5つのうち resources / cookiecutter-weko-module はモジュールではないが、
残る3つは tox.ini と tests/ を持つ実モジュールで、単に列挙漏れだった。

  weko-notifications    39 passed, 1 skipped
  weko-signposting       5 passed
  weko-workspace       239 passed

3モジュールとも CI と同じ経路(scripts/ci/run-module-tests.sh 経由の tox)で
実行して確認済み。いずれも `c1: commands succeeded`。
requirements-weko-modules.txt には最初から入っているので、イメージ側の
変更は要らない。テストコードにも手を入れていない。

コメントの「45個のマトリクス」も実数(47)に直した。

## 2. api-inventory のツールテスト (107本)

api-inventory-tests.yml を tools/api-inventory/ci/ に置いたまま
.github/workflows/ に配置していなかったため、一度も動いていなかった。配置する。
Docker も Secret も台帳も要らず、数秒で終わる。

あわせて push と pull_request のパス指定を YAML アンカーで共有した。
別々に書くと片方だけ古びて「PR では回るが push では回らない」という
説明のつかない差になるため。ci/README.md の設置手順にも2本目を追記した
(.github/workflows/ が実体で ci/ 配下は原本、という関係を明記)。

## 確認の際に踏んだ落とし穴(記録)

ローカルで既存イメージを流用して回すと、イメージに焼き付いた古い egg-info の
entry_point (weko_theme.bundles:js_preview_widget など。現行の setup.py には無い)
を invenio_assets が読みにいって 191件が ImportError になる。CI は
ci-images.yml がブランチからイメージを作り直すので発生しない。ローカルで
再現するときは全モジュールに `python setup.py egg_info` を掛けてから回すこと。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UFWPMjL6mrvQ2NHBvNgviy
@sourcery-ai

sourcery-ai Bot commented Sep 2, 2026

Copy link
Copy Markdown

Reviewer's Guide

GitHub Actionsで未実行だった390本のユニットテストを有効化するため、unit-testsのマトリクスに3モジュールを追加し、api-inventoryの単体テストワークフローを配置する。後者ではpushとpull_requestの対象パスを共有し、pytestに加えて静的経路検知の最低件数チェックも実行する。

File-Level Changes

Change Details Files
CI のユニットテスト対象モジュールを追加し、漏れていた3モジュールを既存のマトリクス実行経路に組み込む。
  • マトリクスを44から47モジュールへ拡張
  • weko-notifications、weko-signposting、weko-workspaceを追加
  • マトリクス数およびキャッシュ関連コメントを実数に更新
.github/workflows/unit-tests.yml
api-inventory の単体テスト用GitHub Actionsワークフローを実際のワークフロー配置へ追加し、変更時に自動実行できるようにする。
  • Python 3.11環境でpytestを実行
  • 静的な経路検知結果が一定件数以上あることをスモークチェック
  • SecretやDockerを使わず、対象ディレクトリ変更時と手動実行時に動作する構成を追加
.github/workflows/api-inventory-tests.yml
api-inventory テストワークフローの原本と配置先でトリガー条件を同期しやすくする。
  • pushとpull_requestのパス指定をYAMLアンカーで共有
  • ワークフロー原本を.github/workflowsへコピーする手順をREADMEに追加
  • ci配下が原本で.github/workflowsが実体であることを明記
tools/api-inventory/ci/api-inventory-tests.yml
tools/api-inventory/ci/README.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 28dc2d44-b3bf-4150-982e-7849b4a5ae0c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path=".github/workflows/api-inventory-tests.yml" line_range="19-24" />
<code_context>
+# 「PR では回るが push では回らない」といった説明のつかない差になる)。
+on:
+  pull_request:
+    paths: &paths
+      - 'tools/api-inventory/**'
+      - '.github/workflows/api-inventory-tests.yml'
+  push:
+    branches: ['**']
+    paths: *paths
+  workflow_dispatch:
+
</code_context>
<issue_to_address>
**issue (bug_risk):** The workflow relies on a YAML anchor defined under `pull_request.paths` and an alias under `push.paths`; GitHub Actions rejects YAML anchors/aliases in workflow syntax, so the workflow fails validation before any job starts.

**Suggested fix:** Use a duplicated `paths` list, or use a GitHub Actions-supported reusable configuration mechanism instead of YAML anchors.

```suggestion
    paths:
      - 'tools/api-inventory/**'
      - '.github/workflows/api-inventory-tests.yml'
  push:
    branches: ['**']
    paths:
      - 'tools/api-inventory/**'
      - '.github/workflows/api-inventory-tests.yml'
```
</issue_to_address>

### Comment 2
<location path=".github/workflows/api-inventory-tests.yml" line_range="14-24" />
<code_context>
+
+name: API Inventory Tests
+
+# 対象は tools/api-inventory/ だけなので、そこを触ったときだけ回す。
+# push と pull_request でパスの並びを揃えること(片方だけ古びると、
+# 「PR では回るが push では回らない」といった説明のつかない差になる)。
+on:
+  pull_request:
+    paths: &paths
+      - 'tools/api-inventory/**'
+      - '.github/workflows/api-inventory-tests.yml'
+  push:
+    branches: ['**']
+    paths: *paths
+  workflow_dispatch:
+
</code_context>
<issue_to_address>
**issue (broader_impact):** Changes made only to the canonical workflow at `tools/api-inventory/ci/api-inventory-tests.yml` do not match the deployed workflow's path filters, so the newly added CI workflow does not run to validate those source changes. The documented requirement to keep the source and deployed copies synchronized is therefore not enforced by CI.

**Triggers:** When a contributor edits only `tools/api-inventory/ci/api-inventory-tests.yml`.

**Suggested fix:** Include `tools/api-inventory/ci/api-inventory-tests.yml` in the deployed workflow's path filters, or eliminate the copied-source arrangement by using the deployed workflow as the single source of truth.
</issue_to_address>

Sourcery assessment

Approval pending. 2 findings to address first.

Blocking findings: .github/workflows/api-inventory-tests.yml:24, .github/workflows/api-inventory-tests.yml:24


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +19 to +24
paths: &paths
- 'tools/api-inventory/**'
- '.github/workflows/api-inventory-tests.yml'
push:
branches: ['**']
paths: *paths

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): The workflow relies on a YAML anchor defined under pull_request.paths and an alias under push.paths; GitHub Actions rejects YAML anchors/aliases in workflow syntax, so the workflow fails validation before any job starts.

Suggested fix: Use a duplicated paths list, or use a GitHub Actions-supported reusable configuration mechanism instead of YAML anchors.

Suggested change
paths: &paths
- 'tools/api-inventory/**'
- '.github/workflows/api-inventory-tests.yml'
push:
branches: ['**']
paths: *paths
paths:
- 'tools/api-inventory/**'
- '.github/workflows/api-inventory-tests.yml'
push:
branches: ['**']
paths:
- 'tools/api-inventory/**'
- '.github/workflows/api-inventory-tests.yml'

Comment thread .github/workflows/api-inventory-tests.yml
@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Run omitted module and API inventory tests in GitHub Actions

⚙️ Configuration changes 🧪 Tests 📝 Documentation 🕐 20-40 Minutes

Grey Divider

AI Description

• Expands the module matrix to cover 283 previously omitted tests.
• Adds API inventory CI for 107 tests and route-detection smoke validation.
• Synchronizes workflow path filters and documents source-to-deployment workflow steps.
Diagram

graph TD
  A["GitHub events"] --> B["Unit Tests"] --> C["47-module matrix"] --> D["Module tox runner"]
  A --> E{"API paths changed"} --> F["API Inventory Tests"] --> G["107 pytest cases"]
  F --> H["Route smoke check"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Keep only the deployed workflow
  • ➕ Eliminates duplicate YAML and manual synchronization risk
  • ➕ Makes the executable GitHub workflow the single source of truth
  • ➖ Removes the portable workflow template from the API inventory tool
  • ➖ Weakens separation between reusable tooling and repository deployment
2. Add automated workflow parity validation
  • ➕ Preserves the reusable source copy while detecting drift
  • ➕ Prevents future partial updates despite documentation warnings
  • ➖ Adds another CI check or synchronization script
  • ➖ Requires defining whether exact or semantic equality is enforced

Recommendation: Retain both copies because the tool directory serves as a portable source while .github/workflows must contain the executable deployment. However, a lightweight byte-for-byte parity check would be safer than relying solely on documented manual synchronization.

Files changed (4) +73 / -6

Documentation (1) +4 / -1
README.mdDocument deployment of both inventory workflows +4/-1

Document deployment of both inventory workflows

• Updates setup instructions to copy both the inventory unit-test and drift workflows into '.github/workflows'. Clarifies the distinction between source copies and executable workflow files.

tools/api-inventory/ci/README.md

Other (3) +69 / -5
api-inventory-tests.ymlDeploy API inventory unit-test workflow +59/-0

Deploy API inventory unit-test workflow

• Adds a secret-free Python 3.11 workflow that runs the existing API inventory pytest suite and verifies static route detection finds at least 300 routes. Shared path filters keep push and pull-request behavior aligned.

.github/workflows/api-inventory-tests.yml

unit-tests.ymlExpand module test matrix from 44 to 47 modules +5/-2

Expand module test matrix from 44 to 47 modules

• Adds 'weko-notifications', 'weko-signposting', and 'weko-workspace' to the tox matrix, exposing 283 previously omitted tests to CI. Updates matrix-count comments to match the 47 jobs.

.github/workflows/unit-tests.yml

api-inventory-tests.ymlSynchronize API inventory trigger path filters +5/-3

Synchronize API inventory trigger path filters

• Uses a YAML anchor to share path filters between push and pull-request triggers, preventing behavioral drift between event types. Keeps the source workflow aligned with its deployed copy.

tools/api-inventory/ci/api-inventory-tests.yml

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can turn on the rule miner and Qodo learns your standards from review history

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

API インベントリ差分(件数のみ)

⚠️ プライベートリポジトリに対応ブランチが無いため、既定ブランチの台帳と比較しています。
ブランチ間の経路差がそのまま差分として出るので、以下の件数は当てになりません。
この PR のブランチと同名のブランチをプライベートリポジトリに作ってください。

明細は公開できないため件数のみ表示しています。該当箇所はプライベートリポジトリ側の台帳・レポートで確認してください。

ベースラインとの差分

API インベントリ差分レポート

  • 旧: e9c5b2b51 v2.0.3-69-ge9c5b2b51 (profile=default) endpoints=928 (外部ライブラリ由来 359)
  • 新: 62162190a v2.0.4-41-g62162190a (profile=default) endpoints=928 (外部ライブラリ由来 359)

判定: ✅ PASS (FAIL 0 / WARN 1)

サマリ

分類 件数
ADDED 0
REMOVED 0
RULE_CHANGED 0
METHODS_CHANGED 0
AUTH_CHANGED 0
IMPL_CHANGED 0
ATTRS_UNKNOWN_NEW 0
ModelView 追加 0
ModelView 削除 0
ModelView フラグ変化 1
config 変化 0
コメントアウト認証の増加 0
依存パッケージの版変化 40

[WARN] W6 依存パッケージの版が変化した — 40件

  • attrs — 22.2.0 -> 17.4.0
  • botocore — 1.12.209 -> 1.12.253
  • cffi — 1.15.1 -> 1.11.2
  • click — 8.0.4 -> 6.7
  • cryptography — 40.0.2 -> 2.1.4
  • pyld — 3.1.0 -> 3.3.0
  • pytest — 7.0.1 -> 4.2.0
  • Docker-Services-CLI — 0.8.0 -> (削除)
  • aws-xray-sdk — 0.95 -> (削除)
  • build — 0.9.0 -> (削除)
  • check-manifest — 0.48 -> (削除)
  • cookies — 2.2.1 -> (削除)
  • coverage — 4.5.4 -> (削除)
  • docker — 5.0.3 -> (削除)
  • ecdsa — 0.19.2 -> (削除)
  • execnet — 1.9.0 -> (削除)
  • iniconfig — 1.1.1 -> (削除)
  • isort — 5.10.1 -> (削除)
  • jsondiff — 1.1.1 -> (削除)
  • jsonpickle — 2.2.0 -> (削除)
  • mock — 3.0.5 -> (削除)
  • moto — 1.3.7 -> (削除)
  • pep517 — 0.13.1 -> (削除)
  • pep8 — 1.7.1 -> (削除)
  • pyaml — 23.5.8 -> (削除)
  • pycryptodome — 3.21.0 -> (削除)
  • pydocstyle — 6.3.0 -> (削除)
  • pytest-cache — 1.0 -> (削除)
  • pytest-cov — 2.10.1 -> (削除)
  • pytest-flask — 0.15.1 -> (削除)
  • pytest-invenio — 1.3.4 -> (削除)
  • pytest-mock — 3.6.1 -> (削除)
  • pytest-pep8 — 1.0.6 -> (削除)
  • python-jose — 2.0.2 -> (削除)
  • responses — 0.10.15 -> (削除)
  • selenium — 3.141.0 -> (削除)
  • tomli — 1.2.3 -> (削除)
  • websocket-client — 1.3.1 -> (削除)
  • weko-redis — 0.1.0.dev20170000 -> (削除)
  • wrapt — 1.16.0 -> (削除)

台帳との突き合わせ

スナップショット ↔ インベントリ 突き合わせ

  • リビジョン: 62162190a v2.0.4-41-g62162190a 経路URI=908
  • 台帳: 行=1048 URI=919

件数のみ。詳細はプライベートリポジトリ側の完全版レポートを参照。

判定: ✅ 一致 (0件)

検出 件数
A. インベントリ未収載(抽出漏れ) 0
B. 実機に無い(未説明) 0
B'. 実機に無い(既知・許容) 11
C. メソッド不一致 0
D. app列の不一致 0
E. endpoint 未収載 0
E'. endpoint が実機に無い(参考) 1

ローカルと CI で違う回し方をすると、どちらかでしか出ない失敗が生まれ、結果を
突き合わせられなくなる。実際、直前の作業で**テストは正常なのに落ちる**事象を
2件踏んだ。

  - 手元にあった無関係な weko-web イメージを流用したところ、イメージに焼き付いた
    古い egg-info の entry_point (weko_theme.bundles:js_preview_widget。現行の
    setup.py には無い) を invenio_assets が読みにいって 191件が ImportError。
    CI は ci-images.yml が modules/*/setup.py を含むハッシュでタグを決めるので
    起きない。
  - invenio の venv で直接 pytest を叩いたところ pytest-mock / mock が無く
    「fixture 'mocker' not found」。CI は tox が requirements2.txt から入れる。

どちらも原因の切り分けに時間を取られただけで、実装にもテストにも問題は無かった。

README-TEST.md が案内していたのも CI とは別経路(Python 3.5 + venv + run-tests.sh)
で、Python も依存も tox の有無も違う。ここで通っても CI で通る保証がない。

## scripts/ci/run-local.sh

CI の Unit Tests ジョブと**同じ部品をそのまま呼ぶ**。分岐させないことが要点。

  compose          docker-compose2.yml:docker-compose.ci.yml   (CI と同一)
  起動サービス      postgresql / elasticsearch / redis / rabbitmq のみ (同一)
  起動待ち          scripts/ci/wait-for-services.sh            (同一)
  テスト実行        scripts/ci/run-module-tests.sh (= tox)      (同一)
  モジュール一覧    .github/workflows/unit-tests.yml の matrix  (同一)

イメージは CI と同じ入力ファイル集合(modules/*/setup.py を含む)のハッシュで
タグ付けし、無ければビルドする。GHCR から引けない代わりに、setup.py が変われば
必ず作り直されるので、古い egg-info を使い回す事故が起きない。
CI と完全に同一のイメージで確かめたいときは WEKO_IMAGE で明示する。

起動前後に2つの事前確認を入れた。どちらも今回実際に踏んだもの:
  - 別の WEKO スタックが 29201/26301/24301 を掴んでいないか
  - invenio_assets.bundles の entry_point が壊れていないか(= egg-info が古い)

## scripts/ci/matrix.sh

モジュール一覧が「ワークフローの中」と「手順書」に二重に書かれると必ず片方が
古びる。マトリクスを唯一の正として読み、食い違いを検出する。

  tests/ と tox.ini があるのにマトリクスに無い → 失敗
    ジョブが立たない = 赤くもならない静かな漏れ。v2.0.5 まで3モジュール283本が
    この状態だった。unit-tests.yml に matrix-check ジョブとして組み込む。
  マトリクスにあるが tests/ か tox.ini が無い → 警告
    ジョブは立って赤くなるので見えている。消すか足すかは人の判断。
    現状 weko-redis が該当(tox.ini の c1 が `--cov=weko_rediss tests` を指すが
    tests/ が無く、CI でも常に失敗している)。

## 残る差: ホストのアーキテクチャ

CI は x86_64。ARM では ES 6.8 の seccomp が x86_64 専用のため bootstrap check に
失敗する。ホストが x86_64 でないときだけ scripts/ci/compose.arm64.yml を重ねて
discovery.type=single-node にし、その旨を表示する。テストの内容には影響しない。
Dockerfile.arm64 は nodesource の setup_4.x が消えており現在ビルドできないので
使わない(標準の Dockerfile は aarch64 でもビルドできる)。

aarch64 のこのホストで scripts/ci/run-local.sh weko-signposting を通しで実行し、
イメージのビルドから 5 passed / congratulations まで確認済み。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UFWPMjL6mrvQ2NHBvNgviy
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

🔍 Claude レビュー統合

他レビューの指摘 2 件 → ✅ 妥当 0 / ❌ 誤検知 1 / 🔎 要文脈 0 / ☑️ 対応済み 1

Claude の追加指摘 2 件 — 🔴 高 2 / 🟠 中 0 / 🟡 低 0

# 出所 箇所 指摘 判定 修正案
1 sourcery-ai .github/workflows/api-inventory-tests.yml:19 Canonical workflow copy under tools/api-inventory/ci/ not covered by deployed workflow's path filters ☑️ 対応済み
2 sourcery-ai .github/workflows/api-inventory-tests.yml:19 YAML anchor/alias in paths: rejected by GitHub Actions ❌ 誤検知
3 Claude scripts/ci/run-local.sh:92 run-local.sh が COMPOSE_PROJECT_NAME を設定せず、通常の開発スタック(install.sh)と同じ名前付きボリュームを共有し、終了時の既定の docker compose down -v で消しうる 🔴 追加指摘(高) あり
4 Claude scripts/ci/run-local.sh:92 run-local.sh の既定の後片付けが、同じチェックアウトで動く通常の開発スタックの永続データを削除しうる 🔴 追加指摘(高) あり

1. ☑️ 対応済み Canonical workflow copy under tools/api-inventory/ci/ not covered by deployed workflow's path filters

.github/workflows/api-inventory-tests.yml:19 / 出所 sourcery-ai

解決済みとマークされているが、実際にコードを読んで確認した。デプロイ済みワークフローの pull_request.paths に 'tools/api-inventory/**' が含まれ、これは tools/api-inventory/ci/api-inventory-tests.yml にもマッチするグロブなので、原本のみを編集した場合もワークフローが起動する。両ファイルは diff コマンドでバイト単位の同一を確認した。

根拠

確認: .github/workflows/api-inventory-tests.yml:17-21 と tools/api-inventory/ci/api-inventory-tests.yml を diff で比較し IDENTICAL を確認


2. ❌ 誤検知 YAML anchor/alias in paths: rejected by GitHub Actions

.github/workflows/api-inventory-tests.yml:19 / 出所 sourcery-ai

GitHub Actions added support for YAML anchors/aliases in workflow files on 2025-09-18 (this PR is dated 2026-09-02, well after). The pattern used here — paths: &paths under one trigger and paths: *paths under another, with no merge keys (&lt;&lt;:) — is exactly the supported use case; only merge keys remain unsupported.

根拠

確認: .github/workflows/api-inventory-tests.yml:17-24 を確認。merge key は使われていない。加えて WebSearch で GitHub 公式アナウンス(2025-09-18)を確認済み


3. 🔴 [高] run-local.sh が COMPOSE_PROJECT_NAME を設定せず、通常の開発スタック(install.sh)と同じ名前付きボリュームを共有し、終了時の既定の docker compose down -v で消しうる(Claude の追加指摘)

scripts/ci/run-local.sh:92 (1/2 パス)

docker compose のプロジェクト名は COMPOSE_FILE の内容に関わらずカレントディレクトリ名から既定で決まる。install.sh も run-local.sh も COMPOSE_PROJECT_NAME を設定していないことを確認した。docker-compose.yml / docker-compose2.yml はどちらも同じ名前付きボリューム pgsql-data・es-data を宣言している。同じチェックアウトで install.sh により通常の開発スタックを起動した状態のまま run-local.sh を実行すると、両者は同じ docker compose プロジェクトとして扱われ、run-local.sh 終了時の既定動作(--keep を付けない場合)である docker compose down -v が、開発者が普段使っているDB/Elasticsearchの永続データを削除してしまう。

修正案 scripts/ci/run-local.sh:92-92

export COMPOSE_FILE=docker-compose2.yml:docker-compose.ci.yml
export COMPOSE_PROJECT_NAME=weko-ci-local

同じディレクトリで動く通常の開発スタック(install.sh 起動分)と docker compose のプロジェクト名前空間を分離し、既定の docker compose down -v が誤って開発者のDB/ES永続データを消さないようにする。

根拠
scripts/ci/run-local.sh:92 export COMPOSE_FILE=docker-compose2.yml:docker-compose.ci.yml (COMPOSE_PROJECT_NAME の設定なし) / scripts/ci/run-local.sh:170 docker compose down -v (既定動作) / docker-compose2.yml:307,350,453-454 で pgsql-data・es-data を宣言 / install.sh:9-11 も COMPOSE_PROJECT_NAME を設定していない

確認: scripts/ci/run-local.sh 全体を読んで COMPOSE_PROJECT_NAME が一度も設定されないことを確認。docker-compose.yml と docker-compose2.yml を grep し pgsql-data / es-data が両方に存在することを確認。install.sh を読み、同様に COMPOSE_PROJECT_NAME 未設定であることを確認


4. 🔴 [高] run-local.sh の既定の後片付けが、同じチェックアウトで動く通常の開発スタックの永続データを削除しうる(Claude の追加指摘)

scripts/ci/run-local.sh:92 (1/2 パス)

docker compose のプロジェクト名は COMPOSE_FILE の指定に関わらずディレクトリ名から既定で決まる。docker-compose.yml と docker-compose2.yml はどちらも同名の named volume pgsql-data / es-data を宣言しており、run-local.sh は COMPOSE_PROJECT_NAME を設定しない。install.sh で通常の開発スタックを同じチェックアウトで起動したまま run-local.sh を実行すると、同じプロジェクト名の下で動作し、--keep を付けない既定動作では終了時に docker compose down -v が走るため、開発者が使っている DB / Elasticsearch の永続データが削除される。

修正案 scripts/ci/run-local.sh:92-92

export COMPOSE_FILE=docker-compose2.yml:docker-compose.ci.yml
export COMPOSE_PROJECT_NAME=weko-ci-local

同じディレクトリで動く通常の開発スタック(install.sh 起動分)と Compose のプロジェクト名を分離し、既定の docker compose down -v が他方の named volume を巻き込んで削除しないようにする。

根拠
export COMPOSE_FILE=docker-compose2.yml:docker-compose.ci.yml (COMPOSE_PROJECT_NAME 未設定) / cleanup() { ... docker compose down -v ... } / docker-compose.yml と docker-compose2.yml がともに volumes: pgsql-data / es-data を宣言

確認: scripts/ci/run-local.sh 全体(COMPOSE_PROJECT_NAME が一度も設定されないことを grep で確認)、docker-compose.yml:307,350,447,453-454 と docker-compose2.yml:307,350,447,453-454 で同名 volume を確認


次にすること: 外部レビューの2件はいずれも実害なし(YAML アンカーは2025年9月にGitHub Actionsが対応済みで merge key も使っていない、原本/実体のパスフィルタ差異も現状のパス設定で既にカバーされておりファイルもバイト同一)。前回指摘した scripts/ci/run-local.sh の高リスク項目(COMPOSE_PROJECT_NAME 未設定により通常の開発スタックの永続ボリュームを誤って削除しうる)は本 PR でも未修正のままなので、COMPOSE_PROJECT_NAME を明示して名前空間を分離することを推奨する。


モデル sonnet / 2 回実行して和集合 / コスト $1.0143。同じ入力でも結果が揺れるため複数回まわし、一部のパスでしか挙がらなかったものには回数を添えています

他レビューを踏まえた自動レビューです。誤りが含まれることがあります。

前のコミットは aarch64 のときだけ Elasticsearch の設定を変えていた。これだと
開発機が AMD か ARM かで手元の条件が変わり、「片方の CPU でしか再現しない失敗」を
自分で作ることになる。ローカルと CI を揃えるという目的に反する。

分岐をやめ、scripts/ci/compose.local.yml を**常に**重ねる形にした
(compose.arm64.yml から改名)。調整点は install.sh と同じく COMPOSE_FILE ひとつ。

ES 6.8 は非ループバックアドレスに bind した時点で bootstrap check を強制するが、
これはホストのカーネルと sysctl に依存するので、開発機では環境しだいで落ちる。
確認できたものだけでも:

  - ARM: seccomp の実装が x86_64 専用で
    「seccomp unavailable: CONFIG_SECCOMP not compiled into kernel」で失敗する
  - vm.max_map_count が 262144 未満のホスト: max_map_count の検査で失敗する

後者は AMD でも起こる。アーキで分岐しても解決しない類の問題なので、
discovery.type=single-node で bootstrap check ごと省く。ES はテストが使う単一
ノードなので意味は変わらない(リポジトリの docker-compose.arm64.yml と同じ扱い)。
CI はこのオーバレイを読まないため、CI 側は素の設定のまま。

Dockerfile は両アーキとも CI と同じものを使う(標準の Dockerfile /
elasticsearch/Dockerfile は aarch64 でもビルドできる)。

aarch64 の実機で scripts/ci/run-local.sh weko-signposting を通しで実行し、
5 passed / congratulations / exit=0 を確認。x86_64 の実機は手元に無いため未検証。

## AGENTS.md

- テスト節が `python manage.py test` (Django のコマンド) を案内していた。
  本プロジェクトは Flask/Invenio なので、run-local.sh / matrix.sh /
  api-inventory のテストに書き換えた。
- 同じくセキュリティ節の「Django のバリデーション機構」を実態
  (Flask-WTF / marshmallow / JSON Schema) に直した。
- ベースラインに既存の失敗が残っている旨を明記した。「赤い = 自分のせい」と
  取り違えると、無い原因を探すことになるため。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UFWPMjL6mrvQ2NHBvNgviy
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown

API インベントリ差分(件数のみ)

⚠️ プライベートリポジトリに対応ブランチが無いため、既定ブランチの台帳と比較しています。
ブランチ間の経路差がそのまま差分として出るので、以下の件数は当てになりません。
この PR のブランチと同名のブランチをプライベートリポジトリに作ってください。

明細は公開できないため件数のみ表示しています。該当箇所はプライベートリポジトリ側の台帳・レポートで確認してください。

ベースラインとの差分

API インベントリ差分レポート

  • 旧: e9c5b2b51 v2.0.3-69-ge9c5b2b51 (profile=default) endpoints=928 (外部ライブラリ由来 359)
  • 新: dda0d5723 v2.0.4-42-gdda0d5723 (profile=default) endpoints=928 (外部ライブラリ由来 359)

判定: ✅ PASS (FAIL 0 / WARN 1)

サマリ

分類 件数
ADDED 0
REMOVED 0
RULE_CHANGED 0
METHODS_CHANGED 0
AUTH_CHANGED 0
IMPL_CHANGED 0
ATTRS_UNKNOWN_NEW 0
ModelView 追加 0
ModelView 削除 0
ModelView フラグ変化 1
config 変化 0
コメントアウト認証の増加 0
依存パッケージの版変化 40

[WARN] W6 依存パッケージの版が変化した — 40件

  • attrs — 22.2.0 -> 17.4.0
  • botocore — 1.12.209 -> 1.12.253
  • cffi — 1.15.1 -> 1.11.2
  • click — 8.0.4 -> 6.7
  • cryptography — 40.0.2 -> 2.1.4
  • pyld — 3.1.0 -> 3.3.0
  • pytest — 7.0.1 -> 4.2.0
  • Docker-Services-CLI — 0.8.0 -> (削除)
  • aws-xray-sdk — 0.95 -> (削除)
  • build — 0.9.0 -> (削除)
  • check-manifest — 0.48 -> (削除)
  • cookies — 2.2.1 -> (削除)
  • coverage — 4.5.4 -> (削除)
  • docker — 5.0.3 -> (削除)
  • ecdsa — 0.19.2 -> (削除)
  • execnet — 1.9.0 -> (削除)
  • iniconfig — 1.1.1 -> (削除)
  • isort — 5.10.1 -> (削除)
  • jsondiff — 1.1.1 -> (削除)
  • jsonpickle — 2.2.0 -> (削除)
  • mock — 3.0.5 -> (削除)
  • moto — 1.3.7 -> (削除)
  • pep517 — 0.13.1 -> (削除)
  • pep8 — 1.7.1 -> (削除)
  • pyaml — 23.5.8 -> (削除)
  • pycryptodome — 3.21.0 -> (削除)
  • pydocstyle — 6.3.0 -> (削除)
  • pytest-cache — 1.0 -> (削除)
  • pytest-cov — 2.10.1 -> (削除)
  • pytest-flask — 0.15.1 -> (削除)
  • pytest-invenio — 1.3.4 -> (削除)
  • pytest-mock — 3.6.1 -> (削除)
  • pytest-pep8 — 1.0.6 -> (削除)
  • python-jose — 2.0.2 -> (削除)
  • responses — 0.10.15 -> (削除)
  • selenium — 3.141.0 -> (削除)
  • tomli — 1.2.3 -> (削除)
  • websocket-client — 1.3.1 -> (削除)
  • weko-redis — 0.1.0.dev20170000 -> (削除)
  • wrapt — 1.16.0 -> (削除)

台帳との突き合わせ

スナップショット ↔ インベントリ 突き合わせ

  • リビジョン: dda0d5723 v2.0.4-42-gdda0d5723 経路URI=908
  • 台帳: 行=1048 URI=919

件数のみ。詳細はプライベートリポジトリ側の完全版レポートを参照。

判定: ✅ 一致 (0件)

検出 件数
A. インベントリ未収載(抽出漏れ) 0
B. 実機に無い(未説明) 0
B'. 実機に無い(既知・許容) 11
C. メソッド不一致 0
D. app列の不一致 0
E. endpoint 未収載 0
E'. endpoint が実機に無い(参考) 1

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown

API インベントリ差分(件数のみ)

⚠️ プライベートリポジトリに対応ブランチが無いため、既定ブランチの台帳と比較しています。
ブランチ間の経路差がそのまま差分として出るので、以下の件数は当てになりません。
この PR のブランチと同名のブランチをプライベートリポジトリに作ってください。

明細は公開できないため件数のみ表示しています。該当箇所はプライベートリポジトリ側の台帳・レポートで確認してください。

ベースラインとの差分

API インベントリ差分レポート

  • 旧: e9c5b2b51 v2.0.3-69-ge9c5b2b51 (profile=default) endpoints=928 (外部ライブラリ由来 359)
  • 新: 55cf6050e v2.0.4-43-g55cf6050e (profile=default) endpoints=928 (外部ライブラリ由来 359)

判定: ✅ PASS (FAIL 0 / WARN 1)

サマリ

分類 件数
ADDED 0
REMOVED 0
RULE_CHANGED 0
METHODS_CHANGED 0
AUTH_CHANGED 0
IMPL_CHANGED 0
ATTRS_UNKNOWN_NEW 0
ModelView 追加 0
ModelView 削除 0
ModelView フラグ変化 1
config 変化 0
コメントアウト認証の増加 0
依存パッケージの版変化 40

[WARN] W6 依存パッケージの版が変化した — 40件

  • attrs — 22.2.0 -> 17.4.0
  • botocore — 1.12.209 -> 1.12.253
  • cffi — 1.15.1 -> 1.11.2
  • click — 8.0.4 -> 6.7
  • cryptography — 40.0.2 -> 2.1.4
  • pyld — 3.1.0 -> 3.3.0
  • pytest — 7.0.1 -> 4.2.0
  • Docker-Services-CLI — 0.8.0 -> (削除)
  • aws-xray-sdk — 0.95 -> (削除)
  • build — 0.9.0 -> (削除)
  • check-manifest — 0.48 -> (削除)
  • cookies — 2.2.1 -> (削除)
  • coverage — 4.5.4 -> (削除)
  • docker — 5.0.3 -> (削除)
  • ecdsa — 0.19.2 -> (削除)
  • execnet — 1.9.0 -> (削除)
  • iniconfig — 1.1.1 -> (削除)
  • isort — 5.10.1 -> (削除)
  • jsondiff — 1.1.1 -> (削除)
  • jsonpickle — 2.2.0 -> (削除)
  • mock — 3.0.5 -> (削除)
  • moto — 1.3.7 -> (削除)
  • pep517 — 0.13.1 -> (削除)
  • pep8 — 1.7.1 -> (削除)
  • pyaml — 23.5.8 -> (削除)
  • pycryptodome — 3.21.0 -> (削除)
  • pydocstyle — 6.3.0 -> (削除)
  • pytest-cache — 1.0 -> (削除)
  • pytest-cov — 2.10.1 -> (削除)
  • pytest-flask — 0.15.1 -> (削除)
  • pytest-invenio — 1.3.4 -> (削除)
  • pytest-mock — 3.6.1 -> (削除)
  • pytest-pep8 — 1.0.6 -> (削除)
  • python-jose — 2.0.2 -> (削除)
  • responses — 0.10.15 -> (削除)
  • selenium — 3.141.0 -> (削除)
  • tomli — 1.2.3 -> (削除)
  • websocket-client — 1.3.1 -> (削除)
  • weko-redis — 0.1.0.dev20170000 -> (削除)
  • wrapt — 1.16.0 -> (削除)

台帳との突き合わせ

スナップショット ↔ インベントリ 突き合わせ

  • リビジョン: 55cf6050e v2.0.4-43-g55cf6050e 経路URI=908
  • 台帳: 行=1048 URI=919

件数のみ。詳細はプライベートリポジトリ側の完全版レポートを参照。

判定: ✅ 一致 (0件)

検出 件数
A. インベントリ未収載(抽出漏れ) 0
B. 実機に無い(未説明) 0
B'. 実機に無い(既知・許容) 11
C. メソッド不一致 0
D. app列の不一致 0
E. endpoint 未収載 0
E'. endpoint が実機に無い(参考) 1

@mhaya mhaya closed this Sep 3, 2026
@mhaya
mhaya deleted the ci/unit-tests-coverage branch September 3, 2026 00:31
@mhaya

mhaya commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

ブランチを ci/unit-tests-coveragefix/unittest202609 に改名したところ、head ref が失われてこの PR が自動クローズされました。内容は #1910 に引き継いでいます(コミットは同一: 9e32ff8 / 06a072d / 7ecb552)。

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