Merge pull request #29 from 7or2ga/info-return-seconds #13
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Rescue Node API | |
on: | |
push: | |
tags: | |
- v* | |
branches: | |
- master | |
- main | |
pull_request: | |
types: [opened, reopened, synchronize] | |
permissions: | |
contents: read | |
# Needed to leave comments | |
pull-requests: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version: 1.21.1 | |
- run: | | |
go mod tidy | |
git diff --exit-code > /dev/null | |
if [[ $? -ne 0 ]]; then | |
echo "go mod tidy produces a diff" | |
exit 1 | |
fi | |
- run: | | |
make | |
# run the tests and create a coverage report | |
- run: go test ./... -coverprofile=./cover.out -covermode=atomic -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' | |
runs-on: ubuntu-latest | |
needs: build # only run if the previous job finished successfully | |
steps: | |
- uses: jshufro/go-coverage-report@e506bba8b2ed4fb709a1cb852d8801a1d66ff0f5 | |
with: | |
coverage-artifact-name: "code-coverage" | |
coverage-file-name: "cover.out" | |
skip-comment: true | |
id: report-step | |
- 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 }})\n${{ steps.report-step.outputs.coverage_report }}' | |
}) |