Merge pull request #8 from ctrlsam/v2 #14
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: Go Tests | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| paths: | |
| - 'rigour/**' | |
| - '.github/workflows/go-tests.yml' | |
| pull_request: | |
| branches: [ main, develop ] | |
| paths: | |
| - 'rigour/**' | |
| jobs: | |
| test: | |
| name: Test Go Services | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| go-version: ['1.25.5'] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ matrix.go-version }} | |
| cache-dependency-path: rigour/go.sum | |
| - name: Install libpcap-dev | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libpcap-dev | |
| - name: Verify dependencies | |
| working-directory: ./rigour | |
| run: | | |
| go mod verify | |
| go mod download | |
| - name: Run go vet | |
| working-directory: ./rigour | |
| run: | | |
| # Exclude third_party directory which contains code with testing.T/B calls from goroutines | |
| go vet ./cmd/... | |
| go vet ./internal/... | |
| go vet ./pkg/... | |
| - name: Run go fmt check | |
| working-directory: ./rigour | |
| run: | | |
| fmt_output=$(gofmt -l .) | |
| if [ -n "$fmt_output" ]; then | |
| echo "The following files are not formatted:" | |
| echo "$fmt_output" | |
| exit 1 | |
| fi | |
| - name: Run tests | |
| working-directory: ./rigour | |
| run: | | |
| go test -v -race -coverprofile=coverage.out -covermode=atomic ./... | |
| - name: Generate coverage report | |
| working-directory: ./rigour | |
| run: go tool cover -html=coverage.out -o coverage.html | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| files: ./rigour/coverage.out | |
| flags: unittests | |
| name: codecov-rigour | |
| fail_ci_if_error: false | |
| - name: Upload coverage artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-report-go${{ matrix.go-version }} | |
| path: rigour/coverage.html | |
| build: | |
| name: Build Docker Images | |
| runs-on: ubuntu-latest | |
| needs: [test] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 |