Skip to content

Commit ea145e0

Browse files
Merge pull request #2 from marcelloromani/feature/try-comment-on-pr
comment code coverage on PRs
2 parents 20ecf97 + 26f2f37 commit ea145e0

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

.github/workflows/pr-comment.yaml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,33 @@
1-
name: Comment on PR
1+
name: Report test coverage on PR
22

33
on:
44
pull_request:
55
branches: [ "main" ]
66

77
jobs:
8-
comment:
8+
comment-test-coverage:
99
runs-on: ubuntu-latest
1010
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v4
13+
- name: Install uv
14+
uses: astral-sh/setup-uv@v5
15+
- name: Test
16+
id: test
17+
run: |
18+
echo "coverage<<EOF" >> $GITHUB_OUTPUT
19+
make test-gha >> $GITHUB_OUTPUT
20+
echo "EOF" >> $GITHUB_OUTPUT
21+
1122
- uses: actions/github-script@v7
23+
env:
24+
INPUT_COVERAGE: ${{ steps.test.outputs.coverage }}
1225
with:
13-
github-token: ${{secrets.GHA_PRS}}
26+
github-token: ${{ secrets.GHA_PRS }}
1427
script: |
1528
github.rest.issues.createComment({
1629
issue_number: context.issue.number,
1730
owner: context.repo.owner,
1831
repo: context.repo.repo,
19-
body: '👋 Thanks for reporting!'
32+
body: '```' + core.getInput('coverage') + '```'
2033
})

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ test-report-mac:
99
.PHONY: test-report-win
1010
test-report-win:
1111
start htmlcov/index.html
12+
13+
.PHONY: test-gha
14+
test-gha:
15+
uv run pytest --cov-report=term -r f -s

src/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
def main():
2-
print("Hello from python-template!")
2+
print("Hello from python-basic-template!")
33

44

55
if __name__ == "__main__":

0 commit comments

Comments
 (0)