π§ͺ Adding Unit Tests #24
Workflow file for this run
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: 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 |