Communitygithub.com

Quarkus 検証ループ

Quarkusプロジェクト向け検証ループ: ビルド、静的解析、カバレッジ付きテスト、セキュリティスキャン、ネイティブコンパイル、リリース前やPR前の差分レビューを実行します。

Quarkus 検証ループ とは?

Quarkus Verification Loop は、PR作成前やデプロイ前、大規模リファクタリング後などに、Quarkusサービスの品質を多角的に検証するための包括的なスキルです。Maven/Gradleを用いたビルド、Checkstyle/PMD/SpotBugs/SonarQubeによる静的解析、JaCoCoで80%以上のカバレッジを担保するテスト、OWASP Dependency-CheckやZAPによるセキュリティスキャン、GraalVMネイティブコンパイル、K6を用いたパフォーマンステスト、ヘルスチェック、コンテナイメージのビルドとセキュリティスキャン、設定検証、ドキュメントレビューまでを段階的にカバーします。GitHub ActionsなどのCI/CDパイプラインへの組み込みも容易で、検証スクリプトも提供されています。このスキルはClaude CodeなどのAIエージェントでアクティベート可能で、コード品質、テスト、セキュリティ、デプロイ準備状態を一貫して確認するのに役立ちます。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/everything-claude-code/tree/main/skills/quarkus-verification

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

Quarkus 検証ループ は何をしますか?

PR前、大きな変更後、デプロイ前に実行してください。

アクティベーションタイミング

  • Quarkusサービスのプルリクエストを開く前
  • 大規模なリファクタリングや依存関係アップグレード後
  • ステージングまたは本番環境へのデプロイ前検証
  • フルビルド → リンター → テスト → セキュリティスキャン → ネイティブコンパイルのパイプライン実行
  • テストカバレッジがしきい値(80%以上)を満たしているか検証
  • ネイティブイメージの互換性テスト

フェーズ1: ビルド

# Maven
mvn clean verify -DskipTests

# Gradle
./gradlew clean assemble -x test

ビルドが失敗したら停止し、コンパイルエラーを修正します。

フェーズ2: 静的解析

Checkstyle、PMD、SpotBugs(Maven)

mvn checkstyle:check pmd:check spotbugs:check

SonarQube(設定されている場合)

mvn sonar:sonar \
  -Dsonar.projectKey=my-quarkus-project \
  -Dsonar.host.url=http://localhost:9000 \
  -Dsonar.login=${SONAR_TOKEN}

対応すべき一般的な問題

  • 未使用のインポートや変数
  • 複雑なメソッド(高い循環的複雑度)
  • 潜在的なnullポインタ参照
  • SpotBugsによってフラグが立てられたセキュリティ問題

フェーズ3: テスト + カバレッジ

# 全テストを実行
mvn clean test

# カバレッジレポートを生成
mvn jacoco:report

# カバレッジしきい値を適用(80%)
mvn jacoco:check

# またはGradleの場合
./gradlew test jacocoTestReport jacocoTestCoverageVerification

テストカテゴリ

単体テスト

依存関係をモック化してサービスのロジックをテスト:

@ExtendWith(MockitoExtension.class)
class UserServiceTest {
  @Mock UserRepository userRepository;
  @InjectMocks UserService userService;

  @Test
  void createUser_validInput_returnsUser() {
    var dto = new CreateUserDto("Alice", "[email protected]");

    // Panacheのpersist()はvoidなので、doNothing + verifyを使用
    doNothing().when(userRepository).persist(any(User.class));

    User result = userService.create(dto);

    assertThat(result.name).isEqualTo("Alice");
    verify(userRepository).persist(any(User.class));
  }
}

統合テスト

実際のデータベース(Testcontainers)でテスト:

@QuarkusTest
@QuarkusTestResource(PostgresTestResource.class)
class UserRepositoryIntegrationTest {

  @Inject
  UserRepository userRepository;

  @Test
  @Transactional
  void findByEmail_existingUser_returnsUser() {
    User user = new User();
    user.name = "Alice";
    user.email = "[email protected]";
    userRepository.persist(user);

    Optional<User> found = userRepository.findByEmail("[email protected]");

    assertThat(found).isPresent();
    assertThat(found.get().name).isEqualTo("Alice");
  }
}

APIテスト

REST Assuredを使用してRESTエンドポイントをテスト:

@QuarkusTest
class UserResourceTest {

  @Test
  void createUser_validInput_returns201() {
    given()
        .contentType(ContentType.JSON)
        .body("""
            {"name": "Alice", "email": "[email protected]"}
            """)
        .when().post("/api/users")
        .then()
        .statusCode(201)
        .body("name", equalTo("Alice"));
  }

  @Test
  void createUser_invalidEmail_returns400() {
    given()
        .contentType(ContentType.JSON)
        .body("""
            {"name": "Alice", "email": "invalid"}
            """)
        .when().post("/api/users")
        .then()
        .statusCode(400);
  }
}

カバレッジレポート

詳細なカバレッジは target/site/jacoco/index.html で確認:

  • 全体の行カバレッジ(目標: 80%以上)
  • 分岐カバレッジ(目標: 70%以上)
  • カバーされていない重要なパスを特定

フェーズ4: セキュリティスキャン

依存関係の脆弱性(Maven)

mvn org.owasp:dependency-check-maven:check

CVEについては target/dependency-check-report.html を確認。

Quarkusセキュリティ監査

# 脆弱な拡張機能を確認
mvn quarkus:audit

# すべての拡張機能を一覧表示
mvn quarkus:list-extensions

OWASP ZAP(APIセキュリティテスト)

docker run -t ghcr.io/zaproxy/zaproxy:stable zap-api-scan.py \
  -t http://localhost:8080/q/openapi \
  -f openapi

一般的なセキュリティチェック

  • すべてのシークレットは環境変数に(コード内に記述しない)
  • すべてのエンドポイントで入力検証
  • 認証/認可が設定されている
  • CORSが適切に設定されている
  • セキュリティヘッダーが設定されている
  • パスワードはBCryptでハッシュ化
  • SQLインジェクション対策(パラメータ化クエリ)
  • 公開エンドポイントにレート制限

フェーズ5: ネイティブコンパイル

GraalVMネイティブイメージの互換性をテスト:

# ネイティブ実行可能ファイルをビルド
mvn package -Dnative

# またはコンテナを使用
mvn package -Dnative -Dquarkus.native.container-build=true

# ネイティブ実行可能ファイルをテスト
./target/*-runner

# 基本的なスモークテストを実行
curl http://localhost:8080/q/health/live
curl http://localhost:8080/q/health/ready

ネイティブイメージのトラブルシューティング

よくある問題:

  • リフレクション: 動的クラスにリフレクション設定を追加
  • リソース: quarkus.native.resources.includes でリソースを含める
  • JNI: ネイティブライブラリを使用する場合はJNIクラスを登録

リフレクション設定の例:

@RegisterForReflection(targets = {MyDynamicClass.class})
public class ReflectionConfiguration {}

フェーズ6: パフォーマンステスト

K6を使った負荷テスト

// load-test.js
import http from 'k6/http';
import { check } from 'k6';

export const options = {
  stages: [
    { duration: '30s', target: 50 },
    { duration: '1m', target: 100 },
    { duration: '30s', target: 0 },
  ],
};

export default function () {
  const res = http.get('http://localhost:8080/api/markets');
  check(res, {
    'status is 200': (r) => r.status === 200,
    'response time < 200ms': (r) => r.timings.duration < 200,
  });
}

実行:

k6 run load-test.js

監視するメトリクス

  • 応答時間(p50、p95、p99)
  • スループット(リクエスト/秒)
  • エラー率
  • メモリ使用量
  • CPU使用率

フェーズ7: ヘルスチェック

# Liveness(生存確認)
curl http://localhost:8080/q/health/live

# Readiness(準備確認)
curl http://localhost:8080/q/health/ready

# すべてのヘルスチェック
curl http://localhost:8080/q/health

# メトリクス(有効な場合)
curl http://localhost:8080/q/metrics

期待される応答:

{
  "status": "UP",
  "checks": [
    {
      "name": "Database connection",
      "status": "UP"
    }
  ]
}

フェーズ8: コンテナイメージビルド

# コンテナイメージをビルド
mvn package -Dquarkus.container-image.build=true

# または特定のレジストリで
mvn package \
  -Dquarkus.container-image.build=true \
  -Dquarkus.container-image.registry=docker.io \
  -Dquarkus.container-image.group=myorg \
  -Dquarkus.container-image.tag=1.0.0

# コンテナをテスト
docker run -p 8080:8080 myorg/my-quarkus-app:1.0.0

コンテナセキュリティスキャン

# Trivy
trivy image myorg/my-quarkus-app:1.0.0

# Grype
grype myorg/my-quarkus-app:1.0.0

フェーズ9: 設定検証

# すべての設定プロパティを確認
mvn quarkus:info

# すべての設定ソースを一覧表示
curl http://localhost:8080/q/dev/io.quarkus.quarkus-vertx-http/config

環境固有のチェック

  • データベースURLが環境ごとに設定されている
  • シークレットが外部化されている(Vault、環境変数)
  • ログレベルが適切
  • CORSオリジンが正しく設定されている
  • レート制限が設定されている
  • モニタリング/トレーシングが有効

フェーズ10: ドキュメントレビュー

  • OpenAPI/Swaggerドキュメントが最新(/q/swagger-ui)
  • READMEにセットアップ手順がある
  • API変更がドキュメント化されている
  • 破壊的変更の移行ガイド
  • 設定プロパティがドキュメント化されている

OpenAPI仕様の生成:

curl http://localhost:8080/q/openapi -o openapi.json

検証チェックリスト

コード品質

  • 警告なしでビルドが成功
  • 静的解析がクリーン(高/中程度の問題がない)
  • コードがチームの規約に従っている
  • PR内にコメントアウトされたコードやTODOがない

テスト

  • すべてのテストが成功
  • コードカバレッジ ≥ 80%
  • 実際のデータベースを使った統合テスト
  • セキュリティテストが成功
  • パフォーマンスが許容範囲内

セキュリティ

  • 依存関係の脆弱性がない
  • 認証/認可がテストされている
  • 入力検証が完了している
  • シークレットがソースコードに含まれていない
  • セキュリティヘッダーが設定されている

デプロイ

  • ネイティブコンパイルが成功
  • コンテナイメージがビルドされる
  • ヘルスチェックが正しく応答する
  • 設定がターゲット環境で有効

ネイティブイメージ

  • ネイティブ実行可能ファイルがビルドされる
  • ネイティブテストが成功
  • 起動時間 < 100ms
  • メモリフットプリントが許容範囲内

自動検証スクリプト

#!/bin/bash
set -e

echo "=== フェーズ1: ビルド ==="
mvn clean verify -DskipTests

echo "=== フェーズ2: 静的解析 ==="
mvn checkstyle:check pmd:check spotbugs:check

echo "=== フェーズ3: テスト + カバレッジ ==="
mvn test jacoco:report jacoco:check

echo "=== フェーズ4: セキュリティスキャン ==="
mvn org.owasp:dependency-check-maven:check

echo "=== フェーズ5: ネイティブコンパイル ==="
mvn package -Dnative -Dquarkus.native.container-build=true

echo "=== 全フェーズ完了 ==="
echo "レポートを確認:"
echo "  - カバレッジ: target/site/jacoco/index.html"
echo "  - セキュリティ: target/dependency-check-report.html"
echo "  - ネイティブ: target/*-runner"

CI/CD統合

GitHub Actionsの例

name: Verification

on: [push, pull_request]

jobs:
  verify:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7

      - name: Set up JDK 21
        uses: actions/setup-java@v5
        with:
          java-version: '21'
          distribution: 'temurin'

      - name: Cache Maven packages
        uses: actions/cache@v6
        with:
          path: ~/.m2
          key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}

      - name: Build
        run: mvn clean verify -DskipTests

      - name: Test with Coverage
        run: mvn test jacoco:report jacoco:check

      - name: Security Scan
        run: mvn org.owasp:dependency-check-maven:check

      - name: Upload Coverage
        uses: codecov/codecov-action@v7
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
          files: target/site/jacoco/jacoco.xml

ベストプラクティス

  • すべてのPRの前に検証ループを実行する
  • CI/CDパイプラインで自動化する
  • 問題はすぐに修正し、負債を蓄積しない
  • カバレッジを80%以上に保つ
  • 依存関係を定期的に更新する
  • ネイティブコンパイルを定期的にテストする
  • パフォーマンスの傾向を監視する
  • 破壊的変更を文書化する
  • セキュリティスキャン結果をレビューする
  • 各環境の設定を検証する

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

accessibility

Design, implement, and audit inclusive digital products using WCAG 2.2 Level AA. Use when building or auditing UI that must meet WCAG 2.2 Level AA, or when reviewing a change for keyboard, contrast, or screen-reader support.

affaan-m/claude-api

Anthropic Claude API patterns for Python and TypeScript. Covers Messages API, streaming, tool use, vision, extended thinking, batches, prompt caching, and Claude Agent SDK. Use when building applications with the Claude API or Anthropic SDKs.

affaan-m/everything-claude-code

End-to-end marketing campaign planning and execution. Covers audience research, positioning, campaign angle definition, landing page copy, email sequences, social posts, ad copy, short-form video scripts, and content calendars. Use as the orchestration layer for multi-channel product launches. Use when planning or executing a multi-channel product launch, or producing landing page, email, social, or ad copy.

affaan-m/everything-claude-code

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/everything-claude-code-conventions

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/frontend-design

Create distinctive, production-grade frontend interfaces with high design quality. Use when the user asks to build web components, pages, or applications and the visual direction matters as much as the code quality.

affaan-m/gget

gget CLI and Python workflow for quick genomic database queries, sequence lookup, BLAST-style searches, enrichment checks, and reproducible bioinformatics evidence logs.

affaan-m/literature-review

Systematic literature-review workflow for academic, biomedical, technical, and scientific topics, including search planning, source screening, synthesis, citation checks, and evidence logging.

affaan-m/motion-ui

Production-ready UI motion system for React/Next.js. Use when implementing animations, transitions, or motion patterns.

affaan-m/project-guidelines-example

Example project-specific skill template based on a real production application.

affaan-m/pubmed-database

Direct PubMed and NCBI E-utilities search workflows for biomedical literature, MeSH queries, PMID lookup, citation retrieval, and API-backed literature monitoring.

affaan-m/scholar-evaluation

Structured scholarly-work evaluation for papers, proposals, literature reviews, methods sections, evidence quality, citation support, and research-writing feedback.

affaan-m/uspto-database

USPTO patent and trademark data workflow for official record lookup, PatentSearch queries, TSDR checks, assignment data, and reproducible IP research logs.

agent-architecture-audit

Full-stack diagnostic for agent and LLM applications. Audits the 12-layer agent stack for wrapper regression, memory pollution, tool discipline failures, hidden repair loops, and rendering corruption. Produces severity-ranked findings with code-first fixes. Essential for developers building agent applications, autonomous loops, or any LLM-powered feature. Use when an agent or LLM feature misbehaves and the failing layer is unknown, or before shipping an agent stack.

agent-eval

Head-to-head comparison of coding agents (Claude Code, Aider, Codex, etc.) on custom tasks with pass rate, cost, time, and consistency metrics. Use when choosing between coding agents, or when a change to an agent setup needs measured pass rate, cost, and time rather than an impression.

agent-harness-construction

Design and optimize AI agent action spaces, tool definitions, and observation formatting for higher completion rates. Use when defining or revising an agent

agentic-engineering

Operate as an agentic engineer using eval-first execution, decomposition, and cost-aware model routing. Use when planning or executing engineering work that agents will carry out end to end.

agentic-os

Build persistent multi-agent operating systems on Claude Code. Covers kernel architecture, specialist agents, slash commands, file-based memory, scheduled automation, and state management without external databases. Use when building a persistent multi-agent system on Claude Code with its own memory, commands, and scheduling.

agent-introspection-debugging

Structured self-debugging workflow for AI agent failures using capture, diagnosis, contained recovery, and introspection reports. Use when an agent run fails and you need a reproducible diagnosis instead of a retry.

agent-payment-x402

Add x402 payment execution to AI agents with per-task budgets, spending controls, and non-custodial wallets. Supports Base through agentwallet-sdk and X Layer through OKX Payments / OKX Agent Payments Protocol. Use when an agent must pay for something itself and needs per-task budgets, spending controls, and a non-custodial wallet.

関連スキル