ci: add Gitea Actions workflow with gofmt and test jobs
CI / fmt (pull_request) Has been cancelled
CI / test (pull_request) Has been cancelled

Add CI workflow at .gitea/workflows/ci.yml triggered on pull_request
with two jobs: fmt (gofmt check) and test (go test ./...).

Fix gofmt issues (import ordering) in 7 files so CI passes from
the start.

Fixes #7

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-04-27 22:34:56 +07:00
co-authored by Claude Opus 4.7
parent bae7ad5821
commit dbe5cab56e
8 changed files with 66 additions and 37 deletions
+6 -6
View File
@@ -9,10 +9,10 @@ import (
"strings"
"time"
"gorm.io/gorm"
"thuanle.me/claw-email-bridge/internal/config"
"thuanle.me/claw-email-bridge/internal/database"
"thuanle.me/claw-email-bridge/internal/logging"
"gorm.io/gorm"
)
// Retry backoff schedule: 1s, 5s, 15s.
@@ -20,11 +20,11 @@ var retryBackoffs = []time.Duration{1 * time.Second, 5 * time.Second, 15 * time.
// openClawRequest is the payload sent to OpenClaw API.
type openClawRequest struct {
Input string `json:"input"`
SessionID string `json:"session_id"`
History []historyEntry `json:"history,omitempty"`
CallbackURL string `json:"callback_url"`
Metadata map[string]string `json:"metadata"`
Input string `json:"input"`
SessionID string `json:"session_id"`
History []historyEntry `json:"history,omitempty"`
CallbackURL string `json:"callback_url"`
Metadata map[string]string `json:"metadata"`
}
type historyEntry struct {
+3 -3
View File
@@ -130,9 +130,9 @@ func TestDispatch_UsesCallbackBaseURL(t *testing.T) {
defer mockServer.Close()
cfg := &config.Config{
OpenClawURL: mockServer.URL,
ListenAddr: ":9999",
CallbackBaseURL: "https://bridge.example.com/",
OpenClawURL: mockServer.URL,
ListenAddr: ":9999",
CallbackBaseURL: "https://bridge.example.com/",
}
task := &database.Task{
+1 -1
View File
@@ -5,9 +5,9 @@ import (
"net/http"
"github.com/gin-gonic/gin"
"gorm.io/gorm"
"thuanle.me/claw-email-bridge/internal/database"
"thuanle.me/claw-email-bridge/internal/logging"
"gorm.io/gorm"
)
// CallbackRequest is the payload received from OpenClaw.
+11 -11
View File
@@ -102,17 +102,17 @@ func defaultCallbackBaseURL(listenAddr string) string {
// validate checks that all required configuration values are present.
func (c *Config) validate() error {
required := map[string]string{
"IMAP_HOST": c.IMAPHost,
"IMAP_PORT": c.IMAPPort,
"IMAP_USER": c.IMAPUser,
"IMAP_PASS": c.IMAPPass,
"SMTP_HOST": c.SMTPHost,
"SMTP_PORT": c.SMTPPort,
"SMTP_USER": c.SMTPUser,
"SMTP_PASS": c.SMTPPass,
"OPENCLAW_URL": c.OpenClawURL,
"BRIDGE_CALLBACK_TOKEN": c.BridgeCallbackToken,
"SYSTEM_EMAIL": c.SystemEmail,
"IMAP_HOST": c.IMAPHost,
"IMAP_PORT": c.IMAPPort,
"IMAP_USER": c.IMAPUser,
"IMAP_PASS": c.IMAPPass,
"SMTP_HOST": c.SMTPHost,
"SMTP_PORT": c.SMTPPort,
"SMTP_USER": c.SMTPUser,
"SMTP_PASS": c.SMTPPass,
"OPENCLAW_URL": c.OpenClawURL,
"BRIDGE_CALLBACK_TOKEN": c.BridgeCallbackToken,
"SYSTEM_EMAIL": c.SystemEmail,
}
var missing []string
+14 -14
View File
@@ -6,28 +6,28 @@ import (
// Task status constants matching the requirement's state machine.
const (
StatusIgnored = "IGNORED"
StatusReceived = "RECEIVED"
StatusAIProcessing = "AI_PROCESSING"
StatusCallbackDone = "CALLBACK_DONE"
StatusSMTPRetrying = "SMTP_RETRYING"
StatusCompleted = "COMPLETED"
StatusFailed = "FAILED"
StatusIgnored = "IGNORED"
StatusReceived = "RECEIVED"
StatusAIProcessing = "AI_PROCESSING"
StatusCallbackDone = "CALLBACK_DONE"
StatusSMTPRetrying = "SMTP_RETRYING"
StatusCompleted = "COMPLETED"
StatusFailed = "FAILED"
)
// Task represents a single email processing unit tracked through the pipeline.
type Task struct {
ID uint `gorm:"primaryKey;autoIncrement"`
TaskUUID string `gorm:"uniqueIndex;not null"`
ThreadID string `gorm:"index"`
MessageID string `gorm:"index"`
ID uint `gorm:"primaryKey;autoIncrement"`
TaskUUID string `gorm:"uniqueIndex;not null"`
ThreadID string `gorm:"index"`
MessageID string `gorm:"index"`
Sender string
Subject string
BodyPlain string
AIResponse string
Status string `gorm:"index;not null"`
AttemptOpenClaw int `gorm:"default:0"`
AttemptSMTP int `gorm:"default:0"`
Status string `gorm:"index;not null"`
AttemptOpenClaw int `gorm:"default:0"`
AttemptSMTP int `gorm:"default:0"`
LastError *string
NextRetryAt *time.Time
CreatedAt time.Time
+1 -1
View File
@@ -17,10 +17,10 @@ import (
"github.com/emersion/go-imap/v2/imapclient"
"github.com/google/uuid"
"golang.org/x/net/proxy"
"gorm.io/gorm"
"thuanle.me/claw-email-bridge/internal/config"
"thuanle.me/claw-email-bridge/internal/database"
"thuanle.me/claw-email-bridge/internal/logging"
"gorm.io/gorm"
)
// IMAPWatcher monitors an IMAP mailbox via IDLE and processes new emails.
+1 -1
View File
@@ -6,10 +6,10 @@ import (
"strings"
"time"
"gorm.io/gorm"
"thuanle.me/claw-email-bridge/internal/config"
"thuanle.me/claw-email-bridge/internal/database"
"thuanle.me/claw-email-bridge/internal/logging"
"gorm.io/gorm"
)
// Retry backoff schedule: 1s, 5s, 15s.