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
62 changes: 62 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Go Build, Test, and Format

on:
push:
branches:
- main
- 'v[0-9]+.[0-9]+.[0-9]+'
pull_request:
branches:
- main
- 'v[0-9]+.[0-9]+.[0-9]+'

jobs:
build-test:
name: Build and Test on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]

steps:
- name: Checkout code
uses: actions/checkout@v4

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

- name: Build
run: go build ./...

- name: Run Tests
run: go test ./...

format:
name: Format
runs-on: ubuntu-latest
if: github.event_name == 'push' # only format on push events (not PRs from forks)

steps:
- name: Checkout code
uses: actions/checkout@v4

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

- name: Auto-format code with gofmt and commit changes
run: |
gofmt -w .
if [ -n "$(git status --porcelain)" ]; then
echo "Code was not formatted. Applying gofmt and committing changes..."
git config user.name "github-actions"
git config user.email "github-actions@github.com"
git add .
git commit -m "chore: auto-format Go code via gofmt"
git push
else
echo "Code already properly formatted."
fi
7 changes: 0 additions & 7 deletions internal/log/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ package log

import (
"context"
"fmt"
"log/slog"
"os"
"sync"
"time"

"gopkg.in/natefinch/lumberjack.v2"
)
Expand Down Expand Up @@ -103,11 +101,6 @@ func Fatal(msg string, args ...any) {
os.Exit(1)
}

// Request ID utilities
func GenerateRequestID() string {
return fmt.Sprintf("req_%d", time.Now().UnixNano())
}

type contextKey string

const requestIDKey contextKey = "request_id"
Expand Down
13 changes: 0 additions & 13 deletions internal/log/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"log/slog"
"os"
"strings"
"testing"
)

Expand Down Expand Up @@ -47,18 +46,6 @@ func TestInitialize(t *testing.T) {
}

func TestRequestIDFunctions(t *testing.T) {
t.Run("generates unique request IDs", func(t *testing.T) {
id1 := GenerateRequestID()
id2 := GenerateRequestID()

if id1 == id2 {
t.Error("IDs should be unique")
}
if !strings.HasPrefix(id1, "req_") {
t.Error("ID should have req_ prefix")
}
})

t.Run("context request ID functions", func(t *testing.T) {
ctx := ContextWithRequestID(context.Background(), "test123")
retrieved := RequestIDFromContext(ctx)
Expand Down
Loading