jekyll-theme-zer0 0.8.1 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +201 -4
- data/README.md +58 -25
- data/_data/README.md +4 -5
- data/_includes/README.md +1 -1
- data/_includes/stats/README.md +14 -2
- data/_layouts/README.md +3 -3
- data/_sass/core/_theme.scss +4 -1
- data/scripts/bin/build +115 -0
- data/scripts/bin/release +240 -0
- data/scripts/bin/test +203 -0
- data/scripts/features/generate-preview-images +846 -0
- data/scripts/features/install-preview-generator +531 -0
- data/scripts/features/preview_generator.py +646 -0
- data/scripts/generate-preview-images.sh +38 -93
- data/scripts/lib/README.md +35 -7
- data/scripts/test/integration/auto-version +243 -0
- data/scripts/test/integration/mermaid +252 -0
- data/scripts/test/lib/run_tests.sh +151 -0
- data/scripts/test/lib/test_changelog.sh +90 -0
- data/scripts/test/lib/test_gem.sh +71 -0
- data/scripts/test/lib/test_git.sh +85 -0
- data/scripts/test/lib/test_validation.sh +75 -0
- data/scripts/test/lib/test_version.sh +101 -0
- data/scripts/test/theme/validate +120 -0
- data/scripts/utils/analyze-commits +300 -0
- data/scripts/utils/fix-markdown +251 -0
- data/scripts/utils/setup +137 -0
- data/scripts/version.sh +26 -0
- metadata +20 -8
- data/scripts/build.sh +0 -33
- data/scripts/build.sh.legacy +0 -174
- data/scripts/gem-publish.sh +0 -42
- data/scripts/gem-publish.sh.legacy +0 -700
- data/scripts/release.sh +0 -33
- data/scripts/release.sh.legacy +0 -342
|
@@ -79,13 +79,6 @@ else
|
|
|
79
79
|
warn() { echo -e "${YELLOW}[WARNING]${NC} $1"; }
|
|
80
80
|
error() { echo -e "${RED}[ERROR]${NC} $1" >&2; exit 1; }
|
|
81
81
|
debug() { [[ "${VERBOSE:-false}" == "true" ]] && echo -e "${PURPLE}[DEBUG]${NC} $1" >&2 || true; }
|
|
82
|
-
print_header() {
|
|
83
|
-
echo ""
|
|
84
|
-
echo -e "${CYAN}════════════════════════════════════════════════════════════════${NC}"
|
|
85
|
-
echo -e " ${GREEN}$1${NC}"
|
|
86
|
-
echo -e "${CYAN}════════════════════════════════════════════════════════════════${NC}"
|
|
87
|
-
echo ""
|
|
88
|
-
}
|
|
89
82
|
fi
|
|
90
83
|
|
|
91
84
|
# =============================================================================
|
|
@@ -577,35 +570,27 @@ update_front_matter() {
|
|
|
577
570
|
# Create backup
|
|
578
571
|
cp "$file" "$file.bak"
|
|
579
572
|
|
|
580
|
-
# Always use sed for reliability (yq can fail on complex YAML)
|
|
581
573
|
# Check if preview field exists
|
|
582
574
|
if grep -q "^preview:" "$file"; then
|
|
583
|
-
# Update existing preview field
|
|
584
|
-
if [[ "$
|
|
585
|
-
#
|
|
586
|
-
|
|
575
|
+
# Update existing preview field
|
|
576
|
+
if [[ "$YAML_PARSER" == "yq" ]]; then
|
|
577
|
+
# Use yq for in-place update
|
|
578
|
+
yq -i ".preview = \"$preview_path\"" "$file"
|
|
587
579
|
else
|
|
588
|
-
sed
|
|
580
|
+
# Use sed for simple replacement
|
|
581
|
+
sed -i.tmp "s|^preview:.*|preview: $preview_path|" "$file"
|
|
582
|
+
rm -f "$file.tmp"
|
|
589
583
|
fi
|
|
590
584
|
else
|
|
591
585
|
# Add preview field after description or title
|
|
592
586
|
if grep -q "^description:" "$file"; then
|
|
593
|
-
|
|
594
|
-
sed -i '' "/^description:/a\\
|
|
595
|
-
preview: $preview_path" "$file"
|
|
596
|
-
else
|
|
597
|
-
sed -i "/^description:/a\\
|
|
587
|
+
sed -i.tmp "/^description:/a\\
|
|
598
588
|
preview: $preview_path" "$file"
|
|
599
|
-
fi
|
|
600
589
|
else
|
|
601
|
-
|
|
602
|
-
sed -i '' "/^title:/a\\
|
|
603
|
-
preview: $preview_path" "$file"
|
|
604
|
-
else
|
|
605
|
-
sed -i "/^title:/a\\
|
|
590
|
+
sed -i.tmp "/^title:/a\\
|
|
606
591
|
preview: $preview_path" "$file"
|
|
607
|
-
fi
|
|
608
592
|
fi
|
|
593
|
+
rm -f "$file.tmp"
|
|
609
594
|
fi
|
|
610
595
|
|
|
611
596
|
# Remove backup on success
|
|
@@ -740,54 +725,6 @@ main() {
|
|
|
740
725
|
echo " List Only: $LIST_ONLY"
|
|
741
726
|
echo ""
|
|
742
727
|
|
|
743
|
-
# Get configured collections from _config.yml
|
|
744
|
-
get_configured_collections() {
|
|
745
|
-
local collections=()
|
|
746
|
-
local in_preview_images=false
|
|
747
|
-
local in_collections=false
|
|
748
|
-
|
|
749
|
-
while IFS= read -r line; do
|
|
750
|
-
if [[ "$line" =~ ^preview_images: ]]; then
|
|
751
|
-
in_preview_images=true
|
|
752
|
-
continue
|
|
753
|
-
fi
|
|
754
|
-
if [[ "$in_preview_images" == true && "$line" =~ ^[[:space:]]+collections: ]]; then
|
|
755
|
-
in_collections=true
|
|
756
|
-
continue
|
|
757
|
-
fi
|
|
758
|
-
if [[ "$in_collections" == true && "$line" =~ ^[[:space:]]+- ]]; then
|
|
759
|
-
local collection="${line#*- }"
|
|
760
|
-
collection="${collection%%#*}"
|
|
761
|
-
collection="${collection%"${collection##*[![:space:]]}"}"
|
|
762
|
-
collections+=("$collection")
|
|
763
|
-
elif [[ "$in_collections" == true && ! "$line" =~ ^[[:space:]]+- && ! "$line" =~ ^[[:space:]]*$ ]]; then
|
|
764
|
-
break
|
|
765
|
-
fi
|
|
766
|
-
if [[ "$in_preview_images" == true && "$line" =~ ^[a-zA-Z_]+: && ! "$line" =~ ^[[:space:]] ]]; then
|
|
767
|
-
break
|
|
768
|
-
fi
|
|
769
|
-
done < "$CONFIG_FILE"
|
|
770
|
-
|
|
771
|
-
if [[ ${#collections[@]} -eq 0 ]]; then
|
|
772
|
-
collections=("posts" "quickstart" "docs")
|
|
773
|
-
fi
|
|
774
|
-
|
|
775
|
-
echo "${collections[@]}"
|
|
776
|
-
}
|
|
777
|
-
|
|
778
|
-
# Process a collection by name
|
|
779
|
-
process_collection_by_name() {
|
|
780
|
-
local name="$1"
|
|
781
|
-
local path="$PROJECT_ROOT/pages/_${name}"
|
|
782
|
-
|
|
783
|
-
if [[ -d "$path" ]]; then
|
|
784
|
-
step "Processing ${name} collection..."
|
|
785
|
-
process_collection "$path"
|
|
786
|
-
else
|
|
787
|
-
warn "Collection directory not found: $path"
|
|
788
|
-
fi
|
|
789
|
-
}
|
|
790
|
-
|
|
791
728
|
# Process files
|
|
792
729
|
if [[ -n "$SPECIFIC_FILE" ]]; then
|
|
793
730
|
# Process single file
|
|
@@ -797,27 +734,35 @@ main() {
|
|
|
797
734
|
process_file "$PROJECT_ROOT/$SPECIFIC_FILE"
|
|
798
735
|
elif [[ -n "$COLLECTION" ]]; then
|
|
799
736
|
# Process specific collection
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
737
|
+
case "$COLLECTION" in
|
|
738
|
+
posts)
|
|
739
|
+
step "Processing posts collection..."
|
|
740
|
+
process_collection "$PROJECT_ROOT/pages/_posts"
|
|
741
|
+
;;
|
|
742
|
+
quickstart)
|
|
743
|
+
step "Processing quickstart collection..."
|
|
744
|
+
process_collection "$PROJECT_ROOT/pages/_quickstart"
|
|
745
|
+
;;
|
|
746
|
+
docs)
|
|
747
|
+
step "Processing docs collection..."
|
|
748
|
+
process_collection "$PROJECT_ROOT/pages/_docs"
|
|
749
|
+
;;
|
|
750
|
+
all)
|
|
751
|
+
step "Processing all collections..."
|
|
752
|
+
process_collection "$PROJECT_ROOT/pages/_posts"
|
|
753
|
+
process_collection "$PROJECT_ROOT/pages/_quickstart"
|
|
754
|
+
process_collection "$PROJECT_ROOT/pages/_docs"
|
|
755
|
+
;;
|
|
756
|
+
*)
|
|
757
|
+
error "Unknown collection: $COLLECTION. Use: posts, quickstart, docs, or all"
|
|
758
|
+
;;
|
|
759
|
+
esac
|
|
815
760
|
else
|
|
816
|
-
# Process all
|
|
817
|
-
step "Processing all
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
761
|
+
# Process all content by default
|
|
762
|
+
step "Processing all content collections..."
|
|
763
|
+
process_collection "$PROJECT_ROOT/pages/_posts"
|
|
764
|
+
process_collection "$PROJECT_ROOT/pages/_quickstart"
|
|
765
|
+
process_collection "$PROJECT_ROOT/pages/_docs"
|
|
821
766
|
fi
|
|
822
767
|
|
|
823
768
|
# Print summary
|
data/scripts/lib/README.md
CHANGED
|
@@ -9,9 +9,11 @@ This directory contains focused, single-responsibility libraries that power the
|
|
|
9
9
|
## Libraries
|
|
10
10
|
|
|
11
11
|
### 📦 `common.sh` - Shared Utilities
|
|
12
|
+
|
|
12
13
|
Core utilities used by all other libraries.
|
|
13
14
|
|
|
14
15
|
**Functions:**
|
|
16
|
+
|
|
15
17
|
- `log()`, `info()`, `warn()`, `error()` - Colored logging
|
|
16
18
|
- `confirm()` - User confirmation prompts
|
|
17
19
|
- `dry_run_exec()` - Dry run wrapper for commands
|
|
@@ -19,15 +21,18 @@ Core utilities used by all other libraries.
|
|
|
19
21
|
- `get_repo_root()` - Find repository root directory
|
|
20
22
|
|
|
21
23
|
**Usage:**
|
|
24
|
+
|
|
22
25
|
```bash
|
|
23
26
|
source "$(dirname "$0")/lib/common.sh"
|
|
24
27
|
log "Starting process..."
|
|
25
28
|
```
|
|
26
29
|
|
|
27
30
|
### 🔍 `validation.sh` - Environment Validation
|
|
31
|
+
|
|
28
32
|
Validates environment, dependencies, and prerequisites.
|
|
29
33
|
|
|
30
34
|
**Functions:**
|
|
35
|
+
|
|
31
36
|
- `validate_git_repo()` - Verify git repository
|
|
32
37
|
- `validate_clean_working_dir()` - Check for uncommitted changes
|
|
33
38
|
- `validate_required_files()` - Check required files exist
|
|
@@ -36,15 +41,18 @@ Validates environment, dependencies, and prerequisites.
|
|
|
36
41
|
- `validate_environment()` - Comprehensive validation
|
|
37
42
|
|
|
38
43
|
**Usage:**
|
|
44
|
+
|
|
39
45
|
```bash
|
|
40
46
|
source "$(dirname "$0")/lib/validation.sh"
|
|
41
47
|
validate_environment false false # skip_publish=false, require_gh=false
|
|
42
48
|
```
|
|
43
49
|
|
|
44
50
|
### 📝 `version.sh` - Version Management
|
|
51
|
+
|
|
45
52
|
Read, calculate, and update semantic versions.
|
|
46
53
|
|
|
47
54
|
**Functions:**
|
|
55
|
+
|
|
48
56
|
- `get_current_version()` - Read version from version.rb
|
|
49
57
|
- `calculate_new_version()` - Calculate new version (major/minor/patch)
|
|
50
58
|
- `update_version_files()` - Update all version files
|
|
@@ -52,6 +60,7 @@ Read, calculate, and update semantic versions.
|
|
|
52
60
|
- `version_less_than()` - Compare two versions
|
|
53
61
|
|
|
54
62
|
**Usage:**
|
|
63
|
+
|
|
55
64
|
```bash
|
|
56
65
|
source "$(dirname "$0")/lib/version.sh"
|
|
57
66
|
|
|
@@ -61,15 +70,18 @@ update_version_files "$new"
|
|
|
61
70
|
```
|
|
62
71
|
|
|
63
72
|
### 📋 `changelog.sh` - Changelog Generation
|
|
73
|
+
|
|
64
74
|
Generate changelogs from conventional commits.
|
|
65
75
|
|
|
66
76
|
**Functions:**
|
|
77
|
+
|
|
67
78
|
- `generate_changelog()` - Generate changelog for version
|
|
68
79
|
- `categorize_commit()` - Categorize commit by type
|
|
69
80
|
- `clean_commit_message()` - Clean conventional commit prefixes
|
|
70
81
|
- `extract_release_notes()` - Extract notes for specific version
|
|
71
82
|
|
|
72
83
|
**Commit Categories:**
|
|
84
|
+
|
|
73
85
|
- `feat:` → Added
|
|
74
86
|
- `fix:` → Fixed
|
|
75
87
|
- `BREAKING:` → Breaking Changes
|
|
@@ -78,6 +90,7 @@ Generate changelogs from conventional commits.
|
|
|
78
90
|
- `security:` → Security
|
|
79
91
|
|
|
80
92
|
**Usage:**
|
|
93
|
+
|
|
81
94
|
```bash
|
|
82
95
|
source "$(dirname "$0")/lib/changelog.sh"
|
|
83
96
|
|
|
@@ -85,9 +98,11 @@ generate_changelog "1.2.0" "v1.1.0" "HEAD"
|
|
|
85
98
|
```
|
|
86
99
|
|
|
87
100
|
### 🔄 `git.sh` - Git Operations
|
|
101
|
+
|
|
88
102
|
Git commits, tags, and repository operations.
|
|
89
103
|
|
|
90
104
|
**Functions:**
|
|
105
|
+
|
|
91
106
|
- `get_last_version_tag()` - Find last version tag
|
|
92
107
|
- `commit_and_tag()` - Create release commit and tag
|
|
93
108
|
- `push_changes()` - Push to remote with tags
|
|
@@ -95,6 +110,7 @@ Git commits, tags, and repository operations.
|
|
|
95
110
|
- `get_repo_info()` - Extract owner/repo from URL
|
|
96
111
|
|
|
97
112
|
**Usage:**
|
|
113
|
+
|
|
98
114
|
```bash
|
|
99
115
|
source "$(dirname "$0")/lib/git.sh"
|
|
100
116
|
|
|
@@ -103,9 +119,11 @@ push_changes "origin" "main"
|
|
|
103
119
|
```
|
|
104
120
|
|
|
105
121
|
### 💎 `gem.sh` - Gem Operations
|
|
122
|
+
|
|
106
123
|
Build, test, publish, and release gems.
|
|
107
124
|
|
|
108
125
|
**Functions:**
|
|
126
|
+
|
|
109
127
|
- `build_gem()` - Build the gem package
|
|
110
128
|
- `publish_gem()` - Publish to RubyGems
|
|
111
129
|
- `create_github_release()` - Create GitHub release
|
|
@@ -113,6 +131,7 @@ Build, test, publish, and release gems.
|
|
|
113
131
|
- `gem_version_exists()` - Check if version exists on RubyGems
|
|
114
132
|
|
|
115
133
|
**Usage:**
|
|
134
|
+
|
|
116
135
|
```bash
|
|
117
136
|
source "$(dirname "$0")/lib/gem.sh"
|
|
118
137
|
|
|
@@ -127,11 +146,13 @@ create_github_release "1.2.0"
|
|
|
127
146
|
Each library has comprehensive unit tests in `test/`.
|
|
128
147
|
|
|
129
148
|
### Run All Tests
|
|
149
|
+
|
|
130
150
|
```bash
|
|
131
151
|
./scripts/lib/test/run_tests.sh
|
|
132
152
|
```
|
|
133
153
|
|
|
134
154
|
### Run Individual Tests
|
|
155
|
+
|
|
135
156
|
```bash
|
|
136
157
|
./scripts/lib/test/test_version.sh
|
|
137
158
|
./scripts/lib/test/test_changelog.sh
|
|
@@ -139,6 +160,7 @@ Each library has comprehensive unit tests in `test/`.
|
|
|
139
160
|
```
|
|
140
161
|
|
|
141
162
|
### Test Coverage
|
|
163
|
+
|
|
142
164
|
- ✅ Version calculations and validation
|
|
143
165
|
- ✅ Changelog generation and categorization
|
|
144
166
|
- ✅ Git operations and tag management
|
|
@@ -178,30 +200,30 @@ source "$LIB_DIR/gem.sh"
|
|
|
178
200
|
# Main workflow
|
|
179
201
|
main() {
|
|
180
202
|
print_header "Custom Release"
|
|
181
|
-
|
|
203
|
+
|
|
182
204
|
# Validate
|
|
183
205
|
validate_environment
|
|
184
|
-
|
|
206
|
+
|
|
185
207
|
# Version
|
|
186
208
|
local current=$(get_current_version)
|
|
187
209
|
local new=$(calculate_new_version "$current" "patch")
|
|
188
210
|
update_version_files "$new"
|
|
189
|
-
|
|
211
|
+
|
|
190
212
|
# Changelog
|
|
191
213
|
generate_changelog "$new"
|
|
192
|
-
|
|
214
|
+
|
|
193
215
|
# Build & Test
|
|
194
216
|
build_gem "$new"
|
|
195
217
|
run_tests
|
|
196
|
-
|
|
218
|
+
|
|
197
219
|
# Commit & Tag
|
|
198
220
|
commit_and_tag "$new"
|
|
199
|
-
|
|
221
|
+
|
|
200
222
|
# Publish
|
|
201
223
|
publish_gem "$new"
|
|
202
224
|
create_github_release "$new"
|
|
203
225
|
push_changes
|
|
204
|
-
|
|
226
|
+
|
|
205
227
|
success "Release $new complete!"
|
|
206
228
|
}
|
|
207
229
|
|
|
@@ -211,18 +233,23 @@ main "$@"
|
|
|
211
233
|
## Architecture Benefits
|
|
212
234
|
|
|
213
235
|
### ✅ Modularity
|
|
236
|
+
|
|
214
237
|
Each library has ONE responsibility - easy to understand and modify.
|
|
215
238
|
|
|
216
239
|
### ✅ Testability
|
|
240
|
+
|
|
217
241
|
Small, focused functions can be unit tested independently.
|
|
218
242
|
|
|
219
243
|
### ✅ Reusability
|
|
244
|
+
|
|
220
245
|
Libraries can be used in different scripts or GitHub Actions.
|
|
221
246
|
|
|
222
247
|
### ✅ Maintainability
|
|
248
|
+
|
|
223
249
|
Changes isolated to specific files - less ripple effect.
|
|
224
250
|
|
|
225
251
|
### ✅ Clarity
|
|
252
|
+
|
|
226
253
|
Functions have clear names and single purposes.
|
|
227
254
|
|
|
228
255
|
## Migrating Old Scripts
|
|
@@ -234,6 +261,7 @@ Old monolithic scripts (`gem-publish.sh`, `release.sh`, `build.sh`) can now be:
|
|
|
234
261
|
3. **Removed** once adoption is confirmed
|
|
235
262
|
|
|
236
263
|
Example deprecation wrapper:
|
|
264
|
+
|
|
237
265
|
```bash
|
|
238
266
|
#!/bin/bash
|
|
239
267
|
echo "⚠️ WARNING: This script is deprecated"
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Test Script for Automated Version Bump System
|
|
4
|
+
# Tests the commit analysis and version bump automation
|
|
5
|
+
# Usage: ./scripts/test/integration/auto-version
|
|
6
|
+
|
|
7
|
+
set -euo pipefail
|
|
8
|
+
|
|
9
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
10
|
+
SCRIPTS_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
|
11
|
+
PROJECT_ROOT="$(cd "$SCRIPTS_ROOT/.." && pwd)"
|
|
12
|
+
LIB_DIR="$SCRIPTS_ROOT/lib"
|
|
13
|
+
|
|
14
|
+
# Source common library for logging and utilities
|
|
15
|
+
source "$LIB_DIR/common.sh"
|
|
16
|
+
|
|
17
|
+
# Aliases for backward compatibility
|
|
18
|
+
log_info() { info "$@"; }
|
|
19
|
+
log_success() { success "$@"; }
|
|
20
|
+
log_warning() { warn "$@"; }
|
|
21
|
+
log_error() { error "$@"; }
|
|
22
|
+
log_test() { step "$@"; }
|
|
23
|
+
|
|
24
|
+
# Test counter
|
|
25
|
+
TESTS_RUN=0
|
|
26
|
+
TESTS_PASSED=0
|
|
27
|
+
|
|
28
|
+
run_test() {
|
|
29
|
+
local test_name="$1"
|
|
30
|
+
local test_command="$2"
|
|
31
|
+
local expected_result="${3:-}"
|
|
32
|
+
|
|
33
|
+
((TESTS_RUN++))
|
|
34
|
+
log_test "Running: $test_name"
|
|
35
|
+
|
|
36
|
+
local actual_result
|
|
37
|
+
if actual_result=$(eval "$test_command" 2>&1); then
|
|
38
|
+
if [[ -n "$expected_result" ]]; then
|
|
39
|
+
if [[ "$actual_result" == "$expected_result" ]]; then
|
|
40
|
+
log_success "✅ $test_name"
|
|
41
|
+
((TESTS_PASSED++))
|
|
42
|
+
else
|
|
43
|
+
log_error "❌ $test_name - Expected: '$expected_result', Got: '$actual_result'"
|
|
44
|
+
fi
|
|
45
|
+
else
|
|
46
|
+
log_success "✅ $test_name"
|
|
47
|
+
((TESTS_PASSED++))
|
|
48
|
+
fi
|
|
49
|
+
else
|
|
50
|
+
log_error "❌ $test_name - Command failed: $actual_result"
|
|
51
|
+
fi
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
# Test the commit analysis script
|
|
55
|
+
test_commit_analysis() {
|
|
56
|
+
log_info "Testing commit analysis functionality..."
|
|
57
|
+
|
|
58
|
+
# Test script exists and is executable
|
|
59
|
+
run_test "Commit analysis script exists" "test -x '$SCRIPT_DIR/analyze-commits.sh'"
|
|
60
|
+
|
|
61
|
+
# Test help output
|
|
62
|
+
run_test "Help output works" "$SCRIPT_DIR/analyze-commits.sh --help | grep -q 'Commit Analysis Script'"
|
|
63
|
+
|
|
64
|
+
# Test with sample commit ranges (if we have git history)
|
|
65
|
+
if git rev-list --count HEAD >/dev/null 2>&1; then
|
|
66
|
+
local commit_count=$(git rev-list --count HEAD)
|
|
67
|
+
|
|
68
|
+
if [[ $commit_count -gt 1 ]]; then
|
|
69
|
+
# Test analyzing last commit
|
|
70
|
+
run_test "Analyze last commit" "$SCRIPT_DIR/analyze-commits.sh HEAD~1..HEAD | grep -E '^(patch|minor|major|none)$'"
|
|
71
|
+
|
|
72
|
+
# Test analyzing multiple commits if available
|
|
73
|
+
if [[ $commit_count -gt 3 ]]; then
|
|
74
|
+
run_test "Analyze multiple commits" "$SCRIPT_DIR/analyze-commits.sh HEAD~3..HEAD | grep -E '^(patch|minor|major|none)$'"
|
|
75
|
+
fi
|
|
76
|
+
fi
|
|
77
|
+
else
|
|
78
|
+
log_warning "No git history available for commit analysis tests"
|
|
79
|
+
fi
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
# Test gem publication script compatibility
|
|
83
|
+
test_gem_publish_script() {
|
|
84
|
+
log_info "Testing gem publication script compatibility..."
|
|
85
|
+
|
|
86
|
+
# Test script exists and is executable
|
|
87
|
+
run_test "Gem publish script exists" "test -x '$SCRIPT_DIR/gem-publish.sh'"
|
|
88
|
+
|
|
89
|
+
# Test new automated options
|
|
90
|
+
run_test "Automated release option works" "$SCRIPT_DIR/gem-publish.sh --help | grep -q 'automated-release'"
|
|
91
|
+
run_test "Auto commit range option works" "$SCRIPT_DIR/gem-publish.sh --help | grep -q 'auto-commit-range'"
|
|
92
|
+
|
|
93
|
+
# Test dry run with automated options
|
|
94
|
+
if [[ -f "$PROJECT_ROOT/lib/jekyll-theme-zer0/version.rb" ]]; then
|
|
95
|
+
run_test "Dry run with automated options" "$SCRIPT_DIR/gem-publish.sh patch --dry-run --automated-release --skip-tests --skip-publish --no-github-release | grep -q 'Automated Release Mode'"
|
|
96
|
+
fi
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
# Test workflow files syntax
|
|
100
|
+
test_workflow_syntax() {
|
|
101
|
+
log_info "Testing GitHub Actions workflow syntax..."
|
|
102
|
+
|
|
103
|
+
# Check if yamllint is available
|
|
104
|
+
if command -v yamllint >/dev/null 2>&1; then
|
|
105
|
+
run_test "Auto-version-bump workflow syntax" "yamllint '$PROJECT_ROOT/.github/workflows/auto-version-bump.yml'"
|
|
106
|
+
else
|
|
107
|
+
# Basic YAML syntax check with Python
|
|
108
|
+
if command -v python3 >/dev/null 2>&1; then
|
|
109
|
+
run_test "Auto-version-bump workflow syntax" "python3 -c 'import yaml; yaml.safe_load(open(\"$PROJECT_ROOT/.github/workflows/auto-version-bump.yml\"))'"
|
|
110
|
+
else
|
|
111
|
+
log_warning "Neither yamllint nor python3 available for YAML validation"
|
|
112
|
+
fi
|
|
113
|
+
fi
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
# Test file permissions and executability
|
|
117
|
+
test_file_permissions() {
|
|
118
|
+
log_info "Testing file permissions..."
|
|
119
|
+
|
|
120
|
+
local scripts=(
|
|
121
|
+
"$SCRIPT_DIR/analyze-commits.sh"
|
|
122
|
+
"$SCRIPT_DIR/gem-publish.sh"
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
for script in "${scripts[@]}"; do
|
|
126
|
+
local script_name=$(basename "$script")
|
|
127
|
+
run_test "$script_name is executable" "test -x '$script'"
|
|
128
|
+
done
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
# Test integration between components
|
|
132
|
+
test_integration() {
|
|
133
|
+
log_info "Testing integration between components..."
|
|
134
|
+
|
|
135
|
+
# Test that analyze-commits.sh can be called by the workflow
|
|
136
|
+
if [[ -x "$SCRIPT_DIR/analyze-commits.sh" ]]; then
|
|
137
|
+
# Test with a simple commit range
|
|
138
|
+
if git rev-list --count HEAD >/dev/null 2>&1; then
|
|
139
|
+
local commit_count=$(git rev-list --count HEAD)
|
|
140
|
+
if [[ $commit_count -gt 0 ]]; then
|
|
141
|
+
run_test "Integration: commit analysis returns valid output" "$SCRIPT_DIR/analyze-commits.sh HEAD~1..HEAD | grep -E '^(patch|minor|major|none)$'"
|
|
142
|
+
fi
|
|
143
|
+
fi
|
|
144
|
+
fi
|
|
145
|
+
|
|
146
|
+
# Test that gem-publish.sh accepts the new parameters
|
|
147
|
+
if [[ -x "$SCRIPT_DIR/gem-publish.sh" ]]; then
|
|
148
|
+
run_test "Integration: gem-publish accepts automated params" "$SCRIPT_DIR/gem-publish.sh patch --dry-run --automated-release --auto-commit-range=HEAD~1..HEAD --skip-tests --skip-publish --no-github-release | grep -q 'DRY RUN MODE'"
|
|
149
|
+
fi
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
# Test conventional commit detection
|
|
153
|
+
test_conventional_commits() {
|
|
154
|
+
log_info "Testing conventional commit detection..."
|
|
155
|
+
|
|
156
|
+
# Create test commits in memory (don't actually commit)
|
|
157
|
+
local test_commits=(
|
|
158
|
+
"feat: add new feature"
|
|
159
|
+
"fix: resolve bug in component"
|
|
160
|
+
"BREAKING CHANGE: remove deprecated API"
|
|
161
|
+
"chore: update dependencies"
|
|
162
|
+
"docs: improve documentation"
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
local expected_results=(
|
|
166
|
+
"minor"
|
|
167
|
+
"patch"
|
|
168
|
+
"major"
|
|
169
|
+
"patch"
|
|
170
|
+
"patch"
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
# Note: This would require a more sophisticated test setup
|
|
174
|
+
# For now, just test that the patterns exist in the script
|
|
175
|
+
run_test "Conventional commit patterns exist" "grep -q 'feat.*minor' '$SCRIPT_DIR/analyze-commits.sh'"
|
|
176
|
+
run_test "Fix patterns exist" "grep -q 'fix.*patch' '$SCRIPT_DIR/analyze-commits.sh'"
|
|
177
|
+
run_test "Breaking change patterns exist" "grep -q 'BREAKING.*major' '$SCRIPT_DIR/analyze-commits.sh'"
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
# Main test execution
|
|
181
|
+
main() {
|
|
182
|
+
log_info "🧪 Starting Automated Version Bump System Tests"
|
|
183
|
+
echo "=================================================="
|
|
184
|
+
echo ""
|
|
185
|
+
|
|
186
|
+
# Change to project root
|
|
187
|
+
cd "$PROJECT_ROOT"
|
|
188
|
+
|
|
189
|
+
# Run all test suites
|
|
190
|
+
test_file_permissions
|
|
191
|
+
test_commit_analysis
|
|
192
|
+
test_gem_publish_script
|
|
193
|
+
test_workflow_syntax
|
|
194
|
+
test_integration
|
|
195
|
+
test_conventional_commits
|
|
196
|
+
|
|
197
|
+
# Test summary
|
|
198
|
+
echo ""
|
|
199
|
+
echo "=================================================="
|
|
200
|
+
log_info "🎯 Test Results Summary"
|
|
201
|
+
echo "Tests Run: $TESTS_RUN"
|
|
202
|
+
echo "Tests Passed: $TESTS_PASSED"
|
|
203
|
+
echo "Tests Failed: $((TESTS_RUN - TESTS_PASSED))"
|
|
204
|
+
|
|
205
|
+
if [[ $TESTS_PASSED -eq $TESTS_RUN ]]; then
|
|
206
|
+
log_success "🎉 All tests passed! Automated version bump system is ready."
|
|
207
|
+
exit 0
|
|
208
|
+
else
|
|
209
|
+
log_error "❌ Some tests failed. Please review the issues above."
|
|
210
|
+
exit 1
|
|
211
|
+
fi
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
# Show usage if requested
|
|
215
|
+
if [[ "${1:-}" == "--help" ]] || [[ "${1:-}" == "-h" ]]; then
|
|
216
|
+
cat << EOF
|
|
217
|
+
Test Script for Automated Version Bump System
|
|
218
|
+
|
|
219
|
+
USAGE:
|
|
220
|
+
$0
|
|
221
|
+
|
|
222
|
+
DESCRIPTION:
|
|
223
|
+
This script tests the automated version bump system including:
|
|
224
|
+
- Commit analysis functionality
|
|
225
|
+
- Gem publication script compatibility
|
|
226
|
+
- Workflow file syntax validation
|
|
227
|
+
- Integration between components
|
|
228
|
+
- Conventional commit detection
|
|
229
|
+
|
|
230
|
+
REQUIREMENTS:
|
|
231
|
+
- Git repository with commit history
|
|
232
|
+
- Executable scripts in scripts/ directory
|
|
233
|
+
- Valid GitHub Actions workflow files
|
|
234
|
+
|
|
235
|
+
OUTPUT:
|
|
236
|
+
Detailed test results and summary
|
|
237
|
+
Exit code 0 on success, 1 on failure
|
|
238
|
+
EOF
|
|
239
|
+
exit 0
|
|
240
|
+
fi
|
|
241
|
+
|
|
242
|
+
# Execute main function
|
|
243
|
+
main "$@"
|