Skip to content

Commit c2f7c04

Browse files
authored
Merge pull request #64 from codeGROOVE-dev/reliable
upgrade ds9, add tests, move internal to pkg
2 parents e6e6fa9 + 677f723 commit c2f7c04

File tree

93 files changed

+13706
-909
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+13706
-909
lines changed

.github/workflows/test.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
pull_request:
7+
branches: [main, master]
8+
9+
jobs:
10+
test:
11+
name: Unit and Integration Tests
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Check out code
16+
uses: actions/checkout@v4
17+
18+
- name: Set up Go
19+
uses: actions/setup-go@v5
20+
with:
21+
go-version: '1.23'
22+
cache: true
23+
24+
- name: Install dependencies
25+
run: |
26+
sudo apt-get update
27+
sudo apt-get install -y bc
28+
29+
- name: Download dependencies
30+
run: go mod download
31+
32+
- name: Run tests with coverage
33+
run: make test
34+
35+
- name: Upload coverage to Codecov
36+
uses: codecov/codecov-action@v4
37+
with:
38+
file: ./coverage.out
39+
flags: unittests
40+
name: codecov-slacker
41+
fail_ci_if_error: false
42+
continue-on-error: true
43+
44+
- name: Archive coverage results
45+
uses: actions/upload-artifact@v4
46+
with:
47+
name: coverage-report
48+
path: coverage.out
49+
retention-days: 30

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11

22
# added by lint-install
33
out/
4+
coverage.out

.golangci.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@ issues:
1414
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
1515
max-same-issues: 0
1616

17+
exclude-rules:
18+
# Exclude errcheck for test files - test code doesn't need to check every error
19+
- linters:
20+
- errcheck
21+
- thelper
22+
- usetesting
23+
- dogsled
24+
- dupl
25+
path: _test\.go$
26+
1727
formatters:
1828
enable:
1929
# - gci

Makefile

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,37 @@ build-server:
1414
build-registrar:
1515
go build -v -o bin/slack-registrar ./cmd/registrar
1616

17-
# Run tests with race detection
17+
# Run tests with race detection and coverage
1818
test:
19-
go test -v -race ./...
19+
@echo "Running tests with race detection and coverage..."
20+
@go test -v -race -coverprofile=coverage.out -covermode=atomic ./...
21+
@echo ""
22+
@echo "Coverage by package:"
23+
@go test -coverprofile=coverage.out -covermode=atomic ./... 2>&1 | grep -E "coverage:" | awk '{print $$2 "\t" $$5}' | column -t
24+
@echo ""
25+
@echo "Checking for packages below 80% coverage..."
26+
@failed=0; \
27+
packages=$$(go list ./... | grep -v "/cmd/"); \
28+
for pkg in $$packages; do \
29+
output=$$(go test -coverprofile=/dev/null "$$pkg" 2>&1); \
30+
if echo "$$output" | grep -q "\[no test files\]"; then \
31+
continue; \
32+
fi; \
33+
coverage=$$(echo "$$output" | grep "coverage:" | awk '{print $$5}' | sed 's/%//'); \
34+
if [ -n "$$coverage" ] && [ "$$coverage" != "statements" ]; then \
35+
pkg_short=$$(echo "$$pkg" | sed 's|github.com/codeGROOVE-dev/slacker/||'); \
36+
if [ "$$(echo "$$coverage < 80.0" | bc -l 2>/dev/null || echo 0)" -eq 1 ]; then \
37+
echo "❌ FAIL: $$pkg_short has $$coverage% coverage (minimum: 80%)"; \
38+
failed=1; \
39+
fi; \
40+
fi; \
41+
done; \
42+
if [ $$failed -eq 1 ]; then \
43+
echo ""; \
44+
echo "Coverage check failed. All packages must have at least 80% coverage."; \
45+
exit 1; \
46+
fi
47+
@echo "✅ All packages meet 80% coverage threshold"
2048

2149
# Format code
2250
fmt:

cmd/registrar/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
"time"
1515

1616
"github.com/codeGROOVE-dev/gsm"
17-
"github.com/codeGROOVE-dev/slacker/internal/slack"
17+
"github.com/codeGROOVE-dev/slacker/pkg/slack"
1818
"github.com/gorilla/mux"
1919
"golang.org/x/time/rate"
2020
)

cmd/server/main.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ import (
1717
"time"
1818

1919
"github.com/codeGROOVE-dev/gsm"
20-
"github.com/codeGROOVE-dev/slacker/internal/bot"
21-
"github.com/codeGROOVE-dev/slacker/internal/config"
22-
"github.com/codeGROOVE-dev/slacker/internal/github"
23-
"github.com/codeGROOVE-dev/slacker/internal/notify"
24-
"github.com/codeGROOVE-dev/slacker/internal/slack"
25-
"github.com/codeGROOVE-dev/slacker/internal/state"
20+
"github.com/codeGROOVE-dev/slacker/pkg/bot"
21+
"github.com/codeGROOVE-dev/slacker/pkg/config"
22+
"github.com/codeGROOVE-dev/slacker/pkg/github"
23+
"github.com/codeGROOVE-dev/slacker/pkg/notify"
24+
"github.com/codeGROOVE-dev/slacker/pkg/slack"
25+
"github.com/codeGROOVE-dev/slacker/pkg/state"
2626
"github.com/codeGROOVE-dev/sprinkler/pkg/client"
2727
"github.com/gorilla/mux"
2828
"golang.org/x/sync/errgroup"
@@ -256,7 +256,7 @@ func run(ctx context.Context, cancel context.CancelFunc, cfg *config.ServerConfi
256256
slog.Info("configured Slack manager with state store for DM tracking")
257257

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

261261
// Initialize event router for multi-workspace event handling.
262262
eventRouter := slack.NewEventRouter(slackManager)
@@ -711,7 +711,8 @@ func runBotCoordinators(
711711
}
712712

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

716717
// Start initial coordinators
717718
cm.startCoordinators(ctx)

go.mod

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ module github.com/codeGROOVE-dev/slacker
33
go 1.25.1
44

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

2324
require (
24-
cloud.google.com/go v0.123.0 // indirect
25-
cloud.google.com/go/auth v0.17.0 // indirect
26-
cloud.google.com/go/auth/oauth2adapt v0.2.8 // indirect
27-
cloud.google.com/go/compute/metadata v0.9.0 // indirect
2825
github.com/ProtonMail/go-crypto v1.3.0 // indirect
2926
github.com/cloudflare/circl v1.6.1 // indirect
30-
github.com/codeGROOVE-dev/prx v0.0.0-20251027204543-4e6165f046e5 // indirect
31-
github.com/felixge/httpsnoop v1.0.4 // indirect
32-
github.com/go-logr/logr v1.4.3 // indirect
33-
github.com/go-logr/stdr v1.2.2 // indirect
27+
github.com/google/go-cmp v0.7.0 // indirect
3428
github.com/google/go-querystring v1.1.0 // indirect
35-
github.com/google/s2a-go v0.1.9 // indirect
36-
github.com/googleapis/enterprise-certificate-proxy v0.3.6 // indirect
37-
github.com/googleapis/gax-go/v2 v2.15.0 // indirect
3829
github.com/gorilla/websocket v1.5.3 // indirect
30+
github.com/kr/pretty v0.3.1 // indirect
31+
github.com/rogpeppe/go-internal v1.14.1 // indirect
3932
github.com/shurcooL/graphql v0.0.0-20230722043721-ed46e5a46466 // indirect
40-
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
41-
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.63.0 // indirect
42-
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.63.0 // indirect
43-
go.opentelemetry.io/otel v1.38.0 // indirect
44-
go.opentelemetry.io/otel/metric v1.38.0 // indirect
45-
go.opentelemetry.io/otel/trace v1.38.0 // indirect
33+
github.com/stretchr/testify v1.11.1 // indirect
4634
golang.org/x/crypto v0.43.0 // indirect
4735
golang.org/x/net v0.46.0 // indirect
4836
golang.org/x/sys v0.37.0 // indirect
4937
golang.org/x/text v0.30.0 // indirect
50-
google.golang.org/api v0.254.0 // indirect
51-
google.golang.org/genproto v0.0.0-20251022142026-3a174f9686a8 // indirect
52-
google.golang.org/genproto/googleapis/api v0.0.0-20251022142026-3a174f9686a8 // indirect
53-
google.golang.org/genproto/googleapis/rpc v0.0.0-20251022142026-3a174f9686a8 // indirect
54-
google.golang.org/grpc v1.76.0 // indirect
55-
google.golang.org/protobuf v1.36.10 // indirect
38+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
5639
)

0 commit comments

Comments
 (0)