-
Notifications
You must be signed in to change notification settings - Fork 87
zenn-cliのWindows互換性を向上し、E2Eテストワークフローを追加 #594
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
Conversation
Windowsでzenn-cliが最低限動作することを確認するためのE2E workflowを追加しました。 ## 仕様の変更 - Windows環境でzenn-cliのinitコマンドが正常に動作することを確認する新しいワークフローを追加 ## コードの変更 - `.github/workflows/e2e.yml` を新規作成 - buildジョブ: ubuntu-latestでビルドし、zenn-cliのdistディレクトリをキャッシュに保存 - e2eジョブ: windows-latestでキャッシュからdistを復元し、initコマンドを実行してエラーが出ないことを確認 ## その他・備考 - Windowsでのビルドは問題があるため、ubuntu-latestでビルドしたものをキャッシュ経由で共有する方式を採用 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
LinuxとWindows間でキャッシュを共有するために enableCrossOsArchive を有効化しました。 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
openパッケージをバンドルから除外し、外部依存として扱うことでクロスプラットフォーム対応を改善しました。 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
openパッケージを外部依存として扱うため、実行時に必要なdependenciesに移動しました。 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
openパッケージの依存関係の変更に伴いロックファイルを更新しました。 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
distディレクトリの内容を確認するデバッグステップを追加しました。 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Windows PowerShell用のコマンドに修正しました。 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
エラー出力を確実にキャプチャするようにPowerShellスクリプトを改善しました。 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
openパッケージをexternalとしてビルドする際にESMパッケージとして正しく扱うように修正しました。 仕様の変更: - openパッケージをdynamic importで読み込むように変更 コードの変更: - packages/zenn-cli/src/server/lib/server.ts - import文を削除し、open()呼び出し箇所でdynamic importを使用 - listening イベントハンドラをasync関数に変更 - packages/zenn-cli/rspack.server.js - externals設定でopenパッケージを'import open'として扱うように変更 - ESMパッケージであることを明示するコメントを追加 その他・備考: - openパッケージv10はESM専用のため、CommonJSのrequireでは読み込めない問題を解決 - dynamic importを使用することでクロスプラットフォーム対応を維持 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
修正前のコメントでは「dynamic importで読み込む」と記載していたが、 実際の実装は静的なESM importを使用しているため、コメントを修正。 - 誤: dynamic importで読み込む - 正: ESM importとして扱う 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Changed from dynamic import('open') to static import to simplify the code while maintaining the same functionality. The 'open' package is now imported at the top of the file.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
すべてのzennコマンド(init, new:article, new:book, list:articles, list:books, preview)のテストを追加しました。 主な変更点: - new:article/new:bookコマンドの対話型プロンプトに自動応答する仕組みを実装 - ファイル/ディレクトリが正しく作成されることを検証 - previewコマンドをバックグラウンドで起動し、HTTPリクエストでサーバー起動を確認してから停止する処理を実装 - 各コマンドのエラーハンドリングとメッセージを改善 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This change streamlines the E2E workflow to focus on basic installation and execution checks: - Use production dependencies only (--prod flag) to test the actual deployment scenario - Remove detailed command tests (new:article, new:book, list:*, preview) which are now covered by comprehensive tests in a previous commit 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
…ndencies This change modifies the E2E workflow to install all packages, removing the exclusion of devDependencies during installation. This adjustment ensures that the workflow has access to all necessary packages for testing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
仕様の変更: - E2Eワークフローで個別のコマンドテストを廃止し、Vitestベースの統合E2Eテストスイートを実行するように変更 コードの変更: - .github/workflows/e2e.yml: 個別のinitコマンドテストを削除し、`pnpm -C packages/zenn-cli e2e`による統合テスト実行に置き換え - packages/zenn-cli/package.json: `e2e`スクリプトを追加 - packages/zenn-cli/e2e.ts: 全zennコマンド(init, new:article, new:book, list:articles, list:books, preview)のE2Eテストを実装 - packages/zenn-cli/vitest.e2e.config.ts: E2Eテスト用のVitest設定ファイルを追加 - packages/zenn-cli/tsconfig.e2e.json: E2Eテスト用のTypeScript設定ファイルを追加 - packages/zenn-cli/tsconfig.json: `commands.e2e.ts`をincludeに追加 - pnpm-lock.yaml: 依存関係の更新 その他・備考: - E2Eテストは実際のファイルシステムを使用し、一時ディレクトリで実行されます - 各テストは独立したテストディレクトリを使用し、クリーンアップも自動で行われます 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Added comments to clarify the build process for zenn-editor packages on Linux and the restoration of zenn-cli bundle files from actions/cache for E2E tests on Windows. - This update improves the workflow's efficiency by leveraging cached artifacts across different operating systems. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
commands.e2e.ts は E2E テストファイルであり、通常のビルドプロセスに含める必要がないため、tsconfig.json の include から除外しました。 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
E2Eテストファイルを整理し、クロスプラットフォーム対応を改善しました。
仕様の変更:
- E2Eテストファイルを packages/zenn-cli/e2e.ts から packages/zenn-cli/src/e2e/e2e.ts に移動
- src配下に配置することでプロジェクト構造を統一
コードの変更:
- e2e.ts: __dirname から process.cwd() に変更し、実行時のworking directoryを基準にパス解決
- e2e.ts: パス連結を './dist/server/zenn.js' から join('dist', 'server', 'zenn.js') に変更し、Windows環境でも正しく動作するように改善
- tsconfig.e2e.json: include パスを新しいファイル位置に更新
- vitest.e2e.config.ts: include パスを新しいファイル位置に更新
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
## 仕様の変更 なし ## コードの変更 - `src/e2e/helper.ts` を新規作成 - `getZennCliPath()`: zenn CLI のパスを取得し、存在しない場合はエラーを投げる - `execZennCommand()`: zenn CLI コマンドを実行するヘルパー関数 - `src/e2e/e2e.ts` にテストを追加 - `new:article` コマンドのE2Eテスト(デフォルトと --slug オプション) - `new:book` コマンドのE2Eテスト(デフォルトと --slug オプション) - 既存の `init` コマンドテストをリファクタリング - `vitest.e2e.config.ts` にシングルワーカー設定を追加 - `pool: 'forks'` と `singleFork: true` を設定 ## その他・備考 - E2Eテストは必ずシングルワーカーで実行されるように設定 - ファイル作成の確認とエラーなく実行されることを検証 - すべてのテストが正常に合格 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
## 仕様の変更 なし ## コードの変更 - `src/e2e/e2e.ts` から --slug オプション付きテストを削除 - デフォルトの動作確認のみに簡略化 ## その他・備考 - テスト数を3つに削減(init, new:article, new:book) - すべてのテストが正常に合格 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
## 仕様の変更 なし ## コードの変更 - `src/e2e/e2e.ts` にテストを追加 - `list:articles` コマンドのE2Eテスト - `list:books` コマンドのE2Eテスト ## その他・備考 - 最低限のテストのみ実装(エラーなく実行されることを確認) - すべてのテストが正常に合格 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
## 仕様の変更 なし ## コードの変更 - `src/e2e/helper.ts` に `logIfFailed` 関数を追加 - コマンド実行結果が失敗している場合にログを出力 - `src/e2e/e2e.ts` で `logIfFailed` を使用するようリファクタリング - 重複していたエラーログ出力処理を共通化 ## その他・備考 - コードの重複を削減 - すべてのテストが正常に合格 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
## 仕様の変更 なし ## コードの変更 - `src/e2e/helper.ts` に `execZennPreview` 関数を追加 - preview コマンドを起動し、指定時間後に自動終了 - 起動時エラーの有無を確認 - `src/e2e/e2e.ts` に preview コマンドのテストを追加 - 3秒間起動してエラーがないことを確認 - すべてのテストケース名を日本語に統一 ## その他・備考 - preview コマンドはフォアグラウンドで常駐するため、タイムアウトで自動終了 - 全6テストが正常に合格 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
GitHub Actions workflow上でE2Eテストの実行ステップにPowerShellを明示的に指定しました。 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- E2EテストをUbuntuとWindowsの両方で実行するようmatrixを追加 - OS別にテスト実行ステップを条件分岐 - distディレクトリ確認ステップを削除してワークフローを簡素化 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| matrix: | ||
| os: [ubuntu-latest, windows-latest] |
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.
linuxとwindowsで動作確認
| needs: build | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| matrix: | ||
| os: [ubuntu-latest, windows-latest] | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
|
|
||
| - uses: pnpm/action-setup@v4 | ||
| with: | ||
| version: 10.18.3 | ||
|
|
||
| - name: パッケージをインストール | ||
| run: pnpm install | ||
|
|
||
| - name: zenn-cliのdistディレクトリをキャッシュから復元 | ||
| uses: actions/cache/restore@v4 | ||
| with: | ||
| path: packages/zenn-cli/dist | ||
| key: zenn-cli-dist-${{ github.sha }} | ||
| enableCrossOsArchive: true | ||
|
|
||
| - name: zenn-cliのE2Eテストを実行 (Windows) | ||
| if: runner.os == 'Windows' | ||
| run: pnpm -C packages/zenn-cli e2e | ||
| shell: pwsh | ||
|
|
||
| - name: zenn-cliのE2Eテストを実行 (Linux) | ||
| if: runner.os == 'Linux' | ||
| run: pnpm -C packages/zenn-cli e2e |
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 month ago
To address the issue, we need to explicitly define the permissions block for the workflow. The best approach is to add it at the root level of .github/workflows/e2e.yml, so it applies to all jobs, unless a job requires something more. Since the jobs only check out code, install packages, build, and cache artifacts, they only need read access to repository contents. We add the following at the top of the workflow:
permissions:
contents: readYou should insert this block immediately after the workflow name: and before on: to conform to standard order and style.
-
Copy modified lines R2-R3
| @@ -1,4 +1,6 @@ | ||
| name: E2E Test on Cross Platform | ||
| permissions: | ||
| contents: read | ||
|
|
||
| on: | ||
| pull_request: |
| "exec:zenn": "node ./dist/server/zenn.js" | ||
| }, | ||
| "dependencies": { | ||
| "open": "^10.2.0" |
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.
openを外部化し、ユーザーインストールするようにする
canaryブランチの最新変更を取り込みました。 - バージョン0.2.10-alpha.2への更新 - Windows環境でのscript実行の修正を含む変更をマージ - package.jsonのcleanスクリプトをcanaryの形式に統一しつつ、e2eスクリプトを保持
- Added a step to build zenn-cli before restoring the dist directory from cache in the E2E workflow.
…s before restoring the dist directory from cache.
| @@ -0,0 +1,155 @@ | |||
| import { mkdtemp, rm, access } from 'fs/promises'; | |||
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.
CLIに対するE2Eテスト。各コマンドがコケないか、最低限の動作確認を行う
|
openパッケージをexternalにしないとこのエラーになる |
cm-igarashi-ryosuke
left a comment
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.
CLIのE2Eテストという発想は思いつかなかったなーアプローチがすばらしい!LGTMです!
📑 Summary
仕様の変更
コードの変更
openパッケージをESM importとして外部化し、rspackでの取り扱いを改善しましたopenパッケージをdevDependenciesからdependenciesに移動しましたvitest.e2e.config.ts)を追加しましたその他・備考
📋 Tasks
プルリクエストを作成いただく際、お手数ですが以下の内容についてご確認をお願いします。
canaryブランチに対するプルリクエストであるより詳しい内容は Pull Request Policy を参照してください.