Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Tests

on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

jobs:
test:
name: Unit and Integration Tests
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
cache: true

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y bc

- name: Download dependencies
run: go mod download

- name: Run tests with coverage
run: make test

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
file: ./coverage.out
flags: unittests
name: codecov-slacker
fail_ci_if_error: false
continue-on-error: true

- name: Archive coverage results
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage.out
retention-days: 30
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

# added by lint-install
out/
coverage.out
10 changes: 10 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ issues:
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
max-same-issues: 0

exclude-rules:
# Exclude errcheck for test files - test code doesn't need to check every error
- linters:
- errcheck
- thelper
- usetesting
- dogsled
- dupl
path: _test\.go$

formatters:
enable:
# - gci
Expand Down
32 changes: 30 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,37 @@ build-server:
build-registrar:
go build -v -o bin/slack-registrar ./cmd/registrar

# Run tests with race detection
# Run tests with race detection and coverage
test:
go test -v -race ./...
@echo "Running tests with race detection and coverage..."
@go test -v -race -coverprofile=coverage.out -covermode=atomic ./...
@echo ""
@echo "Coverage by package:"
@go test -coverprofile=coverage.out -covermode=atomic ./... 2>&1 | grep -E "coverage:" | awk '{print $$2 "\t" $$5}' | column -t
@echo ""
@echo "Checking for packages below 80% coverage..."
@failed=0; \
packages=$$(go list ./... | grep -v "/cmd/"); \
for pkg in $$packages; do \
output=$$(go test -coverprofile=/dev/null "$$pkg" 2>&1); \
if echo "$$output" | grep -q "\[no test files\]"; then \
continue; \
fi; \
coverage=$$(echo "$$output" | grep "coverage:" | awk '{print $$5}' | sed 's/%//'); \
if [ -n "$$coverage" ] && [ "$$coverage" != "statements" ]; then \
pkg_short=$$(echo "$$pkg" | sed 's|github.com/codeGROOVE-dev/slacker/||'); \
if [ "$$(echo "$$coverage < 80.0" | bc -l 2>/dev/null || echo 0)" -eq 1 ]; then \
echo "❌ FAIL: $$pkg_short has $$coverage% coverage (minimum: 80%)"; \
failed=1; \
fi; \
fi; \
done; \
if [ $$failed -eq 1 ]; then \
echo ""; \
echo "Coverage check failed. All packages must have at least 80% coverage."; \
exit 1; \
fi
@echo "✅ All packages meet 80% coverage threshold"

# Format code
fmt:
Expand Down
2 changes: 1 addition & 1 deletion cmd/registrar/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"time"

"github.com/codeGROOVE-dev/gsm"
"github.com/codeGROOVE-dev/slacker/internal/slack"
"github.com/codeGROOVE-dev/slacker/pkg/slack"
"github.com/gorilla/mux"
"golang.org/x/time/rate"
)
Expand Down
17 changes: 9 additions & 8 deletions cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ import (
"time"

"github.com/codeGROOVE-dev/gsm"
"github.com/codeGROOVE-dev/slacker/internal/bot"
"github.com/codeGROOVE-dev/slacker/internal/config"
"github.com/codeGROOVE-dev/slacker/internal/github"
"github.com/codeGROOVE-dev/slacker/internal/notify"
"github.com/codeGROOVE-dev/slacker/internal/slack"
"github.com/codeGROOVE-dev/slacker/internal/state"
"github.com/codeGROOVE-dev/slacker/pkg/bot"
"github.com/codeGROOVE-dev/slacker/pkg/config"
"github.com/codeGROOVE-dev/slacker/pkg/github"
"github.com/codeGROOVE-dev/slacker/pkg/notify"
"github.com/codeGROOVE-dev/slacker/pkg/slack"
"github.com/codeGROOVE-dev/slacker/pkg/state"
"github.com/codeGROOVE-dev/sprinkler/pkg/client"
"github.com/gorilla/mux"
"golang.org/x/sync/errgroup"
Expand Down Expand Up @@ -256,7 +256,7 @@ func run(ctx context.Context, cancel context.CancelFunc, cfg *config.ServerConfi
slog.Info("configured Slack manager with state store for DM tracking")

// Initialize notification manager for multi-workspace notifications.
notifier := notify.New(slackManager, configManager)
notifier := notify.New(notify.WrapSlackManager(slackManager), configManager)

// Initialize event router for multi-workspace event handling.
eventRouter := slack.NewEventRouter(slackManager)
Expand Down Expand Up @@ -711,7 +711,8 @@ func runBotCoordinators(
}

// Initialize daily digest scheduler
dailyDigest := notify.NewDailyDigestScheduler(notifier, githubManager, configManager, stateStore, slackManager)
//nolint:revive // line length acceptable for initialization
dailyDigest := notify.NewDailyDigestScheduler(notifier, github.WrapManager(githubManager), configManager, stateStore, notify.WrapSlackManager(slackManager))

// Start initial coordinators
cm.startCoordinators(ctx)
Expand Down
33 changes: 8 additions & 25 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ module github.com/codeGROOVE-dev/slacker
go 1.25.1

require (
cloud.google.com/go/datastore v1.21.0
github.com/codeGROOVE-dev/ds9 v0.6.0
github.com/codeGROOVE-dev/gh-mailto v0.0.0-20251024133418-149270eb16a9
github.com/codeGROOVE-dev/gsm v0.0.0-20251019065141-833fe2363d22
github.com/codeGROOVE-dev/prx v0.0.0-20251028202628-9f237ee71356
github.com/codeGROOVE-dev/retry v1.3.0
github.com/codeGROOVE-dev/sprinkler v0.0.0-20251028184624-4d8c8315a53a
github.com/codeGROOVE-dev/sprinkler v0.0.0-20251029020504-57f2ea3ae37a
github.com/codeGROOVE-dev/turnclient v0.0.0-20251028130307-1f85c9aa43c4
github.com/golang-jwt/jwt/v5 v5.3.0
github.com/google/go-github/v50 v50.2.0
Expand All @@ -21,36 +22,18 @@ require (
)

require (
cloud.google.com/go v0.123.0 // indirect
cloud.google.com/go/auth v0.17.0 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.8 // indirect
cloud.google.com/go/compute/metadata v0.9.0 // indirect
github.com/ProtonMail/go-crypto v1.3.0 // indirect
github.com/cloudflare/circl v1.6.1 // indirect
github.com/codeGROOVE-dev/prx v0.0.0-20251027204543-4e6165f046e5 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/google/go-cmp v0.7.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/s2a-go v0.1.9 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.6 // indirect
github.com/googleapis/gax-go/v2 v2.15.0 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/rogpeppe/go-internal v1.14.1 // indirect
github.com/shurcooL/graphql v0.0.0-20230722043721-ed46e5a46466 // indirect
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.63.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.63.0 // indirect
go.opentelemetry.io/otel v1.38.0 // indirect
go.opentelemetry.io/otel/metric v1.38.0 // indirect
go.opentelemetry.io/otel/trace v1.38.0 // indirect
github.com/stretchr/testify v1.11.1 // indirect
golang.org/x/crypto v0.43.0 // indirect
golang.org/x/net v0.46.0 // indirect
golang.org/x/sys v0.37.0 // indirect
golang.org/x/text v0.30.0 // indirect
google.golang.org/api v0.254.0 // indirect
google.golang.org/genproto v0.0.0-20251022142026-3a174f9686a8 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20251022142026-3a174f9686a8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20251022142026-3a174f9686a8 // indirect
google.golang.org/grpc v1.76.0 // indirect
google.golang.org/protobuf v1.36.10 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
)
Loading
Loading