Skip to content

Add WebSocket support #342

Add WebSocket support

Add WebSocket support #342

Workflow file for this run

name: Tests
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
test:
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
go-version: ['1.24']
os: [ubuntu-latest, macos-latest, windows-latest]
fail-fast: true
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
cache: true
- name: Get dependencies
run: go mod download
- name: Verify dependencies
run: go mod verify
- name: Run tests
run: go test -v -race -coverpkg=github.com/Suhaibinator/SRouter/pkg/codec,github.com/Suhaibinator/SRouter/pkg/common,github.com/Suhaibinator/SRouter/pkg/metrics,github.com/Suhaibinator/SRouter/pkg/metrics/prometheus,github.com/Suhaibinator/SRouter/pkg/middleware,github.com/Suhaibinator/SRouter/pkg/router -coverprofile=coverage.txt -covermode=atomic ./pkg/...
- name: Check coverage
run: |
go tool cover -func=coverage.txt
COVERAGE=$(go tool cover -func=coverage.txt | grep total | awk '{print $3}' | tr -d '%')
if (( $(echo "$COVERAGE < 80" | bc -l) )); then
echo "Code coverage is below 80%: $COVERAGE%"
exit 1
fi
echo "Code coverage is $COVERAGE%"
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.24'
cache: true
- name: Install golangci-lint
run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
- name: Run golangci-lint
run: golangci-lint run --timeout=5m
build:
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
go-version: ['1.24']
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
cache: true
- name: Build
run: go build -v ./...
benchmark:
name: Benchmark
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.24'
cache: true
- name: Run benchmarks
run: go test -bench=. -benchmem ./pkg/router -run=^$ -v
examples:
name: Build Examples
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.24'
cache: true
- name: Build simple example
run: go build -v ./examples/simple
- name: Build prometheus example
run: go build -v ./examples/prometheus