Skip to content

Commit 91a1512

Browse files
committed
ci: add test workflow
1 parent 1e2ad9b commit 91a1512

File tree

3 files changed

+264
-7
lines changed

3 files changed

+264
-7
lines changed
Lines changed: 257 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,257 @@
1+
name: Test GoReleaser (Manual)
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
debug:
7+
description: "Enable debug mode"
8+
required: false
9+
default: false
10+
type: boolean
11+
12+
jobs:
13+
test-goreleaser:
14+
name: Test GoReleaser Configuration (Dry Run)
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v5
19+
with:
20+
fetch-depth: 0 # Full history for changelog generation
21+
22+
- name: Set up Go
23+
uses: actions/setup-go@v5
24+
with:
25+
go-version-file: go.mod
26+
27+
- name: Cache Go modules
28+
uses: actions/cache@v4
29+
with:
30+
path: |
31+
~/.cache/go-build
32+
~/go/pkg/mod
33+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
34+
restore-keys: |
35+
${{ runner.os }}-go-
36+
37+
- name: Install dependencies
38+
run: |
39+
go mod download
40+
41+
# - name: Install GoReleaser
42+
# uses: goreleaser/goreleaser-action@v6
43+
# with:
44+
# install-only: true
45+
46+
# - name: Install system dependencies for packaging
47+
# run: |
48+
# echo "📦 Installing packaging dependencies..."
49+
50+
# # Update package lists
51+
# sudo apt-get update -qq
52+
53+
# # Install snapcraft for snap packaging
54+
# sudo snap install snapcraft --classic
55+
56+
# # Install Mono for Chocolatey CLI support
57+
# sudo apt-get install -y mono-complete
58+
59+
# # Install Nix for nix packaging
60+
# curl -L https://nixos.org/nix/install | sh -s -- --yes
61+
# . ~/.nix-profile/etc/profile.d/nix.sh
62+
63+
# # Add nix to PATH for this session
64+
# echo "$HOME/.nix-profile/bin" >> $GITHUB_PATH
65+
66+
# # Install Chocolatey CLI
67+
# TEMP_DIR=$(mktemp -d)
68+
# cd "$TEMP_DIR"
69+
# curl -sSL "https://github.com/chocolatey/choco/releases/download/2.5.0/chocolatey.v2.5.0.tar.gz" -o choco.tar.gz
70+
# tar -xzf choco.tar.gz
71+
# sudo cp choco.exe /usr/local/bin/
72+
73+
# # Create chocolatey wrapper script
74+
# sudo tee /usr/local/bin/choco > /dev/null << 'EOF'
75+
# #!/bin/bash
76+
# exec mono /usr/local/bin/choco.exe "$@"
77+
# EOF
78+
# sudo chmod +x /usr/local/bin/choco
79+
80+
# # Verify installations
81+
# echo "🔍 Verifying tool installations:"
82+
# echo "Snapcraft: $(snap --version | head -1)"
83+
# echo "Mono: $(mono --version | head -1)"
84+
# echo "Nix: $(nix --version || echo 'Not available yet')"
85+
# echo "Choco: $(choco --version || echo 'Not available')"
86+
87+
- name: Verify GoReleaser configuration
88+
run: |
89+
echo "🧪 Validating GoReleaser configuration..."
90+
go tool goreleaser check
91+
92+
# - name: Set up test environment
93+
# run: |
94+
# # Set dummy environment variables for testing
95+
# echo "Setting up test environment variables..."
96+
# echo "GITHUB_TOKEN=${{ github.token }}" >> $GITHUB_ENV
97+
# echo "CHOCOLATEY_API_KEY=dummy-for-testing" >> $GITHUB_ENV
98+
# echo "WINGET_GITHUB_TOKEN=dummy-for-testing" >> $GITHUB_ENV
99+
# echo "AUR_KEY=dummy-for-testing" >> $GITHUB_ENV
100+
101+
- name: Test GoReleaser build (with all package managers)
102+
run: |
103+
echo "🚀 Testing GoReleaser with ALL package managers enabled..."
104+
echo "This is a dry-run test with no skipping of any components."
105+
echo
106+
107+
# Enable debug mode if requested
108+
DEBUG_FLAGS=""
109+
if [[ "${{ inputs.debug }}" == "true" ]]; then
110+
DEBUG_FLAGS="--debug"
111+
echo "🐛 Debug mode enabled"
112+
fi
113+
114+
# Run GoReleaser with minimal skipping (only publish and sign)
115+
# This will test ALL package manager configurations
116+
go tool goreleaser release \
117+
--snapshot \
118+
--clean \
119+
--skip=publish \
120+
--skip=sign \
121+
--skip=validate \
122+
$DEBUG_FLAGS
123+
124+
- name: Verify generated artifacts
125+
run: |
126+
echo "📋 Checking generated artifacts..."
127+
128+
if [[ -d "dist" ]]; then
129+
echo "✅ Distribution directory created"
130+
131+
# Count different types of artifacts
132+
BINARIES=$(find dist -name "emojify*" -type f -executable | wc -l || echo "0")
133+
ARCHIVES=$(find dist -name "*.tar.gz" -o -name "*.zip" | wc -l || echo "0")
134+
CHECKSUMS=$(find dist -name "checksums.txt" | wc -l || echo "0")
135+
SNAPS=$(find dist -name "*.snap" | wc -l || echo "0")
136+
137+
echo "📊 Artifact Summary:"
138+
echo " Binaries: $BINARIES"
139+
echo " Archives: $ARCHIVES"
140+
echo " Checksums: $CHECKSUMS"
141+
echo " Snaps: $SNAPS"
142+
143+
echo ""
144+
echo "📁 Directory structure:"
145+
ls -la dist/ || echo "Cannot list dist directory"
146+
147+
echo ""
148+
echo "🏷️ Generated files (first 20):"
149+
find dist -type f | head -20 | sed 's/^/ /'
150+
151+
echo ""
152+
echo "📦 Package manager manifests:"
153+
find dist -name "*.rb" -o -name "*.json" -o -name "*.yaml" -o -name "*.yml" | head -10 | sed 's/^/ /'
154+
155+
else
156+
echo "❌ No dist directory found"
157+
exit 1
158+
fi
159+
160+
- name: Test package manager configurations
161+
run: |
162+
echo "🔍 Testing package manager configurations..."
163+
164+
# Check for Homebrew formula
165+
if find dist -name "*.rb" | grep -q .; then
166+
echo "✅ Homebrew formula generated"
167+
echo " Files:"
168+
find dist -name "*.rb" | sed 's/^/ /'
169+
else
170+
echo "❌ No Homebrew formula found"
171+
fi
172+
173+
# Check for Chocolatey packages
174+
if find dist -name "*chocolatey*" | grep -q .; then
175+
echo "✅ Chocolatey package files generated"
176+
echo " Files:"
177+
find dist -name "*chocolatey*" | sed 's/^/ /'
178+
else
179+
echo "⚠️ No Chocolatey package files found"
180+
fi
181+
182+
# Check for WinGet manifests
183+
if find dist -name "*winget*" | grep -q .; then
184+
echo "✅ WinGet manifest generated"
185+
echo " Files:"
186+
find dist -name "*winget*" | sed 's/^/ /'
187+
else
188+
echo "⚠️ No WinGet manifest found"
189+
fi
190+
191+
# Check for AUR packages
192+
if find dist -name "*aur*" | grep -q .; then
193+
echo "✅ AUR package generated"
194+
echo " Files:"
195+
find dist -name "*aur*" | sed 's/^/ /'
196+
else
197+
echo "⚠️ No AUR package found"
198+
fi
199+
200+
# Check for Scoop manifests
201+
if find dist -name "*scoop*" | grep -q .; then
202+
echo "✅ Scoop manifest generated"
203+
echo " Files:"
204+
find dist -name "*scoop*" | sed 's/^/ /'
205+
else
206+
echo "⚠️ No Scoop manifest found"
207+
fi
208+
209+
# Check for Nix packages
210+
if find dist -name "*nix*" | grep -q .; then
211+
echo "✅ Nix package generated"
212+
echo " Files:"
213+
find dist -name "*nix*" | sed 's/^/ /'
214+
else
215+
echo "⚠️ No Nix package found"
216+
fi
217+
218+
# Check for Snap packages
219+
if find dist -name "*.snap" | grep -q .; then
220+
echo "✅ Snap package generated"
221+
echo " Files:"
222+
find dist -name "*.snap" | sed 's/^/ /'
223+
else
224+
echo "⚠️ No Snap package found"
225+
fi
226+
227+
- name: Show detailed logs on failure
228+
if: failure()
229+
run: |
230+
echo "❌ GoReleaser test failed!"
231+
echo ""
232+
echo "🔍 Debugging information:"
233+
echo "Working directory: $(pwd)"
234+
echo "Available tools:"
235+
echo " - GoReleaser: $(go tool goreleaser --version)"
236+
echo " - Go: $(go version)"
237+
echo " - Git: $(git --version)"
238+
echo " - Snapcraft: $(snapcraft --version 2>/dev/null || echo 'Not available')"
239+
echo " - Mono: $(mono --version 2>/dev/null | head -1 || echo 'Not available')"
240+
echo " - Nix: $(nix --version 2>/dev/null || echo 'Not available')"
241+
echo " - Choco: $(choco --version 2>/dev/null || echo 'Not available')"
242+
echo ""
243+
echo "Environment variables:"
244+
env | grep -E "(GITHUB|CHOCOLATEY|WINGET|AUR)" | sed 's/^/ /'
245+
echo ""
246+
echo "Current directory contents:"
247+
ls -la
248+
249+
- name: Upload test artifacts
250+
if: always()
251+
uses: actions/upload-artifact@v4
252+
with:
253+
name: goreleaser-test-artifacts
254+
path: |
255+
dist/
256+
RELEASE_NOTES.md
257+
retention-days: 7

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ dev: clean build run
416416
.PHONY: goreleaser-check
417417
goreleaser-check:
418418
@echo "🔍 Checking GoReleaser configuration..."
419-
@goreleaser check || echo "⚠️ goreleaser not found"
419+
@go tool goreleaser check || echo "⚠️ goreleaser not found"
420420

421421
.PHONY: goreleaser-test
422422
goreleaser-test:
@@ -426,14 +426,14 @@ goreleaser-test:
426426
.PHONY: goreleaser-build
427427
goreleaser-build:
428428
@echo "🔨 Building with GoReleaser..."
429-
@goreleaser build --snapshot --clean || echo "⚠️ goreleaser not found"
429+
@go tool goreleaser build --snapshot --clean || echo "⚠️ goreleaser not found"
430430

431431
.PHONY: goreleaser-test-release-notes
432432
goreleaser-test-release-notes:
433433
@echo "📝 Testing release notes generation..."
434434
@if [ -z "$(VERSION)" ]; then echo "⚠️ VERSION is required. Usage: make goreleaser-test-release-notes VERSION=v1.0.0"; exit 1; fi
435435
@echo "📋 Generating release notes for $(VERSION)..."
436-
@git-chglog --tag-filter-pattern $(VERSION) --output RELEASE_NOTES.md $(VERSION)
436+
@go tool git-chglog --tag-filter-pattern $(VERSION) --output RELEASE_NOTES.md $(VERSION)
437437
@echo "✅ Release notes generated: RELEASE_NOTES.md"
438438
@echo "📄 Content preview:"
439439
@head -20 RELEASE_NOTES.md
@@ -443,8 +443,8 @@ goreleaser-release:
443443
@echo "🚀 Creating release with GoReleaser..."
444444
@if [ -z "$(VERSION)" ]; then echo "⚠️ VERSION is required. Usage: make goreleaser-release VERSION=v1.0.0"; exit 1; fi
445445
@echo "📝 Generating release notes for $(VERSION)..."
446-
@git-chglog --tag-filter-pattern $(VERSION) --output RELEASE_NOTES.md $(VERSION)
447-
@goreleaser release --clean --release-notes RELEASE_NOTES.md || echo "⚠️ goreleaser not found"
446+
@go tool git-chglog --tag-filter-pattern $(VERSION) --output RELEASE_NOTES.md $(VERSION)
447+
@go tool goreleaser release --clean --release-notes RELEASE_NOTES.md || echo "⚠️ goreleaser not found"
448448

449449
.PHONY: goreleaser-release-with-changelog
450450
goreleaser-release-with-changelog:

scripts/test-goreleaser.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ print_error() {
3434

3535
# 1. Configuration validation
3636
print_status "1. Validating GoReleaser configuration..."
37-
if goreleaser check 2>/dev/null; then
37+
if go tool goreleaser check 2>/dev/null; then
3838
print_success "Configuration is valid"
3939
else
4040
echo " Checking with warnings..."
41-
goreleaser check || {
41+
go tool goreleaser check || {
4242
if [[ $? -eq 2 ]]; then
4343
print_warning "Configuration valid but has deprecation warnings"
4444
else

0 commit comments

Comments
 (0)