Skip to content

πŸ§ͺ Adding Unit Tests #24

πŸ§ͺ Adding Unit Tests

πŸ§ͺ Adding Unit Tests #24

Workflow file for this run

name: Lint & Test πŸ•΅οΈβ€β™‚οΈ
on:
pull_request:
types: [opened, synchronize, reopened]
workflow_dispatch:
concurrency:
group: golangci-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
golangci:
name: Golang CI 🧹
runs-on: ubuntu-latest
steps:
- name: Checkout πŸ›ŽοΈ
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Install Go 🐹
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: "1.22"
cache: false
- name: golangci-lint πŸ•΅οΈβ€β™‚οΈ
uses: golangci/golangci-lint-action@3cfe3a4abbb849e10058ce4af15d205b6da42804 # v4.0.0
with:
version: v1.54
unittest:
name: Unit Test πŸ§ͺ
runs-on: ubuntu-latest
steps:
- name: Checkout πŸ›ŽοΈ
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Install Go 🐹
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: "1.22"
cache: false
- name: Install gocover-cobertura πŸ“¦
run: |
go get github.com/boumenot/gocover-cobertura && go install github.com/boumenot/gocover-cobertura
- name: Set up gotestfmt
uses: GoTestTools/gotestfmt-action@8b4478c7019be847373babde9300210e7de34bfb # v2.2.0
- name: Run tests πŸ§ͺ
run: sudo go test -race -json -v -coverprofile=coverage.txt ./... 2>&1 | tee /tmp/gotest.log | gotestfmt
- name: Convert go coverage to corbetura format πŸ”„
run: gocover-cobertura < coverage.txt > coverage.xml
- name: Upload coverage reports to Codecov β˜‚οΈ
uses: codecov/codecov-action@54bcd8715eee62d40e33596ef5e8f0f48dbbccab # v4.1.0
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
slug: pedrojreis/ScrumChrono
with:
files: ./coverage.xml
- name: Generate code coverage report πŸ“Š
uses: irongut/CodeCoverageSummary@51cc3a756ddcd398d447c044c02cb6aa83fdae95 # v1.3.0
with:
filename: coverage.xml
badge: false
fail_below_min: false
format: markdown
hide_branch_rate: false
hide_complexity: true
indicators: true
output: both
thresholds: "60 80"
- name: Add Coverage PR Comment πŸ“Œ
uses: marocchino/sticky-pull-request-comment@331f8f5b4215f0445d3c07b4967662a32a2d3e31 # v2.9.0
if: github.event_name == 'pull_request'
with:
recreate: true
path: code-coverage-results.md
# Upload the original go test log as an artifact for later review.
- name: Upload test log πŸ“€
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
if: always()
with:
name: test-log
path: /tmp/gotest.log
if-no-files-found: error