You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
body: `## ⚠️ Card Image Generation Failed\n\nThe workflow was unable to generate sample playing card images. This indicates an issue with the test execution.\n\n**Debug Info**: Generated at ${new Date().toISOString()}`
commentBody += `Card generation completed but no valid cards were found.\n\n`;
183
-
}
184
-
185
-
commentBody += `\n📁 **Artifacts**: The generated files are also available as artifacts in the [Actions tab](${context.payload.repository.html_url}/actions/runs/${context.runId}).\n\n`;
186
-
commentBody += `These help reviewers visualize how the \`DisplayCard\` SwiftUI component renders different playing cards.\n\n`;
187
-
commentBody += `**Generated**: ${allFiles.length} file(s) at ${new Date().toISOString()}`;
188
-
189
-
console.log('💬 Posting PR comment with embedded images...');
190
-
191
-
// Post comment on PR
192
-
await github.rest.issues.createComment({
193
-
issue_number: context.issue.number,
194
-
owner: context.repo.owner,
195
-
repo: context.repo.repo,
196
-
body: commentBody
197
-
});
198
-
199
-
console.log('✅ Successfully posted PR comment with embedded card images');
Copy file name to clipboardExpand all lines: AGENTS.md
+38Lines changed: 38 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -198,6 +198,44 @@ Example of the transformation:
198
198
3. Simplify GitHub Actions workflows to remove complex detection logic
199
199
4. Focus on the user's actual need (images in PR comments) rather than perfect technical implementation
200
200
- Use GitHub's file URLs: `https://github.com/owner/repo/raw/branch/path/to/image.png`
201
+
202
+
## ⚠️ FAILED APPROACHES - DO NOT REPEAT
203
+
204
+
### Card Image Generation in CI (August 2025)
205
+
206
+
**FAILED FEATURE**: Automated card image generation with PR comment embedding
207
+
208
+
**What was attempted**: A CI workflow that would generate sample playing card images during PR builds and embed them in PR comments to help reviewers visualize card rendering.
209
+
210
+
**Why it failed repeatedly**:
211
+
1. **Test discovery inconsistency**: `#if canImport(SwiftUI)`conditional compilation meant tests didn't exist on some platforms, causing `swift test --filter` to succeed with 0 tests executed
212
+
2. **SwiftUI rendering fragility**: Even on macOS CI runners, SwiftUI-to-image conversion (NSHostingView, SwiftUI.ImageRenderer) failed silently in headless environments
213
+
3. **Complex fallback logic**: Multiple layers of fallback detection in GitHub Actions YAML became unmaintainable and introduced their own failure points
214
+
4. **Iteration difficulty**: Agent couldn't predict failure scenarios, leading to 15+ commits of back-and-forth fixes without resolution
215
+
216
+
**Specific technical failures**:
217
+
- NSHostingView couldn't create valid NSImage from SwiftUI views in headless CI
218
+
- SwiftUI.ImageRenderer with @MainActor annotation still failed to render
219
+
- GitHub Actions `||` fallback syntax was unreliable with proper exit code handling
220
+
- Test filter patterns failed when tests were conditionally compiled out
221
+
- Complex PNG generation fallbacks created invalid files that broke subsequent workflow steps
222
+
223
+
**Root cause**: **Over-engineering a simple problem**. The goal was just to show sample card images in PR comments, but the implementation became a complex system trying to handle every possible CI environment failure scenario.
224
+
225
+
**Lesson for future attempts**:
226
+
- **Don't attempt SwiftUI rendering in CI** - it's fundamentally unreliable in headless environments
227
+
- **Don't use conditional compilation for CI-critical tests** - tests should exist on all platforms
228
+
- **Start with the simplest possible solution** - static placeholder images may be better than complex rendering
229
+
- **Test the CI scenario locally first** - but recognize that local testing may not catch all CI environment issues
230
+
- **Have a clear "abort" criteria** - if something fails more than 3-4 iterations, the approach is likely fundamentally flawed
231
+
232
+
**Alternative approaches to consider**:
233
+
1. **Static sample images**: Pre-generated images committed to the repository
234
+
2. **Manual image updates**: Developer-generated images updated when UI changes
0 commit comments