This repository was archived by the owner on Aug 2, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
chore: pre-commit 配布の廃止・oss profile 削除・cron を sca 限定化(RFS-002) #22
Merged
Merged
Changes from all commits
Commits
Show all changes
2 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
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
This file was deleted.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| #!/usr/bin/env node | ||
| // renovate.json の customManagers 正規表現が実ファイルにマッチし続けているかを検証する。 | ||
| // テンプレートのリファクタ等で正規表現が切れると Renovate はエラーを出さずに | ||
| // そのピンの追従を止めるため、実測がこの期待値と一致しなくなったら fail させて検知する。 | ||
| // 判定はファイル単位の完全一致(合計値だと、あるファイルの regex 切れが別ファイルの | ||
| // ピン追加で相殺されて素通りするため)。ピンを増減・移動させたら EXPECTED を更新すること。 | ||
| import { readFileSync } from "node:fs"; | ||
| import { execSync } from "node:child_process"; | ||
| import path from "node:path"; | ||
|
|
||
| const root = path.resolve(import.meta.dirname, ".."); | ||
|
|
||
| const EXPECTED = { | ||
| "profiles/*/contributes.json の mise 初期値(node)を追従": { | ||
| "profiles/typescript/contributes.json": 1, | ||
| }, | ||
| "profiles/*/contributes.json の mise 初期値(terraform)を追従": { | ||
| "profiles/terraform/contributes.json": 1, | ||
| }, | ||
| "templates/*.liquid 内の GitHub Actions digest ピン(uses: owner/repo@sha # vX.Y.Z)を追従": { | ||
| "templates/security-jvm-workflow.liquid": 5, | ||
| "templates/security-rust-workflow.liquid": 2, | ||
| "templates/security-workflow.liquid": 7, | ||
| }, | ||
| "templates/*.liquid 内の gitleaks docker タグを追従": { | ||
| "templates/security-workflow.liquid": 1, | ||
| }, | ||
| "templates/*.liquid 内の conftest docker タグを追従": { | ||
| "templates/security-workflow.liquid": 1, | ||
| }, | ||
| "templates/*.liquid 内の zizmor バージョンを追従": { | ||
| "templates/security-workflow.liquid": 1, | ||
| }, | ||
| "templates/*.liquid 内の anti-trojan-source バージョンを追従": { | ||
| "templates/security-workflow.liquid": 6, | ||
| }, | ||
| }; | ||
|
|
||
| const config = JSON.parse(readFileSync(path.join(root, "renovate.json"), "utf8")); | ||
| const files = execSync("git ls-files", { cwd: root, encoding: "utf8" }) | ||
| .split("\n") | ||
| .filter(Boolean); | ||
|
|
||
| const toRegExp = (pattern) => new RegExp(pattern.replace(/^\/|\/$/g, "")); | ||
|
|
||
| let errCount = 0; | ||
| const ng = (msg) => { | ||
| console.error(`NG: ${msg}`); | ||
| errCount++; | ||
| }; | ||
|
|
||
| for (const manager of config.customManagers) { | ||
| const desc = manager.description; | ||
| const expected = EXPECTED[desc]; | ||
| if (expected === undefined) { | ||
| ng(`EXPECTED に未登録の customManager: ${desc}`); | ||
| continue; | ||
| } | ||
| const errsBefore = errCount; | ||
| const fileRes = manager.managerFilePatterns.map(toRegExp); | ||
| const actual = {}; | ||
| for (const f of files.filter((f) => fileRes.some((re) => re.test(f)))) { | ||
| const content = readFileSync(path.join(root, f), "utf8"); | ||
| let count = 0; | ||
| for (const ms of manager.matchStrings) { | ||
| count += [...content.matchAll(new RegExp(ms, "g"))].length; | ||
| } | ||
| if (count > 0) actual[f] = count; | ||
| } | ||
| for (const [f, n] of Object.entries(expected)) { | ||
| if (!(f in actual)) ng(`${desc}: ${f} でマッチ 0(期待 ${n}。regex 切れかファイル移動の疑い)`); | ||
| else if (actual[f] !== n) ng(`${desc}: ${f} でマッチ ${actual[f]} ≠ 期待 ${n}(ピン増減なら EXPECTED を更新)`); | ||
| } | ||
| for (const [f, n] of Object.entries(actual)) { | ||
| if (!(f in expected)) ng(`${desc}: EXPECTED に無い ${f} で ${n} 件マッチ(ピン追加なら EXPECTED に登録)`); | ||
| } | ||
| if (errCount === errsBefore) console.log(`ok: ${desc}: ${Object.values(actual).reduce((a, b) => a + b, 0)} 箇所`); | ||
| } | ||
|
|
||
| for (const desc of Object.keys(EXPECTED)) { | ||
| if (!config.customManagers.some((m) => m.description === desc)) { | ||
| ng(`EXPECTED にあるが renovate.json に存在しない: ${desc}`); | ||
| } | ||
| } | ||
|
|
||
| process.exit(errCount > 0 ? 1 : 0); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.