Repository navigation
Merge pull request #47 from Vaishnav88sk/feat/docs-cicd #114
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 Pipeline | |
| on: | |
| push: | |
| branches: | |
| - master | |
| pull_request: | |
| branches: | |
| - master | |
| jobs: | |
| lint: | |
| name: Code Quality | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Go Environment | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.25.x' | |
| - name: Check Formatting (go fmt) | |
| run: | | |
| for dir in $(find . -name go.mod -exec dirname {} \;); do | |
| echo "Checking $dir..." | |
| cd $dir | |
| if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then | |
| echo "The following files are not formatted properly in $dir:" | |
| gofmt -s -l . | |
| exit 1 | |
| fi | |
| cd - > /dev/null | |
| done | |
| - name: Static Analysis (go vet) | |
| run: | | |
| for dir in $(find . -name go.mod -exec dirname {} \;); do | |
| echo "Vetting $dir..." | |
| cd $dir | |
| go vet ./... | |
| cd - > /dev/null | |
| done | |
| test: | |
| name: Unit Tests (${{ matrix.module }}) | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| module: | |
| - clarctl-go | |
| - sre-agent/hub | |
| - sre-agent/agent | |
| - claritty-agent-client | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Go Environment | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.25.x' | |
| - name: Execute Unit Tests | |
| id: test | |
| run: | | |
| cd ${{ matrix.module }} | |
| if go list -f '{{if len .TestGoFiles}}{{.ImportPath}}{{end}}' ./... | grep -q .; then | |
| go list -f '{{if len .TestGoFiles}}{{.ImportPath}}{{end}}' ./... | xargs -r go test -v -coverprofile=coverage.txt | |
| echo "has_tests=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "has_tests=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Generate Cobertura XML | |
| if: steps.test.outputs.has_tests == 'true' | |
| run: | | |
| cd ${{ matrix.module }} | |
| go install github.com/boumenot/gocover-cobertura@latest | |
| gocover-cobertura < coverage.txt > coverage-${{ strategy.job-index }}.xml | |
| - name: Upload Coverage Artifact | |
| if: steps.test.outputs.has_tests == 'true' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-${{ strategy.job-index }} | |
| path: ./${{ matrix.module }}/coverage-${{ strategy.job-index }}.xml | |
| retention-days: 1 | |
| coverage-report: | |
| name: Coverage Report | |
| needs: test | |
| runs-on: ubuntu-latest | |
| permissions: | |
| pull-requests: write | |
| steps: | |
| - name: Download all coverage artifacts | |
| uses: actions/download-artifact@v4 | |
| continue-on-error: true | |
| with: | |
| path: coverage-results | |
| pattern: coverage-* | |
| merge-multiple: true | |
| - name: Generate Code Coverage Summary | |
| uses: irongut/CodeCoverageSummary@v1.3.0 | |
| with: | |
| filename: coverage-results/coverage-*.xml | |
| badge: true | |
| format: markdown | |
| hide_branch_rate: false | |
| hide_complexity: true | |
| indicators: true | |
| output: both | |
| - name: Add Coverage PR Comment | |
| uses: marocchino/sticky-pull-request-comment@v2 | |
| if: github.event_name == 'pull_request' | |
| with: | |
| recreate: true | |
| path: code-coverage-results.md |