|
| 1 | +import { describe, it } from "node:test"; |
| 2 | +import assert from "node:assert/strict"; |
| 3 | +import { readFileSync } from "node:fs"; |
| 4 | +import { resolve } from "node:path"; |
| 5 | + |
| 6 | +const CI_WORKFLOW_PATH = resolve(import.meta.dirname, "..", ".github", "workflows", "ci.yml"); |
| 7 | +const RELEASE_WORKFLOW_PATH = resolve(import.meta.dirname, "..", ".github", "workflows", "build-release.yml"); |
| 8 | +const PACKAGE_JSON_PATH = resolve(import.meta.dirname, "..", "package.json"); |
| 9 | +const CONTRIBUTING_PATH = resolve(import.meta.dirname, "..", "CONTRIBUTING.md"); |
| 10 | + |
| 11 | +const ciWorkflow = readFileSync(CI_WORKFLOW_PATH, "utf-8"); |
| 12 | +const releaseWorkflow = readFileSync(RELEASE_WORKFLOW_PATH, "utf-8"); |
| 13 | +const packageJson = JSON.parse(readFileSync(PACKAGE_JSON_PATH, "utf-8")); |
| 14 | +const contributing = readFileSync(CONTRIBUTING_PATH, "utf-8"); |
| 15 | + |
| 16 | +describe("CI workflow consistency", () => { |
| 17 | + it("PR / main push 用の軽量 CI と release workflow が分離されていること", () => { |
| 18 | + assert.match(ciWorkflow, /pull_request:/); |
| 19 | + assert.match(ciWorkflow, /push:/); |
| 20 | + assert.match(ciWorkflow, /branches:\n\s+- main/); |
| 21 | + assert.doesNotMatch(ciWorkflow, /tagName:/); |
| 22 | + assert.doesNotMatch(ciWorkflow, /tauri-apps\/tauri-action/); |
| 23 | + assert.match(releaseWorkflow, /tags:\n\s+- "v\*"/); |
| 24 | + }); |
| 25 | + |
| 26 | + it("frontend と Rust の最低限の検証コマンドを CI で実行すること", () => { |
| 27 | + assert.match(ciWorkflow, /npm run lint/); |
| 28 | + assert.match(ciWorkflow, /npm run build/); |
| 29 | + assert.match(ciWorkflow, /npm test/); |
| 30 | + assert.match(ciWorkflow, /npm run test:consistency/); |
| 31 | + assert.match(ciWorkflow, /cargo check --manifest-path src-tauri\/Cargo\.toml/); |
| 32 | + assert.match(ciWorkflow, /cargo test --manifest-path src-tauri\/Cargo\.toml/); |
| 33 | + }); |
| 34 | + |
| 35 | + it("テスト用 npm scripts と CONTRIBUTING の案内が CI と一致していること", () => { |
| 36 | + assert.equal(packageJson.scripts.test, "vitest run"); |
| 37 | + assert.equal(packageJson.scripts["test:consistency"], "node --test tests/*.test.mjs"); |
| 38 | + assert.match(contributing, /\.github\/workflows\/ci\.yml/); |
| 39 | + assert.match(contributing, /npm run test:consistency/); |
| 40 | + assert.match(contributing, /cargo test --manifest-path src-tauri\/Cargo\.toml/); |
| 41 | + }); |
| 42 | +}); |
0 commit comments