diff --git a/.github/workflows/python-ci.yml b/.github/workflows/python-ci.yml index 682e72c58b..b18bc27a42 100644 --- a/.github/workflows/python-ci.yml +++ b/.github/workflows/python-ci.yml @@ -2,9 +2,15 @@ name: Delphi Python Tests on: push: - branches: [ edge, stable ] + branches: &branches [ edge, stable ] + paths: &paths + - 'delphi/**/*.py' + - 'delphi/requirements*.txt' + - 'delphi/Dockerfile' + - '.github/workflows/python-ci.yml' pull_request: - branches: [ edge, stable ] + branches: *branches + paths: *paths jobs: test: @@ -116,13 +122,35 @@ jobs: script: | const fs = require('fs'); const commentBody = fs.readFileSync('coverage-comment.md', 'utf8'); + const marker = ''; + const body = `${marker}\n## Delphi Coverage Report\n\n${commentBody}`; try { + // Find existing coverage comment + const { data: comments } = await github.rest.issues.listComments({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + }); + + const existingComment = comments.find(c => c.body.includes(marker)); + + if (existingComment) { + // Delete existing comment so new one appears after latest commit + await github.rest.issues.deleteComment({ + comment_id: existingComment.id, + owner: context.repo.owner, + repo: context.repo.repo, + }); + console.log('Existing coverage comment deleted.'); + } + + // Always create a new comment await github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - body: "## Coverage Report\n\n" + commentBody + body: body }); console.log('Coverage comment posted successfully.'); } catch (error) {