Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 42 additions & 2 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ on:
- master
- main
pull_request:
types: [opened, reopened, synchronize]
permissions:
contents: read
# Needed to leave comments
pull-requests: write
jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -17,5 +20,42 @@ jobs:
- uses: actions/setup-go@v5
with:
go-version: 1.25.1
cache-dependency-path: go.work.sum
- run: make test
- run: go test -test.timeout 20m $(go list ./... | grep -v bindings) -coverprofile=./cover.out -coverpkg=./...
# upload the plaintext coverage report
- name: Upload txt coverage report
uses: actions/upload-artifact@v4
with:
name: code-coverage
path: ./cover.out
# convert the plaintext coverage report to html
- run: go tool cover -html cover.out -o cover.html
# upload the html coverage report
- name: Upload html coverage report
uses: actions/upload-artifact@v4
with:
name: code-coverage-html
path: ./cover.html
id: html-upload-step
outputs:
artifact-url: ${{ steps.html-upload-step.outputs.artifact-url }}

coverage:
name: "Analyze coverage report"
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'rocket-pool/smartnode'
runs-on: ubuntu-latest
needs: build # only run if the previous job finished successfully
steps:
- name: Leave a comment with a link
uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '[Coverage Report](${{ needs.build.outputs.artifact-url }})'
})
- uses: fgrosse/go-coverage-report@ff33f0f3f96d20ecb97198100852d2af288094ff
with:
coverage-artifact-name: "code-coverage"
coverage-file-name: "cover.out"
Loading