-
Notifications
You must be signed in to change notification settings - Fork 0
2025-11-11 17:30:03+04:00 #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -36,3 +36,6 @@ docker-compose.override.yml | |||||||||
| .env | ||||||||||
|
|
||||||||||
| /data/ | ||||||||||
| -e | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the erroneous The literal Apply this diff to remove the erroneous entry: /data/
--e
# Build artifacts
build/📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
| # Build artifacts | ||||||||||
| build/ | ||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| # .pre-commit-config.yaml | ||
|
|
||
| --- | ||
| repos: | ||
| - repo: https://github.com/pre-commit/pre-commit-hooks | ||
| rev: v5.0.0 | ||
| hooks: | ||
| - id: trailing-whitespace | ||
| always_run: true | ||
| - id: end-of-file-fixer | ||
| always_run: true | ||
| - id: check-yaml | ||
| always_run: true | ||
| - id: check-added-large-files | ||
| always_run: true | ||
| - id: check-merge-conflict | ||
| always_run: true | ||
| - id: check-symlinks | ||
| always_run: true | ||
| - id: detect-private-key | ||
| always_run: true | ||
| - id: no-commit-to-branch | ||
| args: ['--branch', 'main'] | ||
| always_run: true | ||
|
|
||
| - repo: https://github.com/golangci/golangci-lint | ||
| rev: v1.55.2 | ||
| hooks: | ||
| - id: golangci-lint | ||
| args: [--fix, --timeout=5m] | ||
| always_run: true | ||
|
|
||
| - repo: local | ||
| hooks: | ||
| - id: go-fmt | ||
| name: go fmt | ||
| entry: gofmt -w . | ||
| language: system | ||
| types: [go] | ||
| always_run: true | ||
|
|
||
| - id: go-vet | ||
| name: go vet | ||
| entry: go vet ./... | ||
| language: system | ||
| types: [go] | ||
| pass_filenames: false | ||
| always_run: true | ||
|
|
||
| - id: go-tests | ||
| name: go test | ||
| entry: go test 5mdt/bd_bot/... | ||
| language: system | ||
| types: [go] | ||
| pass_filenames: false | ||
| always_run: true |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| --- | ||
|
|
||
| extends: default | ||
|
|
||
| rules: | ||
| braces: | ||
| level: warning | ||
| max-spaces-inside: 1 | ||
| comments-indentation: disable | ||
| comments: disable | ||
| line-length: disable |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| # Makefile for bd_bot project | ||
|
|
||
| # Go parameters | ||
| GOCMD=go | ||
| GOBUILD=$(GOCMD) build | ||
| GOTEST=$(GOCMD) test | ||
| GOVET=$(GOCMD) vet | ||
| GOFMT=gofmt | ||
|
|
||
| # Directories | ||
| CMD_DIR=./cmd/app | ||
| INTERNAL_DIR=./internal | ||
| BUILD_DIR=./build | ||
|
|
||
| # Binary output | ||
| BINARY_NAME=bd_bot | ||
| BINARY_LINUX=$(BINARY_NAME)_linux | ||
| BINARY_DARWIN=$(BINARY_NAME)_darwin | ||
| BINARY_WIN=$(BINARY_NAME)_windows.exe | ||
|
|
||
| # Packages | ||
| PKG=5mdt/bd_bot/... | ||
|
|
||
| # Ensure build directory exists | ||
| $(shell mkdir -p $(BUILD_DIR)) | ||
|
|
||
| .PHONY: all test vet fmt clean build build-linux build-darwin build-windows build-all deps pre-commit docker-build docker-run ci | ||
|
|
||
| # Default target | ||
| all: fmt vet test build | ||
|
|
||
| # Run tests | ||
| test: | ||
| $(GOTEST) $(PKG) | ||
|
|
||
| # Run code quality checks | ||
| vet: | ||
| $(GOVET) $(PKG) | ||
|
|
||
| # Format code | ||
| fmt: | ||
| $(GOFMT) -w . | ||
|
|
||
| # Clean build artifacts | ||
| clean: | ||
| rm -rf $(BUILD_DIR) | ||
|
|
||
| # Install dependencies | ||
| deps: | ||
| $(GOCMD) mod tidy | ||
| $(GOCMD) mod download | ||
|
|
||
| # Run pre-commit hooks | ||
| pre-commit: | ||
| pre-commit run --all-files | ||
|
|
||
| # Build for current platform | ||
| build: | ||
| $(GOBUILD) -o $(BUILD_DIR)/$(BINARY_NAME) $(CMD_DIR) | ||
|
|
||
| # Build for Linux | ||
| build-linux: | ||
| GOOS=linux GOARCH=amd64 $(GOBUILD) -o $(BUILD_DIR)/$(BINARY_LINUX) $(CMD_DIR) | ||
|
|
||
| # Build for macOS | ||
| build-darwin: | ||
| GOOS=darwin GOARCH=amd64 $(GOBUILD) -o $(BUILD_DIR)/$(BINARY_DARWIN) $(CMD_DIR) | ||
|
|
||
| # Build for Windows | ||
| build-windows: | ||
| GOOS=windows GOARCH=amd64 $(GOBUILD) -o $(BUILD_DIR)/$(BINARY_WIN) $(CMD_DIR) | ||
|
|
||
| # Build for all platforms | ||
| build-all: build-linux build-darwin build-windows | ||
|
|
||
| # Docker-related tasks | ||
| docker-build: | ||
| docker build -t bd_bot . | ||
|
|
||
| docker-run: | ||
| docker run -it --rm bd_bot | ||
|
|
||
| # CI tasks | ||
| ci: deps fmt vet test build |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| --- | ||
|
|
||
| services: | ||
| app: | ||
| build: . | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| package bot | ||
|
|
||
| import ( | ||
| "testing" | ||
| "time" | ||
|
|
||
| "5mdt/bd_bot/internal/models" | ||
| ) | ||
|
|
||
| func TestBirthdayNotificationUniqueness(t *testing.T) { | ||
| bot := &Bot{} // Create a minimal bot instance for testing | ||
|
|
||
| // Create a test birthday entry | ||
| testBirthday := models.Birthday{ | ||
| Name: "Test User", | ||
| BirthDate: time.Now().Format("01-02"), // Today's month and day | ||
| ChatID: 12345, | ||
| } | ||
|
|
||
| // Simulate first birthday notification | ||
| shouldSend := bot.shouldSendBirthdayNotification(testBirthday, "BIRTHDAY_TODAY", 0) | ||
| if !shouldSend { | ||
| t.Error("First birthday notification should be sent") | ||
| } | ||
|
|
||
| // Update last notification time to now | ||
| testBirthday.LastNotification = time.Now() | ||
|
|
||
| // Simulate second birthday notification on the same day | ||
| shouldSend = bot.shouldSendBirthdayNotification(testBirthday, "BIRTHDAY_TODAY", 0) | ||
| if shouldSend { | ||
| t.Error("Second birthday notification on the same day should not be sent") | ||
| } | ||
|
|
||
| // Simulate birthday notification on a different day | ||
| futureTime := time.Now().AddDate(0, 0, 1) | ||
| testBirthday.LastNotification = futureTime | ||
| shouldSend = bot.shouldSendBirthdayNotification(testBirthday, "BIRTHDAY_TODAY", 0) | ||
| if !shouldSend { | ||
| t.Error("Birthday notification should be sent on a different day") | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Verify that the Makefile targets are ordered correctly.
The workflow runs
make depsfollowed bymake ci. Ensure thatmake cidoesn't already runmake depsinternally, as this would result in unnecessary duplication. Ifmake ciis comprehensive (including dependency installation), consider removing the separatemake depsstep.Run the following script to check the Makefile targets:
🏁 Script executed:
Length of output: 287
Remove the duplicate
make depsstep from the workflow.The
citarget already includesdepsas a prerequisite (ci: deps fmt vet test build), so runningmake depsseparately beforemake cicauses unnecessary duplication. Remove the "Install dependencies" step (line 31-32) and keep only the "Run tests" step, which will automatically install dependencies first.🤖 Prompt for AI Agents