diff options
| author | Sho Sakuma <me@m1sk9.dev> | 2026-02-26 00:20:33 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-26 00:20:33 +0900 |
| commit | 382ccbc765cd1855d688f60f1235f3f4bfaac9d8 (patch) | |
| tree | 2bb41b90c19cfd3cfbe638f9f8fbd420ab96aa86 /.github | |
| parent | 56ed04185036635dcfd2763391cd64b8be371b1a (diff) | |
| parent | 70c785eee4c61601ba7fffa17cc8b992b4793491 (diff) | |
| download | LunaticChat-382ccbc765cd1855d688f60f1235f3f4bfaac9d8.tar.gz LunaticChat-382ccbc765cd1855d688f60f1235f3f4bfaac9d8.tar.bz2 LunaticChat-382ccbc765cd1855d688f60f1235f3f4bfaac9d8.zip | |
Merge pull request #119 from m1sk9/feat/codecov-jacoco-integration
feat: add Codecov/Jacoco integration and expand test coverage
Diffstat (limited to '.github')
| -rwxr-xr-x | .github/scripts/post-test-results.sh | 101 | ||||
| -rw-r--r-- | .github/workflows/ci.yaml | 22 |
2 files changed, 12 insertions, 111 deletions
diff --git a/.github/scripts/post-test-results.sh b/.github/scripts/post-test-results.sh deleted file mode 100755 index f8fbdf2..0000000 --- a/.github/scripts/post-test-results.sh +++ /dev/null @@ -1,101 +0,0 @@ -#!/bin/bash -set -e - -MARKER="<!-- test-results-comment -->" - -TOTAL_TESTS=0 -PASSED_TESTS=0 -FAILED_TESTS=0 -SKIPPED_TESTS=0 -FAILED_TEST_NAMES="" - -for xml_file in */build/test-results/test/*.xml; do - if [ -f "$xml_file" ]; then - tests=$(sed -n 's/.*tests="\([0-9]*\)".*/\1/p' "$xml_file" | head -n1) - failures=$(sed -n 's/.*failures="\([0-9]*\)".*/\1/p' "$xml_file" | head -n1) - skipped=$(sed -n 's/.*skipped="\([0-9]*\)".*/\1/p' "$xml_file" | head -n1) - - tests=${tests:-0} - failures=${failures:-0} - skipped=${skipped:-0} - - TOTAL_TESTS=$((TOTAL_TESTS + tests)) - FAILED_TESTS=$((FAILED_TESTS + failures)) - SKIPPED_TESTS=$((SKIPPED_TESTS + skipped)) - - if [ "$failures" -gt 0 ]; then - failed_names=$(sed -n 's/.*<testcase name="\([^"]*\)".*<failure.*/\1/p' "$xml_file" || echo "") - if [ -n "$failed_names" ]; then - FAILED_TEST_NAMES="${FAILED_TEST_NAMES}${failed_names}\n" - fi - fi - fi -done - -PASSED_TESTS=$((TOTAL_TESTS - FAILED_TESTS - SKIPPED_TESTS)) - -if [ "$FAILED_TESTS" -gt 0 ]; then - STATUS="❌ Failed" - STATUS_EMOJI="❌" -else - STATUS="✅ Passed" - STATUS_EMOJI="✅" -fi - -COMMENT_BODY="${MARKER} -## ${STATUS_EMOJI} Test Results - -| Status | Count | -|--------|-------| -| ✅ Passed | ${PASSED_TESTS} | -| ❌ Failed | ${FAILED_TESTS} | -| ⏭️ Skipped | ${SKIPPED_TESTS} | -| **Total** | **${TOTAL_TESTS}** | - -**Overall Status:** ${STATUS} -" - -if [ "$FAILED_TESTS" -gt 0 ] && [ -n "$FAILED_TEST_NAMES" ]; then - COMMENT_BODY="${COMMENT_BODY} - -<details> -<summary>❌ Failed Tests</summary> - -$(echo -e "$FAILED_TEST_NAMES" | sed 's/^/- /') - -</details> -" -fi - -COMMENT_BODY="${COMMENT_BODY} - ---- -*Updated at $(date -u '+%Y-%m-%d %H:%M:%S UTC')*" - -echo "$COMMENT_BODY" > /tmp/test-comment.md - -PR_NUMBER="${GITHUB_REF#refs/pull/}" -PR_NUMBER="${PR_NUMBER%/merge}" - -if [ -z "$PR_NUMBER" ] || [ "$PR_NUMBER" = "$GITHUB_REF" ]; then - echo "Not a pull request, skipping comment" - exit 0 -fi - -EXISTING_COMMENT_ID=$(gh api \ - "repos/$GITHUB_REPOSITORY/issues/${PR_NUMBER}/comments" \ - --jq ".[] | select(.body | contains(\"$MARKER\")) | .id" \ - | head -n 1 || echo "") - -if [ -n "$EXISTING_COMMENT_ID" ]; then - echo "Updating existing comment (ID: $EXISTING_COMMENT_ID)" - gh api \ - "repos/$GITHUB_REPOSITORY/issues/comments/${EXISTING_COMMENT_ID}" \ - -X PATCH \ - -f body="$(cat /tmp/test-comment.md)" -else - echo "Creating new comment" - gh pr comment "$PR_NUMBER" --body-file /tmp/test-comment.md -fi - -echo "Test results comment posted successfully" diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2f3a9e8..7ab33b6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -29,16 +29,18 @@ jobs: run: ./gradlew ktlintCheck --no-daemon - name: Run tests - run: ./gradlew test --no-daemon - continue-on-error: true - - - name: Post test results to PR - if: github.event_name == 'pull_request' && always() - env: - GH_TOKEN: ${{ github.token }} - GITHUB_REPOSITORY: ${{ github.repository }} - GITHUB_REF: ${{ github.ref }} - run: .github/scripts/post-test-results.sh + run: ./gradlew test jacocoTestReport --no-daemon + + - name: Upload coverage to Codecov + if: always() + uses: codecov/codecov-action@v5 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: | + engine/build/reports/jacoco/test/jacocoTestReport.xml, + platform-paper/build/reports/jacoco/test/jacocoTestReport.xml, + platform-velocity/build/reports/jacoco/test/jacocoTestReport.xml + fail_ci_if_error: false - name: Build with shadowJar run: ./gradlew :platform-paper:shadowJar :platform-velocity:shadowJar --parallel --no-daemon |
