Skip to content

Commit 100e2ef

Browse files
committedMar 12, 2025·
using diff way to comment.

File tree

3 files changed

+20
-24
lines changed

3 files changed

+20
-24
lines changed
 

‎.github/actions/test-coverage/action.yml

+13-2
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,27 @@ runs:
6565
6666
- name: ci/compare-coverage
6767
if: env.IS_PR_WITH_CACHE == 'true'
68+
id: compare-coverage
6869
shell: bash
6970
run: |
7071
echo "::group::compare-coverage"
71-
./scripts/compare-coverage.sh \
72+
output=$(./scripts/compare-coverage.sh \
7273
./main-coverage \
7374
./coverage \
7475
${{ github.event.pull_request.number }} \
75-
${{ inputs.github_token }}
76+
${{ inputs.github_token }})
77+
echo "report<<EOF" >> $GITHUB_ENV
78+
echo "$output" >> $GITHUB_ENV
79+
echo "EOF" >> $GITHUB_ENV
7680
echo "::endgroup::"
7781
82+
- name: Post coverage report
83+
if: env.IS_PR_WITH_CACHE == 'true'
84+
uses: thollander/actions-comment-pull-request@v3
85+
with:
86+
message: ${{ env.report }}
87+
comment_tag: coverage-report
88+
7889
- name: ci/upload-coverage
7990
if: github.ref_name == 'main'
8091
id: upload-coverage

‎.github/workflows/ci.yml

+7-14
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,11 @@ jobs:
1717
steps:
1818
- name: ci/checkout-repo
1919
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
20-
21-
- name: Comment PR
22-
uses: thollander/actions-comment-pull-request@v3
20+
- name: ci/test
21+
uses: ./.github/actions/test
22+
- name: ci/test-coverage
23+
if: github.event_name == 'pull_request' || github.ref_name == 'main'
24+
uses: ./.github/actions/test-coverage
2325
with:
24-
message: |
25-
Hello world ! :wave:
26-
27-
# - name: ci/test
28-
# uses: ./.github/actions/test
29-
# - name: ci/test-coverage
30-
# if: github.event_name == 'pull_request' || github.ref_name == 'main'
31-
# uses: ./.github/actions/test-coverage
32-
# with:
33-
# github_token: ${{ secrets.MM_MOBILE_GITHUB_TOKEN }}
34-
# run_id: ${{ github.run_id }}
26+
github_token: ${{ secrets.MM_MOBILE_GITHUB_TOKEN }}
27+
run_id: ${{ github.run_id }}

‎scripts/compare-coverage.sh

-8
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,6 @@ if [ "$HAS_DECREASE" -eq 1 ]; then
6363
COMMENT_BODY+=$'\n\n'"⚠️ **Warning:** One or more coverage metrics have decreased by more than ${COVERAGE_THRESHOLD}%"
6464
fi
6565

66-
if [ -n "$PR_NUMBER" ] && [ -n "$GITHUB_TOKEN" ]; then
67-
curl -X POST \
68-
-H "Authorization: token $GITHUB_TOKEN" \
69-
-H "Accept: application/vnd.github.v3+json" \
70-
"https://api.github.com/repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/comments" \
71-
-d "{\"body\":$(echo "$COMMENT_BODY" | jq -R -s .)}"
72-
fi
73-
7466
echo "$COMMENT_BODY"
7567

7668
# Not failing the build for now

0 commit comments

Comments
 (0)
Please sign in to comment.