Skip to content

chores: update golangci-lint config & add sonarcloud (#44) #125

chores: update golangci-lint config & add sonarcloud (#44)

chores: update golangci-lint config & add sonarcloud (#44) #125

Workflow file for this run

name: Build
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
name: Build and test
runs-on: ${{ matrix.os }}
strategy:
matrix:
go_version: ['1.23']
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: Set up Go ${{ matrix.go_version }}
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go_version }}
check-latest: true
cache: true
- name: Get dependencies
run: |
go mod download
- name: Build
run: go build -v ./...
- name: Test
shell: bash
run: |
if [[ "${GITHUB_TOKEN}" != "" ]]; then
go test -v -race -coverprofile=coverage.txt . ./update
else
go test -v -race -short -coverprofile=coverage.txt . ./update
fi
- name: Code coverage with codecov
uses: codecov/codecov-action@v4
with:
env_vars: OS,GO
file: ./coverage.txt
flags: unittests
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 }}