From 81a428e476695e22de7f53310d0142db3c8ec6f5 Mon Sep 17 00:00:00 2001 From: Omar Alani Date: Wed, 13 May 2026 11:30:11 -0500 Subject: [PATCH 1/5] ci: add sonarqube coverage workflow --- .github/workflows/sonarqube.yml | 56 +++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .github/workflows/sonarqube.yml diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml new file mode 100644 index 00000000..6f789943 --- /dev/null +++ b/.github/workflows/sonarqube.yml @@ -0,0 +1,56 @@ +name: SonarQube Analysis + +on: + push: + branches: [main] + pull_request: + types: [opened, synchronize, reopened] + +permissions: + contents: read + +concurrency: + group: sonarqube-${{ github.ref }} + cancel-in-progress: true + +jobs: + sonarqube: + name: SonarQube + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: Setup Go + uses: actions/setup-go@v6 + with: + go-version-file: go.mod + cache: true + + - name: Setup Task + uses: arduino/setup-task@v2 + + - name: Test with coverage + run: task test-coverage + + - name: SonarQube Scan + uses: SonarSource/sonarqube-scan-action@v7 + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: https://sonarcloud.io + with: + args: > + -Dsonar.organization=${{ vars.SONAR_ORGANIZATION || github.repository_owner }} + -Dsonar.projectKey=${{ vars.SONAR_PROJECT_KEY || format('{0}_{1}', github.repository_owner, github.event.repository.name) }} + -Dsonar.projectName=${{ github.event.repository.name }} + -Dsonar.go.coverage.reportPaths=coverage.out + -Dsonar.sources=. + -Dsonar.tests=. + -Dsonar.test.inclusions=**/*_test.go + -Dsonar.exclusions=bin/**,.gocache/**,.gomodcache/**,.tmp/**,coverage.html,coverage.out,docs/assets/**,**/*.png,**/*.jpg,**/*.jpeg,**/*.gif,**/*.webp,**/*.ico,**/*.svg,**/*.pdf + -Dsonar.coverage.exclusions=cmd/**,bench/**,docs/**,extensions/**,**/*_test.go + -Dsonar.c.file.suffixes=- + -Dsonar.cpp.file.suffixes=- + -Dsonar.objc.file.suffixes=- From 54607835e086dde6ccdf30f18697dacc9b679605 Mon Sep 17 00:00:00 2001 From: Omar Alani Date: Wed, 13 May 2026 11:43:08 -0500 Subject: [PATCH 2/5] ci: pin github actions --- .github/workflows/ci.yml | 16 ++++++++-------- .github/workflows/release.yml | 6 +++--- .github/workflows/sonarqube.yml | 8 ++++---- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c44774ad..bcf79698 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,25 +19,25 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v6 + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 - name: Setup Go - uses: actions/setup-go@v6 + uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6 with: go-version-file: go.mod cache: true - name: Setup Task - uses: arduino/setup-task@v2 + uses: arduino/setup-task@b91d5d2c96a56797b48ac1e0e89220bf64044611 # v2.0.0 - name: golangci-lint - uses: golangci/golangci-lint-action@v9 + uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9 - name: Test run: task test-coverage - name: Upload coverage - uses: codecov/codecov-action@v6 + uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6 with: file: ./coverage.out token: ${{ secrets.CODECOV_TOKEN }} @@ -55,10 +55,10 @@ jobs: goarch: arm64 steps: - name: Checkout - uses: actions/checkout@v6 + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 - name: Setup Go - uses: actions/setup-go@v6 + uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6 with: go-version-file: go.mod cache: true @@ -74,7 +74,7 @@ jobs: go build -v -o bin/librecode-${{ matrix.goos }}-${{ matrix.goarch }}${ext} ./cmd/librecode - name: Upload artifact - uses: actions/upload-artifact@v7 + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 with: name: librecode-${{ matrix.goos }}-${{ matrix.goarch }} path: bin/ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 48cc65a1..1fee7f0e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,18 +13,18 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v6 + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 with: fetch-depth: 0 - name: Setup Go - uses: actions/setup-go@v6 + uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6 with: go-version-file: go.mod cache: true - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v7 + uses: goreleaser/goreleaser-action@1a80836c5c9d9e5755a25cb59ec6f45a3b5f41a8 # v7 with: distribution: goreleaser version: "~> v2" diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml index 6f789943..1afb925d 100644 --- a/.github/workflows/sonarqube.yml +++ b/.github/workflows/sonarqube.yml @@ -19,24 +19,24 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v6 + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 with: fetch-depth: 0 - name: Setup Go - uses: actions/setup-go@v6 + uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6 with: go-version-file: go.mod cache: true - name: Setup Task - uses: arduino/setup-task@v2 + uses: arduino/setup-task@b91d5d2c96a56797b48ac1e0e89220bf64044611 # v2.0.0 - name: Test with coverage run: task test-coverage - name: SonarQube Scan - uses: SonarSource/sonarqube-scan-action@v7 + uses: SonarSource/sonarqube-scan-action@c7ee0f9df90b7aa20e8dcf9695dcfe2e7da5b4f2 # v7 env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} SONAR_HOST_URL: https://sonarcloud.io From 9c3d64e26d63c1deacad4a8b663cec480d5e55e7 Mon Sep 17 00:00:00 2001 From: Omar Alani Date: Wed, 13 May 2026 11:45:21 -0500 Subject: [PATCH 3/5] ci: skip sonar for forked prs --- .github/workflows/sonarqube.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml index 1afb925d..6f01951d 100644 --- a/.github/workflows/sonarqube.yml +++ b/.github/workflows/sonarqube.yml @@ -36,6 +36,7 @@ jobs: run: task test-coverage - name: SonarQube Scan + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository uses: SonarSource/sonarqube-scan-action@c7ee0f9df90b7aa20e8dcf9695dcfe2e7da5b4f2 # v7 env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} From a851cac3e151e6909d5c3fe6a60c5ee04bbf0bef Mon Sep 17 00:00:00 2001 From: Omar Alani Date: Wed, 13 May 2026 11:59:04 -0500 Subject: [PATCH 4/5] ci: add codecov coverage upload --- .github/workflows/ci.yml | 6 +++++- codecov.yml | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 codecov.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bcf79698..4a2bd634 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,10 +37,14 @@ jobs: run: task test-coverage - name: Upload coverage + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6 with: - file: ./coverage.out + files: ./coverage.out + flags: unittests + slug: omarluq/librecode token: ${{ secrets.CODECOV_TOKEN }} + fail_ci_if_error: true build: name: Build diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 00000000..1d47faa9 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,17 @@ +coverage: + status: + project: + default: + target: auto + threshold: 2% + patch: + default: + target: 70% + threshold: 5% + +ignore: + - "bench/**" + - "cmd/**" + - "docs/**" + - "extensions/**" + - "**/*_test.go" From 469561dfa1d07ee15439382aa40eaed0ec52991e Mon Sep 17 00:00:00 2001 From: Omar Alani Date: Wed, 13 May 2026 12:10:11 -0500 Subject: [PATCH 5/5] ci: remove explicit sonar scan --- .github/workflows/sonarqube.yml | 57 --------------------------------- 1 file changed, 57 deletions(-) delete mode 100644 .github/workflows/sonarqube.yml diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml deleted file mode 100644 index 6f01951d..00000000 --- a/.github/workflows/sonarqube.yml +++ /dev/null @@ -1,57 +0,0 @@ -name: SonarQube Analysis - -on: - push: - branches: [main] - pull_request: - types: [opened, synchronize, reopened] - -permissions: - contents: read - -concurrency: - group: sonarqube-${{ github.ref }} - cancel-in-progress: true - -jobs: - sonarqube: - name: SonarQube - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 - with: - fetch-depth: 0 - - - name: Setup Go - uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6 - with: - go-version-file: go.mod - cache: true - - - name: Setup Task - uses: arduino/setup-task@b91d5d2c96a56797b48ac1e0e89220bf64044611 # v2.0.0 - - - name: Test with coverage - run: task test-coverage - - - name: SonarQube Scan - if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository - uses: SonarSource/sonarqube-scan-action@c7ee0f9df90b7aa20e8dcf9695dcfe2e7da5b4f2 # v7 - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - SONAR_HOST_URL: https://sonarcloud.io - with: - args: > - -Dsonar.organization=${{ vars.SONAR_ORGANIZATION || github.repository_owner }} - -Dsonar.projectKey=${{ vars.SONAR_PROJECT_KEY || format('{0}_{1}', github.repository_owner, github.event.repository.name) }} - -Dsonar.projectName=${{ github.event.repository.name }} - -Dsonar.go.coverage.reportPaths=coverage.out - -Dsonar.sources=. - -Dsonar.tests=. - -Dsonar.test.inclusions=**/*_test.go - -Dsonar.exclusions=bin/**,.gocache/**,.gomodcache/**,.tmp/**,coverage.html,coverage.out,docs/assets/**,**/*.png,**/*.jpg,**/*.jpeg,**/*.gif,**/*.webp,**/*.ico,**/*.svg,**/*.pdf - -Dsonar.coverage.exclusions=cmd/**,bench/**,docs/**,extensions/**,**/*_test.go - -Dsonar.c.file.suffixes=- - -Dsonar.cpp.file.suffixes=- - -Dsonar.objc.file.suffixes=-