-
Notifications
You must be signed in to change notification settings - Fork 96
ci: GitHub で回っていなかったユニットテストを回す #1909
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| # WEKO3 リポジトリ(RCOSDP/weko)の .github/workflows/ に配置する。 | ||
| # | ||
| # 台帳ツールの単体テスト。**Docker も実機も台帳も要らない**ので数秒で終わる。 | ||
| # api-inventory-drift.yml(実機を起こして突き合わせる。60分枠)とは役割が違う: | ||
| # | ||
| # このワークフロー … 台帳を作る側(スクリプト・手順書)が壊れていないか | ||
| # drift ワークフロー … 台帳の中身が実機とずれていないか | ||
| # | ||
| # ツールが壊れたまま drift だけ回すと、検知器が黙って死んでいても緑で通る。 | ||
| # 先にこちらを通すこと。Secret も不要なので fork からの PR でも動く。 | ||
|
|
||
| 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 | ||
|
sourcery-ai[bot] marked this conversation as resolved.
|
||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| unit: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 10 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.11' | ||
|
|
||
| - name: Install pytest | ||
| run: python3 -m pip install --disable-pip-version-check pytest | ||
|
|
||
| - name: Run unit tests | ||
| working-directory: tools/api-inventory | ||
| run: python3 -m pytest -q | ||
|
|
||
| # 台帳が無くても、ソースからの経路検知そのものは動く。 | ||
| # 検知件数が 0 に落ちていれば、検知器が壊れている。 | ||
| - name: Smoke check the static detector | ||
| run: | | ||
| set -o pipefail | ||
| python3 tools/api-inventory/scripts/detect_routes.py \ | ||
| --weko-root "$PWD" --summary-only | tee /tmp/detect.md | ||
| python3 - <<'PY' | ||
| import re, sys | ||
| text = open('/tmp/detect.md', encoding='utf-8').read() | ||
| total = int(re.search(r'\*\*計\*\* \| \*\*(\d+)\*\*', text).group(1)) | ||
| print(f'detections={total}') | ||
| # 経路が数百ある前提のリポジトリ。2桁に落ちたら検知器の故障を疑う。 | ||
| sys.exit(0 if total >= 300 else 1) | ||
| PY | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.pathsand an alias underpush.paths; GitHub Actions rejects YAML anchors/aliases in workflow syntax, so the workflow fails validation before any job starts.Suggested fix: Use a duplicated
pathslist, or use a GitHub Actions-supported reusable configuration mechanism instead of YAML anchors.