/** * WPML compatibility functions * * @global array $duplicated_posts Array to store the posts being duplicated. * * @package Yoast\WP\Duplicate_Post * @since 3.2 */ add_action( 'admin_init', 'duplicate_post_wpml_init' ); /** * Add handlers for WPML compatibility. */ function duplicate_post_wpml_init() { if ( defined( 'ICL_SITEPRESS_VERSION' ) ) { add_action( 'dp_duplicate_page', 'duplicate_post_wpml_copy_translations', 10, 3 ); add_action( 'dp_duplicate_post', 'duplicate_post_wpml_copy_translations', 10, 3 ); add_action( 'shutdown', 'duplicate_wpml_string_packages', 11 ); } } global $duplicated_posts; // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- Reason: Renaming a global variable is a BC break. $duplicated_posts = []; /** * Copy post translations. * * @global SitePress $sitepress Instance of the Main WPML class. * @global array $duplicated_posts Array of duplicated posts. * * @param int $post_id ID of the copy. * @param WP_Post $post Original post object. * @param string $status Status of the new post. */ function duplicate_post_wpml_copy_translations( $post_id, $post, $status = '' ) { global $sitepress; global $duplicated_posts; remove_action( 'dp_duplicate_page', 'duplicate_post_wpml_copy_translations', 10 ); remove_action( 'dp_duplicate_post', 'duplicate_post_wpml_copy_translations', 10 ); $current_language = $sitepress->get_current_language(); $trid = $sitepress->get_element_trid( $post->ID ); if ( ! empty( $trid ) ) { $translations = $sitepress->get_element_translations( $trid ); $new_trid = $sitepress->get_element_trid( $post_id ); foreach ( $translations as $code => $details ) { if ( $code !== $current_language ) { if ( $details->element_id ) { $translation = get_post( $details->element_id ); if ( ! $translation ) { continue; } $new_post_id = duplicate_post_create_duplicate( $translation, $status ); if ( ! is_wp_error( $new_post_id ) ) { $sitepress->set_element_language_details( $new_post_id, 'post_' . $translation->post_type, $new_trid, $code, $current_language ); } } } } // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- Reason: see above. $duplicated_posts[ $post->ID ] = $post_id; } } /** * Duplicate string packages. * * @global array() $duplicated_posts Array of duplicated posts. */ function duplicate_wpml_string_packages() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- Reason: renaming the function would be a BC-break. global $duplicated_posts; foreach ( $duplicated_posts as $original_post_id => $duplicate_post_id ) { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- Reason: using WPML native filter. $original_string_packages = apply_filters( 'wpml_st_get_post_string_packages', false, $original_post_id ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- Reason: using WPML native filter. $new_string_packages = apply_filters( 'wpml_st_get_post_string_packages', false, $duplicate_post_id ); if ( is_array( $original_string_packages ) ) { foreach ( $original_string_packages as $original_string_package ) { $translated_original_strings = $original_string_package->get_translated_strings( [] ); foreach ( $new_string_packages as $new_string_package ) { $cache = new WPML_WP_Cache( 'WPML_Package' ); $cache->flush_group_cache(); $new_strings = $new_string_package->get_package_strings(); foreach ( $new_strings as $new_string ) { if ( isset( $translated_original_strings[ $new_string->name ] ) ) { foreach ( $translated_original_strings[ $new_string->name ] as $language => $translated_string ) { do_action( // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals -- Reason: using WPML native filter. 'wpml_add_string_translation', $new_string->id, $language, $translated_string['value'], $translated_string['status'] ); } } } } } } } } Devin Cursor CICD運用 – Raqqa

Devin Cursor CICD運用

あなたの構成での“ベストな役割分担”

1) ローカル→AWS移行前(設計固め & コード整理)

Devin(自律)

  • リポジトリ横断の“読み込み→設計メモ化”
    • 目的:FastAPI、Odooアドオン、K8sマニフェスト、Helm/Ingress、SQLスキーマ等の依存関係マップをIssue/Doc化。
    • タスク例:「モノレポ各ディレクトリの依存関係を解析し、/docs/architecture.md に更新履歴と合わせて要約。欠落テスト候補を列挙してJira/Issuesを起票。」
  • テスト雛形の自動生成(後述の“テスト戦略”)
    • FastAPI:pytest + httpx
    • Odoo:odoo.tests.common.TransactionCase ベースのモジュール単体テスト
    • K8s:kubeconform/kubeval/conftest(OPA) で静的検証

Cursor(対話)

  • 日々の細かい修正(Router追加、スキーマ微修正、ドキュメント整備、OWLコンポーネント雛形)
  • 既存コードの部分的リファクタ(関数分割、型注釈、Docstring、エラーハンドリング)

2) AWS移行フェーズ(ECR/EKS/Secrets/OIDC)

Devin(自律)

  • GitHub OIDC→AWSロールの設定手順書とTerraform/YAMLの下書き作成
  • GitHub Actionsの環境昇格(dev→stg→prod)ワークフローの生成
  • プルリクごとのエフェメラル環境kind/k3d or preview namespace)をセットするジョブ化
  • K8sベストプラクティス監査polaris/kube-score)レポートを生成し、PRコメントに要点まとめ

Cursor(対話)

  • 生成されたワークフローやTerraformの微調整、値の注入(VPC/SG/ノードグループ)
  • ECRビルドキャッシュ最適化、イメージサイズ削減(マルチステージ、--mount=type=cache)の即時試行

3) CI/CD本実装(GitHub Actions)

Devin(自律)

  • 失敗から学習するテスト駆動の反復:Issue→失敗テスト生成→修正→再実行→PR
  • 依存の定期更新(Renovate的)+回帰テストの自動実行
  • セキュリティ定期スキャン(Trivy/CodeQL/Semgrep)と脆弱箇所のPR化

Cursor(対話)

  • 生成PRの要点レビューと差分の素早い手直し
  • FastAPIのスキーマ変更に合わせたフロントの型/クライアントSDK再生成

料金メモ:Devinは**Core($20〜の従量制+ACU課金)/Team($500固定)**といった階層。大量の自律セッションを常用しないならCoreから十分始められます。詳細は公式のPricing/Billing参照。 Devin+1


“テスト強化”に直結する具体タスク(Devin向け)

  1. 契約テスト(バックエンド⇄フロント)
    • OpenAPIから自動生成クライアントを用意し、CIでスキーマ破壊を検出。
    • Devinに「OpenAPI差分から壊れる可能性のあるFE呼び出し一覧を抽出→最小再現E2E(Playwright)を生成→PR」。
  2. Odooモジュールの回帰テスト
    • 代表モデル(例:sale.order / purchase.order / account.move)の重要ビジネスルールを洗い出し、
      Devinに失敗テスト→修正PRのループを担当させる。
    • データは最小Seed(YAML/CSV)+Factoryで合成。PostgresはローカルDB or Testcontainers
  3. K8s・インフラの検証
    • マニフェストをスキーマ・ポリシー検証kubeconform/conftest
    • 脆弱設定(特権・無リソース制限・:latest)を検知→修正PRをDevinが作成。
  4. パフォーマンス/コスト監視の最小導入
    • FastAPIに簡易Profiler、Prometheusエクスポート
    • K8sにHorizontal/Vertical Pod Autoscalerの推奨値を観測から提案→PR

Devinに投げる“実戦プロンプト”雛形

  • コード理解・設計マップ
    • 「このモノレポを解析し、サービス境界、主要依存、外部I/F(Odoo/Postgres/OpenAI)を図示(Mermaid)し、/docs/architecture.mdを更新。テスト未カバー領域と高リスク箇所をIssues化して。」
  • 契約テスト
    • /api/openapi.jsonを基にTypeScriptクライアントを再生成し、Playwrightで/fields//translate//searchのE2Eを追加。スキーマ差分が出たらCIでFailさせるGitHub Actionsも作ってPR。」
  • Odooモジュール回帰
    • sale.orderの状態遷移・小数丸め・権限制御の回帰テストをaddons/sale_portal/testsに追加。最小Seedで動くようFixが必要ならPR。」
  • K8s監査
    • /k8s配下のYAMLをkubeconformconftestで検証し、違反を修正するPRをまとめて作成。PolarisレポートをPRコメントに貼る。」

GitHub Actions(超コンパクト雛形)

name: ci
on: [pull_request]
jobs:
  test:
    runs-on: ubuntu-latest
    services:
      postgres:
        image: postgres:16
        env: { POSTGRES_PASSWORD: postgres, POSTGRES_DB: odoo }
        ports: ['5432:5432']
        options: >-
          --health-cmd "pg_isready -U postgres"
          --health-interval 10s --health-timeout 5s --health-retries 5
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with: { python-version: '3.11' }
      - run: pip install -r api/requirements.txt
      - name: FastAPI unit
        run: pytest -q api/tests
      - name: Odoo tests
        run: |
          ./scripts/odoo-test.sh  # ← Devinに作らせる:最小DB/モジュール指定/ログ収集
      - name: OpenAPI client regen + contract tests
        run: |
          npx openapi-typescript http://localhost:8000/openapi.json -o web/src/api.d.ts
          npm ci && npm test  # FE契約テスト
      - name: K8s static checks
        run: |
          curl -L https://github.com/yannh/kubeconform/... | sudo install ...
          kubeconform -strict -summary -exit-on-error ./k8s

こうした骨組みはCursorで微調整し、繰り返し作業・PR化はDevinに投げるのが効率的。


セキュリティ/運用ガードレール(超重要)

  • 最小権限:DevinのGitHub Appは特定リポのみ、“PR作成まで”に制限(直接push禁止)。
  • Secrets隔離:Devinが触れる環境変数はdev用限定。prod用は環境保護(環境承認/required reviewers)。
  • 検証環境のサンドボックス:PRごとにpreview namespace短命DBを発行して動作確認→自動破棄。
  • 監査ログ:Devinが生成・更新したファイルにフッター(生成者・日時・セッションID)を自動追記。

いつDevin/いつCursor?

  • Devin:課題駆動で“丸ごと任せたい”とき(設計要約、テスト起票、依存更新、K8s監査、CI配線)。
  • Cursor:手元で“素早く回したい”とき(関数実装、型リファクタ、細かな修正、レビュー補助)。

Comments

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です