Skip to content

Commit 28a747f

Browse files
authored
Merge pull request #16 from T3pp31/codex/add-lightweight-ci-workflow-for-prs
PR/main向け軽量CIワークフローを追加
2 parents a3fd986 + 6160819 commit 28a747f

6 files changed

Lines changed: 140 additions & 4 deletions

File tree

.github/workflows/ci.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
push:
8+
branches:
9+
- main
10+
11+
permissions:
12+
contents: read
13+
14+
concurrency:
15+
group: ci-${{ github.ref }}
16+
cancel-in-progress: true
17+
18+
jobs:
19+
frontend-and-rust-check:
20+
runs-on: ubuntu-22.04
21+
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
25+
26+
- name: Install Rust stable
27+
uses: dtolnay/rust-toolchain@stable
28+
29+
- name: Rust cache
30+
uses: swatinem/rust-cache@v2
31+
with:
32+
workspaces: |
33+
./src-tauri -> target
34+
./tools/windows-bootstrapper -> target
35+
36+
- name: Setup Node.js
37+
uses: actions/setup-node@v4
38+
with:
39+
node-version: "lts/*"
40+
cache: "npm"
41+
42+
- name: Install Linux dependencies
43+
run: |
44+
sudo apt-get update
45+
sudo apt-get install -y \
46+
libwebkit2gtk-4.1-dev \
47+
libappindicator3-dev \
48+
librsvg2-dev \
49+
patchelf \
50+
libpcap-dev
51+
52+
- name: Install frontend dependencies
53+
run: npm ci
54+
55+
- name: Lint frontend
56+
run: npm run lint
57+
58+
- name: Build frontend
59+
run: npm run build
60+
61+
- name: Run frontend tests
62+
run: npm test
63+
64+
- name: Run repository consistency tests
65+
run: npm run test:consistency
66+
67+
- name: Rust check
68+
run: cargo check --manifest-path src-tauri/Cargo.toml
69+
70+
- name: Rust tests
71+
run: cargo test --manifest-path src-tauri/Cargo.toml

CONTRIBUTING.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,21 @@ npx tauri dev
5353

5454
## テスト
5555

56-
- `node --test tests/buildRsConsistency.test.mjs tests/readmeConsistency.test.mjs tests/releaseWorkflowConsistency.test.mjs tests/repoCleanupConsistency.test.mjs`
57-
- `cargo test --manifest-path tools/windows-bootstrapper/Cargo.toml`
56+
PR / `main` push では `.github/workflows/ci.yml` が軽量 CI として動作し、リリース成果物を作る `.github/workflows/build-release.yml` とは分離しています。
57+
58+
ローカルでも PR 前に最低限以下を確認してください。
59+
60+
```bash
61+
npm run lint
62+
npm run build
63+
npm test
64+
npm run test:consistency
65+
cargo check --manifest-path src-tauri/Cargo.toml
66+
cargo test --manifest-path src-tauri/Cargo.toml
67+
```
68+
69+
Windows bootstrapper を変更した場合は、追加で以下を実行してください。
70+
71+
```bash
72+
cargo test --manifest-path tools/windows-bootstrapper/Cargo.toml
73+
```

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,17 @@ Npcap SDK は以下のいずれかの方法で配置してください。
140140
| `npx tauri build` | リリースビルド |
141141
| `npm run build` | フロントエンドのみビルド |
142142
| `npm run lint` | ESLint によるコード検査 |
143-
| `npx vitest` | テスト実行 |
143+
| `npm test` | Vitest テスト実行 |
144+
| `npm run test:consistency` | `tests/*.test.mjs` の node:test 整合性チェック |
144145
| `npx vitest --coverage` | カバレッジ付きテスト実行 |
145146
| `node --test tests/buildRsConsistency.test.mjs` | `build.rs` の構造検証 |
146147
| `node --test tests/readmeConsistency.test.mjs` | README 整合性チェック |
147148
| `node --test tests/buildDelayLoadConsistency.test.mjs` | 遅延ロード設定の回帰チェック |
149+
| `node --test tests/ciWorkflowConsistency.test.mjs` | CI workflow / Contributor 文書の整合性チェック |
148150
| `node --test tests/releaseWorkflowConsistency.test.mjs` | Release / Contributor 文書の整合性チェック |
149151
| `node --test tests/repoCleanupConsistency.test.mjs` | 不要生成物・旧資産の再混入防止チェック |
152+
| `cargo check --manifest-path src-tauri/Cargo.toml` | Rust/Tauri バックエンドの型・依存関係チェック |
153+
| `cargo test --manifest-path src-tauri/Cargo.toml` | Rust/Tauri バックエンドの単体テスト |
150154
| `cargo test --manifest-path tools/windows-bootstrapper/Cargo.toml` | Windows bootstrapper の単体テスト |
151155

152156
## 設定

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
"tauri:dev": "tauri dev",
1010
"build": "tsc -b && vite build",
1111
"lint": "eslint .",
12-
"preview": "vite preview"
12+
"preview": "vite preview",
13+
"test": "vitest run",
14+
"test:consistency": "node --test tests/*.test.mjs"
1315
},
1416
"dependencies": {
1517
"@tauri-apps/api": "^2.10.1",
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
});

tests/readmeConsistency.test.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ describe("README consistency", () => {
3939
assert.match(readme, /node --test tests\/buildRsConsistency\.test\.mjs/);
4040
assert.match(readme, /node --test tests\/readmeConsistency\.test\.mjs/);
4141
assert.match(readme, /node --test tests\/buildDelayLoadConsistency\.test\.mjs/);
42+
assert.match(readme, /node --test tests\/ciWorkflowConsistency\.test\.mjs/);
4243
assert.match(readme, /node --test tests\/releaseWorkflowConsistency\.test\.mjs/);
4344
assert.match(readme, /node --test tests\/repoCleanupConsistency\.test\.mjs/);
4445
assert.match(readme, /cargo test --manifest-path tools\/windows-bootstrapper\/Cargo\.toml/);

0 commit comments

Comments
 (0)