Open2
細かいTipsや備忘録

記事を作るまでもない備忘録を書き残していく。
今後清書して記事化するかもしれないものも含む

モノレポのカバレッジファイルをコンバインし、GitHubのプルリクエストでコメントするアクションステップ。
コメントの色付けや自由度に課題を感じて結局未使用。
- name: Setup LCOV
uses: hrishikesh-kadam/setup-lcov@v1
with:
ref: v2.3.2
# モノレポ全体のカバレッジを取得するために、
# パッケージごとのcoverage/lcov.infoを結合して、ルートにcoverage/lcov.infoを生成する
- name: Combine coverage reports
run: dart run combine_coverage --repo-path="${{ github.workspace }}"
# New Step: lcov.infoファイル内の絶対パスを相対パスに置換する
- name: Fix lcov paths
run: sed -i 's#^SF:/#SF:#' coverage/lcov.info
- name: Report coverage to PR comment
if: github.event_name == 'pull_request'
id: lcov-report
uses: zgosalvez/github-actions-report-lcov@v4
with:
coverage-files: coverage/lcov.info
artifact-name: coverage-html-report
github-token: ${{ secrets.GITHUB_TOKEN }}
working-directory: ${{ github.workspace }}
update-comment: true
- name: Check coverage percentage
if: github.event_name == 'pull_request'
run: |
COVERAGE=$(echo "${{ steps.lcov-report.outputs.coverage }}" | sed 's/%//')
MINIMUM=80
if (( $(echo "$COVERAGE < $MINIMUM" | bc -l) )); then
echo "Error: The code coverage is too low: ${{ steps.lcov-report.outputs.coverage }}. Expected at least $MINIMUM%."
exit 1
else
echo "Code coverage is sufficient: ${{ steps.lcov-report.outputs.coverage }}."
fi