こんにちは、rightgo09 です。
今回は、PHPUnit の実行とそのカバレッジの結果を AWS CodeBuild 上で行う方法をまとめます。
まとめ
結論としては PHPUnit のカバレッジ結果を Cobertura の XML として出力し、それを AWS CodeBuild の入力とすれば良いようです(現在 Clover 形式では AWS CodeBuild 内でエラーになってしまいました)。
AWS CodeBuild
buildspec.yml
カバレッジ付きの PHPUnit 実行部分
phases: ... build: commands: ... - ./vendor/bin/phpunit --coverage-cobertura coverage-report.xml
レポート出力部分
reports: coverage-report: files: - coverage-report.xml file-format: CoberturaXml
テスト結果のレポートも同時に出力する場合は、JUnit 形式の出力と入力をすれば可能です。
- ./vendor/bin/phpunit --coverage-cobertura coverage-report.xml --log-junit unittest-report.xml
reports: coverage-report: files: - coverage-report.xml file-format: CoberturaXml + unittest-report: + files: + - unittest-report.xml + file-format: JunitXml
以上です。