Skip to content
Merged
Show file tree
Hide file tree
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
19 changes: 19 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,25 @@ jobs:
go version
shell: bash

# Also writes tests-report.json for Sonar.
- name: Test coverage
run: |
make test-cover
shell: bash

- name: Get golangci-lint version
id: golangci-lint
run: |
echo "version=$(awk '$1 == "github.com/golangci/golangci-lint/v2" { print $2 }' tools/golangci-lint/go.mod)" >> "$GITHUB_OUTPUT"
shell: bash

# The checkstyle report is for Sonar only, so the flag is here and not in .golangci.yml.
- name: Prepare lint report
uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0
with:
version: ${{ steps.golangci-lint.outputs.version }}
args: --config .golangci.yml --output.checkstyle.path=linters-report.xml

# Codecov rejects tokenless uploads to the default branch; authenticate with OIDC.
- name: Cover report upload
if: success()
Expand All @@ -157,3 +171,8 @@ jobs:
disable_search: true
use_oidc: true
fail_ci_if_error: true

- name: SonarCloud report upload
uses: SonarSource/sonarqube-scan-action@59202af334b4ba7b5db01b701b8e79f8b3bef0f4 # v8.5.0
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ dist/
coverage/
.DS_Store
README_doc.md
tests-report.json
linters-report.xml
.vscode/

# Codecov CLI downloaded by codecov-action in CI
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
[![Go Reference](https://pkg.go.dev/badge/github.com/obalunenko/getenv.svg)](https://pkg.go.dev/github.com/obalunenko/getenv)
[![Go Report Card](https://goreportcard.com/badge/github.com/obalunenko/getenv)](https://goreportcard.com/report/github.com/obalunenko/getenv)
[![codecov](https://codecov.io/gh/obalunenko/getenv/branch/master/graph/badge.svg)](https://codecov.io/gh/obalunenko/getenv)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=obalunenko_getenv&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=obalunenko_getenv)

# getenv

Expand Down
2 changes: 1 addition & 1 deletion scripts/tests/coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ echo "${SCRIPT_NAME} is running... "
rm -rf "${COVER_DIR}"
mkdir -p "${COVER_DIR}"

go test --count=1 -coverprofile "${COVER_DIR}/full.cov" -covermode=atomic ./...
go test --count=1 -coverprofile "${COVER_DIR}/full.cov" -covermode=atomic -json ./... >tests-report.json

echo "${SCRIPT_NAME} is done... "
31 changes: 31 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# =====================================================
# Standard properties
# =====================================================

sonar.projectKey=obalunenko_getenv
sonar.projectName=getenv
sonar.organization=obalunenko

sonar.host.url=https://sonarcloud.io
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# This property is optional if sonar.modules is set.
sonar.sources=.
sonar.exclusions=**/*_test.go

sonar.tests=.
sonar.test.inclusions=**/*_test.go
# =====================================================
# Meta-data for the project
# =====================================================

sonar.links.homepage=https://github.com/obalunenko/getenv
sonar.links.ci=https://github.com/obalunenko/getenv/actions
sonar.links.issue=https://github.com/obalunenko/getenv/issues

# =====================================================
# Properties specific to Go
# =====================================================

sonar.go.golangci-lint.reportPaths=linters-report.xml
sonar.go.tests.reportPaths=tests-report.json
sonar.go.coverage.reportPaths=coverage/full.cov