diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b42625d..07decb3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,8 +13,8 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - go_version: ['1.21', '1.22'] - os: [ubuntu-latest, windows-latest, macos-14] + go_version: ['1.23'] + os: [ubuntu-latest, windows-latest, macos-latest] steps: @@ -53,3 +53,33 @@ jobs: fail_ci_if_error: false verbose: true token: ${{ secrets.CODECOV_TOKEN }} + + - name: Archive code coverage results + uses: actions/upload-artifact@v4 + with: + name: code-coverage-report-${{ matrix.os }} + path: coverage.txt + + sonarCloudTrigger: + needs: build + name: SonarCloud Trigger + if: github.event_name != 'pull_request' + runs-on: ubuntu-latest + steps: + - name: Clone Repository + uses: actions/checkout@v4 + with: + # Disabling shallow clone is recommended for improving relevancy of reporting + fetch-depth: 0 + + - name: Download code coverage results + uses: actions/download-artifact@v4 + + - name: Display structure of downloaded files + run: ls -R + + - name: Analyze with SonarCloud + uses: sonarsource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.gitignore b/.gitignore index e9e477a..bdec4ef 100644 --- a/.gitignore +++ b/.gitignore @@ -4,5 +4,6 @@ /detect-latest-release /go-get-release /coverage.out +/coverage.txt /cmd/restic /.vscode/ diff --git a/.golangci.yml b/.golangci.yml index 6b9cf9d..8dec473 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,54 +1,22 @@ -linters-settings: - govet: - check-shadowing: true - gocyclo: - min-complexity: 20 - dupl: - threshold: 100 - goconst: - min-len: 3 - min-occurrences: 3 - lll: - line-length: 160 - nakedret: - max-func-lines: 20 - gocritic: - enabled-tags: - - performance - - style - - diagnostic - disabled-checks: - - dupImport # https://github.com/go-critic/go-critic/issues/845 - settings: - rangeValCopy: - sizeThreshold: 512 - hugeParam: - sizeThreshold: 512 linters: - enable-all: true - disable: - - interfacer - - scopelint - - golint - - maligned - - godot - - gochecknoglobals - - exhaustivestruct - - wsl - - nestif - - goerr113 - - nlreturn - - wrapcheck + enable: + - asasalint + - asciicheck + - bidichk + - bodyclose + - contextcheck + - errname + - gocheckcompilerdirectives + - gosec + - maintidx - misspell - - cyclop - - whitespace - - paralleltest - - fast: false - -run: - tests: true - -issues: - exclude-use-default: true - + - nilnil + - noctx + - nolintlint + - predeclared + - reassign + - sloglint + - spancheck + - unconvert + - unparam + - usestdlibvars diff --git a/Makefile b/Makefile index c6893d6..404a82c 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ GOGET=$(GOCMD) get GOPATH?=`$(GOCMD) env GOPATH` TESTS=. ./update -COVERAGE_FILE=coverage.out +COVERAGE_FILE=coverage.txt BUILD_DATE=`date` BUILD_COMMIT=`git rev-parse HEAD` @@ -41,7 +41,7 @@ full-coverage: $(GOTOOL) cover -html=$(COVERAGE_FILE) clean: - rm detect-latest-release go-get-release coverage.out + rm detect-latest-release go-get-release coverage.txt $(GOCLEAN) toc: @@ -51,3 +51,19 @@ toc: sed -i ".1" "/${TOC_START}/,/${TOC_END}/{//!d;}" "${README}" sed -i ".2" "/${TOC_START}/r ${TOC_PATH}" "${README}" rm ${README}.1 ${README}.2 ${TOC_PATH} + +.PHONY: lint +lint: + @echo "[*] $@" + GOOS=darwin golangci-lint run + GOOS=linux golangci-lint run + GOOS=windows golangci-lint run + +.PHONY: fix +fix: + @echo "[*] $@" + $(GOCMD) mod tidy + $(GOCMD) fix ./... + GOOS=darwin golangci-lint run --fix + GOOS=linux golangci-lint run --fix + GOOS=windows golangci-lint run --fix diff --git a/codecov.yml b/codecov.yml index 1203e7f..ff4fc78 100644 --- a/codecov.yml +++ b/codecov.yml @@ -1,9 +1,9 @@ codecov: notify: - after_n_builds: 6 + after_n_builds: 3 comment: - after_n_builds: 6 + after_n_builds: 3 coverage: round: nearest diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..20651e2 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,11 @@ +sonar.organization=creativeprojects +sonar.projectKey=creativeprojects_go-selfupdate +sonar.projectName=go-selfupdate +sonar.projectVersion=1.4.0 + +sonar.sources=. +sonar.exclusions=**/*_test.go,/docs/** + +sonar.tests=. +sonar.test.inclusions=**/*_test.go +sonar.go.coverage.reportPaths=**/coverage.txt diff --git a/update/hide_noop.go b/update/hide_noop.go index 3707756..004339d 100644 --- a/update/hide_noop.go +++ b/update/hide_noop.go @@ -1,4 +1,4 @@ -// +build !windows +//go:build !windows package update