Skip to content

Commit d6910ab

Browse files
Test
1 parent 47e7234 commit d6910ab

File tree

1 file changed

+35
-11
lines changed

1 file changed

+35
-11
lines changed

.github/workflows/coverage.yaml

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,21 @@ name: Coverage Check
99
jobs:
1010
coverage:
1111
runs-on: ubuntu-latest
12+
services:
13+
dind:
14+
image: docker:23.0-rc-dind-rootless
15+
ports:
16+
- 2375:2375
1217
steps:
1318
- name: Checkout code
14-
uses: actions/checkout@v3
15-
16-
- name: Install Go
17-
uses: actions/setup-go@v4
19+
uses: actions/checkout@v4
20+
- name: Set up Go
21+
uses: actions/setup-go@v5
1822
with:
19-
go-version: '1.24'
20-
23+
go-version: 1.24.2
2124
- name: Run tests and calculate coverage
2225
run: |
23-
go test -cover ./... > coverage.txt
26+
POSTGRES_CONTAINER=1 VERNEMQ_CONTAINER=1 go test -cover ./... > coverage.txt
2427
CURRENT_COVERAGE=$(grep -oP '\d+\.\d+%' coverage.txt | tail -1 | tr -d '%')
2528
echo "CURRENT_COVERAGE=$CURRENT_COVERAGE" >> $GITHUB_ENV
2629
if [ -f previous_coverage.txt ]; then
@@ -32,18 +35,39 @@ jobs:
3235
CHANGE=$(echo "$CURRENT_COVERAGE - $PREVIOUS_COVERAGE" | bc)
3336
echo "CHANGE=$CHANGE" >> $GITHUB_ENV
3437
echo "$CURRENT_COVERAGE" > previous_coverage.txt
35-
38+
- name: Delete old coverage comments
39+
uses: actions/github-script@v7
40+
with:
41+
script: |
42+
const { data: comments } = await github.rest.issues.listComments({
43+
owner: context.repo.owner,
44+
repo: context.repo.repo,
45+
issue_number: context.issue.number,
46+
});
47+
const coverageCommentTag = '<!-- coverage-comment -->';
48+
for (const comment of comments) {
49+
if (comment.body.includes(coverageCommentTag)) {
50+
await github.rest.issues.deleteComment({
51+
owner: context.repo.owner,
52+
repo: context.repo.repo,
53+
comment_id: comment.id,
54+
});
55+
}
56+
}
3657
- name: Post coverage comment
3758
uses: actions/github-script@v7
3859
with:
3960
script: |
4061
const currentCoverage = process.env.CURRENT_COVERAGE || 'unknown';
4162
const previousCoverage = process.env.PREVIOUS_COVERAGE || 'unknown';
4263
const change = process.env.CHANGE || 'unknown';
43-
const commentBody = `Coverage: **${currentCoverage}%** (${change >= 0 ? '+' : ''}${change}%)`;
64+
const commentBody = `
65+
<!-- coverage-comment -->
66+
Coverage: **${currentCoverage}%** (${change >= 0 ? '+' : ''}${change}%)
67+
`;
4468
await github.rest.issues.createComment({
4569
issue_number: context.issue.number,
4670
owner: context.repo.owner,
4771
repo: context.repo.repo,
48-
body: commentBody
49-
})
72+
body: commentBody,
73+
});

0 commit comments

Comments
 (0)