Skip to content

Commit cf085eb

Browse files
committed
Clone release workflow
1 parent 0d97ae2 commit cf085eb

File tree

16 files changed

+2715
-0
lines changed

16 files changed

+2715
-0
lines changed

.github/BUILD-ACTION-COMPARISON.md

Lines changed: 247 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,247 @@
1+
# Build Action Detailed Comparison
2+
# Hello Commerce vs Hello Theme
3+
4+
## Overview
5+
This document provides a line-by-line comparison of the build-theme actions from both repositories to inform the decision on which approach to use.
6+
7+
## Current Build Actions
8+
9+
### Hello Theme Build Action Features
10+
**File:** `.github/workflows/build-theme/action.yml` (120 lines)
11+
12+
#### Key Features:
13+
- **Sophisticated npm retry logic** with 3 attempts
14+
- **Multiple fallback strategies**:
15+
- Primary: `npm ci --prefer-offline`
16+
- Fallback 1: `npm install --legacy-peer-deps`
17+
- Fallback 2: Public registry explicitly
18+
- Fallback 3: Install without package-lock
19+
- **Advanced error handling** with cache clearing
20+
- **Registry fallback mechanisms**
21+
- **Detailed logging** for debugging
22+
23+
#### Build Process:
24+
```yaml
25+
- Install npm dependencies (with retry logic)
26+
- Install composer dependencies
27+
- Set package version
28+
- Run build script (npm run build:prod by default)
29+
- Create theme build directory (/tmp/hello-theme-builds)
30+
- Package theme (hello-elementor-${VERSION}.zip)
31+
- Move to workspace
32+
```
33+
34+
### Hello Commerce Build Action Features
35+
**File:** `.github/workflows/build-theme/action.yml` (68 lines)
36+
37+
#### Key Features:
38+
- **Simple npm installation** with single attempt
39+
- **Basic error handling**
40+
- **Straightforward approach**
41+
- **Minimal logging**
42+
43+
#### Build Process:
44+
```yaml
45+
- Install npm dependencies (npm ci only)
46+
- Install composer dependencies
47+
- Set package version
48+
- Run build script (npm run build by default)
49+
- Create theme build directory (/tmp/hello-commerce-builds)
50+
- Package theme (hello-commerce-${VERSION}.zip)
51+
- Move to workspace
52+
```
53+
54+
## Detailed Feature Comparison
55+
56+
| Feature | Hello Theme | Hello Commerce | Advantage |
57+
|---------|-------------|----------------|-----------|
58+
| **NPM Installation Retries** | 3 attempts with exponential backoff | 1 attempt only | 🏆 Hello Theme |
59+
| **Registry Fallbacks** | 4 different strategies | None | 🏆 Hello Theme |
60+
| **Error Handling** | Comprehensive error recovery | Basic error handling | 🏆 Hello Theme |
61+
| **Cache Management** | Automatic cache clearing on failure | None | 🏆 Hello Theme |
62+
| **Logging Detail** | Verbose logging for debugging | Minimal logging | 🏆 Hello Theme |
63+
| **Code Complexity** | 120 lines (more complex) | 68 lines (simpler) | 🏆 Hello Commerce |
64+
| **Maintenance** | More complex to maintain | Easier to maintain | 🏆 Hello Commerce |
65+
| **Build Reliability** | Higher (due to retry logic) | Lower (single attempt) | 🏆 Hello Theme |
66+
67+
## NPM Installation Logic Comparison
68+
69+
### Hello Theme Approach
70+
```yaml
71+
# Enhanced retry logic for npm ci with registry fallbacks and cache clearing
72+
for i in {1..3}; do
73+
echo "🔄 Attempt $i/3: Installing npm dependencies..."
74+
75+
# Try npm ci first
76+
if npm ci --prefer-offline --no-audit --no-fund --silent; then
77+
echo "✅ npm ci succeeded on attempt $i"
78+
break
79+
else
80+
echo "❌ npm ci failed on attempt $i"
81+
82+
# Check if it's a 403/registry error and clear cache
83+
if [ $i -lt 3 ]; then
84+
echo "🧹 Clearing npm cache to resolve potential registry issues..."
85+
npm cache clean --force 2>/dev/null || true
86+
echo "⏳ Waiting 30 seconds before retry..."
87+
sleep 30
88+
else
89+
# Multiple fallback strategies...
90+
# Fallback 1: npm install --legacy-peer-deps
91+
# Fallback 2: NPM_CONFIG_REGISTRY=https://registry.npmjs.org/
92+
# Fallback 3: Install without package-lock.json
93+
fi
94+
fi
95+
done
96+
```
97+
98+
### Hello Commerce Approach
99+
```yaml
100+
- name: Install npm dependencies
101+
shell: bash
102+
run: |
103+
export PUPPETEER_SKIP_DOWNLOAD=true
104+
npm ci
105+
```
106+
107+
## Package Creation Comparison
108+
109+
### Hello Theme
110+
```yaml
111+
# Create zip file with proper naming (following Hello Commerce pattern)
112+
zip -r "/tmp/hello-theme-builds/hello-elementor-${PACKAGE_VERSION}.zip" . \
113+
-x "node_modules/*" "test-results/*" "tests/*" ".git/*" "*.zip" \
114+
"playwright-report/*" ".wp-env.json.*" ".wp-env"
115+
```
116+
117+
### Hello Commerce
118+
```yaml
119+
# Create zip file with proper naming
120+
zip -r "/tmp/hello-commerce-builds/hello-commerce-${PACKAGE_VERSION}.zip" . \
121+
-x "node_modules/*" "test-results/*" "tests/*" ".git/*" "*.zip" \
122+
"playwright-report/*" ".wp-env.json.*" ".wp-env"
123+
```
124+
125+
**Identical exclusion patterns - no compatibility issues**
126+
127+
## Performance Analysis
128+
129+
### Hello Theme Build Action
130+
**Pros:**
131+
- ✅ High reliability due to retry logic
132+
- ✅ Handles network issues gracefully
133+
- ✅ Comprehensive error recovery
134+
- ✅ Production-tested in hello-theme repository
135+
- ✅ Better for CI/CD environments with network instability
136+
137+
**Cons:**
138+
- ❌ More complex code to maintain
139+
- ❌ Longer execution time (due to retries)
140+
- ❌ More verbose output
141+
- ❌ Higher complexity for debugging
142+
143+
### Hello Commerce Build Action
144+
**Pros:**
145+
- ✅ Simple and straightforward
146+
- ✅ Faster execution (no retries)
147+
- ✅ Easy to understand and maintain
148+
- ✅ Less verbose output
149+
150+
**Cons:**
151+
- ❌ Can fail on transient network issues
152+
- ❌ No fallback strategies
153+
- ❌ Less reliable in unstable environments
154+
- ❌ May require manual intervention on failures
155+
156+
## Recommendation Analysis
157+
158+
### Technical Recommendation: **Use Hello Theme's Build Action**
159+
160+
**Rationale:**
161+
1. **Higher Reliability** - The retry logic and fallback strategies make builds more reliable in CI/CD environments
162+
2. **Production Proven** - Already tested and working in Hello Theme production environment
163+
3. **Future Proof** - Handles edge cases that Hello Commerce might encounter as it scales
164+
4. **Error Recovery** - Automatic recovery from transient failures reduces manual intervention
165+
166+
### Adaptation Required:
167+
```yaml
168+
# Changes needed for Hello Commerce integration:
169+
1. Update temp directory: /tmp/hello-theme-builds → /tmp/hello-commerce-builds
170+
2. Update package naming: hello-elementor-${VERSION} → hello-commerce-${VERSION}
171+
3. Update default build script: npm run build:prod → npm run build
172+
```
173+
174+
## Integration Strategy
175+
176+
### Phase 1: Direct Copy with Adaptations
177+
```yaml
178+
# Copy Hello Theme's build action to Hello Commerce
179+
# Update these variables:
180+
- TEMP_DIR: "/tmp/hello-commerce-builds"
181+
- ZIP_NAME: "hello-commerce-${PACKAGE_VERSION}.zip"
182+
- DEFAULT_BUILD_SCRIPT: "npm run build"
183+
```
184+
185+
### Phase 2: Optional Enhancements
186+
```yaml
187+
# Consider these improvements:
188+
1. Make retry count configurable (input parameter)
189+
2. Add option to disable retry logic for simple builds
190+
3. Add build timing metrics
191+
4. Enhance error reporting
192+
```
193+
194+
### Phase 3: Standardization
195+
```yaml
196+
# Long term: Standardize across all theme repositories
197+
1. Create shared build action in common repository
198+
2. Use consistent naming patterns
199+
3. Share retry/fallback logic across all themes
200+
```
201+
202+
## Testing Requirements
203+
204+
### Build Action Testing Checklist
205+
- [ ] Test with Hello Commerce dependencies
206+
- [ ] Test retry logic with simulated network failures
207+
- [ ] Test fallback strategies
208+
- [ ] Verify package naming changes
209+
- [ ] Validate temp directory creation
210+
- [ ] Test with both npm ci and npm install scenarios
211+
- [ ] Verify exclusion patterns work correctly
212+
- [ ] Test error recovery mechanisms
213+
214+
### Performance Testing
215+
- [ ] Compare build times with and without retry logic
216+
- [ ] Test memory usage during build
217+
- [ ] Validate artifact size and contents
218+
- [ ] Test concurrent build scenarios
219+
220+
## Risk Assessment
221+
222+
### Low Risk Changes
223+
- ✅ Package naming updates
224+
- ✅ Temp directory path changes
225+
- ✅ Build script parameter changes
226+
227+
### Medium Risk Changes
228+
- 🟡 Retry logic integration
229+
- 🟡 Error handling adaptation
230+
- 🟡 Fallback strategy testing
231+
232+
### High Risk Areas
233+
- 🔴 NPM dependency compatibility with Hello Commerce packages
234+
- 🔴 Registry fallback behavior in Hello Commerce environment
235+
- 🔴 Build timing impact on overall workflow duration
236+
237+
## Conclusion
238+
239+
**Hello Theme's build action is superior** due to its comprehensive error handling and retry mechanisms. The additional complexity is justified by the increased reliability, especially in CI/CD environments where network issues are common.
240+
241+
**Recommended Approach:**
242+
1. **Adopt Hello Theme's build action** as the base
243+
2. **Customize** for Hello Commerce naming and paths
244+
3. **Test thoroughly** with Hello Commerce specific scenarios
245+
4. **Consider standardizing** across all theme repositories
246+
247+
This approach ensures maximum build reliability while maintaining the proven functionality that Hello Theme has already validated in production.

0 commit comments

Comments
 (0)