Skip to content

Commit 3d87d8f

Browse files
refactor : helf flag improvement & emoji cleanup
1 parent 358520d commit 3d87d8f

17 files changed

Lines changed: 1260 additions & 50 deletions

File tree

.github/workflows/release.yml

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: 🚀 Multi-Platform Release
1+
name: [RELEASE] Multi-Platform Release
22

33
on:
44
push:
@@ -12,7 +12,7 @@ permissions:
1212

1313
jobs:
1414
build:
15-
name: 🔨 Build Binaries
15+
name: [BUILD] Build Binaries
1616
runs-on: ubuntu-latest
1717
strategy:
1818
matrix:
@@ -58,19 +58,19 @@ jobs:
5858
compress: tar.gz
5959

6060
steps:
61-
- name: 📥 Checkout code
61+
- name: [DOWNLOAD] Checkout code
6262
uses: actions/checkout@v4
6363

64-
- name: 🔧 Set up Go
64+
- name: [SETUP] Set up Go
6565
uses: actions/setup-go@v5
6666
with:
6767
go-version: '1.21'
6868

69-
- name: 📊 Get version
69+
- name: [METRICS] Get version
7070
id: version
7171
run: echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
7272

73-
- name: 🏗️ Build optimized binary
73+
- name: [BUILD] Build optimized binary
7474
env:
7575
GOOS: ${{ matrix.goos }}
7676
GOARCH: ${{ matrix.goarch }}
@@ -91,7 +91,7 @@ jobs:
9191
strip ${{ matrix.name }} || true
9292
fi
9393
94-
- name: 🗜️ Compress binary
94+
- name: [COMPRESS] Compress binary
9595
run: |
9696
mkdir -p dist
9797
if [[ "${{ matrix.compress }}" == "zip" ]]; then
@@ -104,35 +104,35 @@ jobs:
104104
echo "ASSET_NAME=${{ matrix.name }}.tar.gz" >> $GITHUB_ENV
105105
fi
106106
107-
- name: 📤 Upload artifacts
107+
- name: [UPLOAD] Upload artifacts
108108
uses: actions/upload-artifact@v4
109109
with:
110110
name: ${{ matrix.name }}
111111
path: ${{ env.ASSET_PATH }}
112112
retention-days: 1
113113

114114
docker:
115-
name: 🐳 Build Docker Images
115+
name: [DOCKER] Build Docker Images
116116
runs-on: ubuntu-latest
117117
needs: build
118118
steps:
119-
- name: 📥 Checkout code
119+
- name: [DOWNLOAD] Checkout code
120120
uses: actions/checkout@v4
121121

122-
- name: 🔧 Set up QEMU
122+
- name: [SETUP] Set up QEMU
123123
uses: docker/setup-qemu-action@v3
124124

125-
- name: 🔧 Set up Docker Buildx
125+
- name: [SETUP] Set up Docker Buildx
126126
uses: docker/setup-buildx-action@v3
127127

128-
- name: 🔑 Login to GitHub Container Registry
128+
- name: [LOGIN] Login to GitHub Container Registry
129129
uses: docker/login-action@v3
130130
with:
131131
registry: ghcr.io
132132
username: ${{ github.actor }}
133133
password: ${{ secrets.GITHUB_TOKEN }}
134134

135-
- name: 📊 Extract metadata
135+
- name: [METRICS] Extract metadata
136136
id: meta
137137
uses: docker/metadata-action@v5
138138
with:
@@ -141,7 +141,7 @@ jobs:
141141
type=ref,event=tag
142142
type=raw,value=latest,enable={{is_default_branch}}
143143
144-
- name: 🏗️ Build and push Docker images
144+
- name: [BUILD] Build and push Docker images
145145
uses: docker/build-push-action@v5
146146
with:
147147
context: .
@@ -153,19 +153,19 @@ jobs:
153153
cache-to: type=gha,mode=max
154154

155155
release:
156-
name: 🎉 Create GitHub Release
156+
name: [RELEASE] Create GitHub Release
157157
runs-on: ubuntu-latest
158158
needs: [build, docker]
159159
steps:
160-
- name: 📥 Checkout code
160+
- name: [DOWNLOAD] Checkout code
161161
uses: actions/checkout@v4
162162

163-
- name: 📥 Download all artifacts
163+
- name: [DOWNLOAD] Download all artifacts
164164
uses: actions/download-artifact@v4
165165
with:
166166
path: ./artifacts
167167

168-
- name: 📋 Prepare release assets
168+
- name: [LIST] Prepare release assets
169169
run: |
170170
mkdir -p release-assets
171171
find ./artifacts -name "*.zip" -o -name "*.tar.gz" | xargs -I {} cp {} ./release-assets/
@@ -175,7 +175,7 @@ jobs:
175175
sha256sum * > checksums.txt
176176
ls -lah
177177
178-
- name: 📊 Get version and release notes
178+
- name: [METRICS] Get version and release notes
179179
id: version
180180
run: |
181181
echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
@@ -185,7 +185,7 @@ jobs:
185185
echo "release_notes=RELEASE_NOTES_v1.0.0.md" >> $GITHUB_OUTPUT
186186
fi
187187
188-
- name: 🎉 Create GitHub Release
188+
- name: [RELEASE] Create GitHub Release
189189
uses: softprops/action-gh-release@v1
190190
with:
191191
tag_name: ${{ steps.version.outputs.version }}
@@ -198,12 +198,12 @@ jobs:
198198
token: ${{ secrets.GITHUB_TOKEN }}
199199

200200
update-homebrew:
201-
name: 🍺 Update Homebrew Formula
201+
name: [HOMEBREW] Update Homebrew Formula
202202
runs-on: ubuntu-latest
203203
needs: release
204204
if: startsWith(github.ref, 'refs/tags/v')
205205
steps:
206-
- name: 🍺 Update Homebrew Formula
206+
- name: [HOMEBREW] Update Homebrew Formula
207207
uses: mislav/bump-homebrew-formula-action@v3
208208
with:
209209
formula-name: mailgrid

cli/runner.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ func Run(args CLIArgs) error {
146146
scheduleInfo += fmt.Sprintf(" using cron %q", args.Cron)
147147
}
148148

149-
fmt.Printf("📅 Job scheduled successfully%s\n", scheduleInfo)
150-
fmt.Printf("🗄️ Database: mailgrid.db\n")
149+
fmt.Printf("[SCHEDULE] Job scheduled successfully%s\n", scheduleInfo)
150+
fmt.Printf("[DATABASE] Database: mailgrid.db\n")
151151
fmt.Printf(" Metrics: http://localhost:8090/metrics\n")
152152
fmt.Printf(" The scheduler will start automatically and run in the background\n")
153153

cmd/mailgrid/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func main() {
3434

3535
// Run the mailgrid workflow (load config, parse CSV, render/send emails)
3636
if err := cli.Run(args); err != nil {
37-
log.Fatalf(" %v", err)
37+
log.Fatalf("[ERROR] %v", err)
3838
}
3939
}
4040

email/dispatcher_test.go

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
package email
2+
3+
import (
4+
"testing"
5+
)
6+
7+
func TestMaxInt(t *testing.T) {
8+
tests := []struct {
9+
name string
10+
a int
11+
b int
12+
expected int
13+
}{
14+
{
15+
name: "a greater than b",
16+
a: 10,
17+
b: 5,
18+
expected: 10,
19+
},
20+
{
21+
name: "b greater than a",
22+
a: 5,
23+
b: 10,
24+
expected: 10,
25+
},
26+
{
27+
name: "a equals b",
28+
a: 5,
29+
b: 5,
30+
expected: 5,
31+
},
32+
{
33+
name: "negative numbers",
34+
a: -10,
35+
b: -5,
36+
expected: -5,
37+
},
38+
{
39+
name: "zero and positive",
40+
a: 0,
41+
b: 5,
42+
expected: 5,
43+
},
44+
{
45+
name: "both zero",
46+
a: 0,
47+
b: 0,
48+
expected: 0,
49+
},
50+
}
51+
52+
for _, tt := range tests {
53+
t.Run(tt.name, func(t *testing.T) {
54+
result := maxInt(tt.a, tt.b)
55+
if result != tt.expected {
56+
t.Errorf("maxInt(%d, %d) = %d, expected %d", tt.a, tt.b, result, tt.expected)
57+
}
58+
})
59+
}
60+
}
61+
62+
func TestTaskStruct(t *testing.T) {
63+
task := Task{
64+
Recipient: struct {
65+
Email string
66+
Data map[string]string
67+
}{Email: "test@example.com", Data: map[string]string{"name": "Test"}},
68+
Subject: "Test Subject",
69+
Body: "Test Body",
70+
Retries: 0,
71+
Attachments: []string{"file1.pdf", "file2.pdf"},
72+
CC: []string{"cc@example.com"},
73+
BCC: []string{"bcc@example.com"},
74+
Index: 1,
75+
}
76+
77+
if task.Subject != "Test Subject" {
78+
t.Errorf("Expected Subject 'Test Subject', got '%s'", task.Subject)
79+
}
80+
81+
if task.Index != 1 {
82+
t.Errorf("Expected Index 1, got %d", task.Index)
83+
}
84+
85+
if len(task.Attachments) != 2 {
86+
t.Errorf("Expected 2 attachments, got %d", len(task.Attachments))
87+
}
88+
}
89+
90+
func TestDispatchOptionsDefaults(t *testing.T) {
91+
opts := &DispatchOptions{}
92+
93+
// Test that fields can be set
94+
opts.StartOffset = 10
95+
if opts.StartOffset != 10 {
96+
t.Errorf("Expected StartOffset 10, got %d", opts.StartOffset)
97+
}
98+
}

0 commit comments

Comments
 (0)