feat: Enhance CI configuration with linting, security checks, and cov… #3
This file contains hidden or 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: CI | ||
| on: | ||
| push: | ||
| branches: | ||
| - master | ||
| - main | ||
| pull_request: | ||
| branches: | ||
| - master | ||
| - main | ||
| permissions: | ||
| contents: read | ||
| concurrency: | ||
| group: ci-${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
| jobs: | ||
| lint: | ||
| name: Lint and Static Analysis | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 12 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: '1.25' | ||
| - name: Install Linux dependencies | ||
| run: sudo apt-get update && sudo apt-get install -y libgtk-3-dev libayatana-appindicator3-dev | ||
| - name: Check gofmt | ||
| run: test -z "$(gofmt -l .)" | ||
| - name: Run go vet | ||
| run: go vet ./... | ||
| - name: Install staticcheck | ||
| run: go install honnef.co/go/tools/cmd/staticcheck@latest | ||
| - name: Run staticcheck | ||
| run: "$(go env GOPATH)/bin/staticcheck" ./... | ||
| security: | ||
| name: Security Checks | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 12 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: '1.25' | ||
| - name: Run gitleaks | ||
| uses: gitleaks/gitleaks-action@v2 | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Install govulncheck | ||
| run: go install golang.org/x/vuln/cmd/govulncheck@latest | ||
| - name: Run govulncheck | ||
| run: "$(go env GOPATH)/bin/govulncheck" ./... | ||
| test: | ||
| name: Unit and Build Tests | ||
| needs: [lint, security] | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 18 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: '1.25' | ||
| - name: Install Linux dependencies | ||
| run: sudo apt-get update && sudo apt-get install -y libgtk-3-dev libayatana-appindicator3-dev | ||
| - name: Run go test | ||
| run: go test ./... -count=1 -timeout=12m -covermode=atomic -coverprofile=coverage.out | ||
| - name: Upload coverage artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: coverage.out | ||
| path: coverage.out | ||
| retention-days: 14 | ||
| race: | ||
| name: Race Detector | ||
| needs: test | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 25 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: '1.25' | ||
| - name: Install Linux dependencies | ||
| run: sudo apt-get update && sudo apt-get install -y libgtk-3-dev libayatana-appindicator3-dev | ||
| - name: Run go test -race | ||
| run: go test -race ./... -count=1 -timeout=20m | ||
| build: | ||
| name: Build Matrix | ||
| needs: [lint, security, test] | ||
| runs-on: ${{ matrix.os }} | ||
| timeout-minutes: 20 | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| - os: ubuntu-latest | ||
| goos: linux | ||
| cgo: 1 | ||
| - os: macos-latest | ||
| goos: darwin | ||
| cgo: 0 | ||
| - os: windows-latest | ||
| goos: windows | ||
| cgo: 0 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: '1.25' | ||
| - name: Install Linux dependencies | ||
| if: matrix.goos == 'linux' | ||
| run: sudo apt-get update && sudo apt-get install -y libgtk-3-dev libayatana-appindicator3-dev | ||
| - name: Build | ||
| env: | ||
| GOOS: ${{ matrix.goos }} | ||
| GOARCH: amd64 | ||
| CGO_ENABLED: ${{ matrix.cgo }} | ||
| run: go build ./cmd/klip | ||