jekyll-theme-zer0 0.7.2 → 0.8.1
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 +72 -0
- data/README.md +33 -4
- data/_plugins/preview_image_generator.rb +258 -0
- data/_plugins/theme_version.rb +88 -0
- data/assets/images/previews/git-workflow-best-practices-for-modern-teams.png +0 -0
- data/scripts/README.md +443 -0
- data/scripts/analyze-commits.sh +313 -0
- data/scripts/build +115 -0
- data/scripts/build.sh +33 -0
- data/scripts/build.sh.legacy +174 -0
- data/scripts/example-usage.sh +102 -0
- data/scripts/fix-markdown-format.sh +265 -0
- data/scripts/gem-publish.sh +42 -0
- data/scripts/gem-publish.sh.legacy +700 -0
- data/scripts/generate-preview-images.sh +846 -0
- data/scripts/install-preview-generator.sh +531 -0
- data/scripts/lib/README.md +263 -0
- data/scripts/lib/changelog.sh +313 -0
- data/scripts/lib/common.sh +154 -0
- data/scripts/lib/gem.sh +226 -0
- data/scripts/lib/git.sh +205 -0
- data/scripts/lib/preview_generator.py +646 -0
- data/scripts/lib/test/run_tests.sh +140 -0
- data/scripts/lib/test/test_changelog.sh +87 -0
- data/scripts/lib/test/test_gem.sh +68 -0
- data/scripts/lib/test/test_git.sh +82 -0
- data/scripts/lib/test/test_validation.sh +72 -0
- data/scripts/lib/test/test_version.sh +96 -0
- data/scripts/lib/validation.sh +139 -0
- data/scripts/lib/version.sh +178 -0
- data/scripts/release +240 -0
- data/scripts/release.sh +33 -0
- data/scripts/release.sh.legacy +342 -0
- data/scripts/setup.sh +155 -0
- data/scripts/test-auto-version.sh +260 -0
- data/scripts/test-mermaid.sh +251 -0
- data/scripts/test.sh +156 -0
- data/scripts/version.sh +152 -0
- metadata +37 -1
|
@@ -0,0 +1,260 @@
|
|
|
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-auto-version.sh
|
|
6
|
+
|
|
7
|
+
set -euo pipefail
|
|
8
|
+
|
|
9
|
+
# Colors for output
|
|
10
|
+
RED='\033[0;31m'
|
|
11
|
+
GREEN='\033[0;32m'
|
|
12
|
+
YELLOW='\033[1;33m'
|
|
13
|
+
BLUE='\033[0;34m'
|
|
14
|
+
CYAN='\033[0;36m'
|
|
15
|
+
NC='\033[0m' # No Color
|
|
16
|
+
|
|
17
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
18
|
+
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
19
|
+
|
|
20
|
+
# Logging functions
|
|
21
|
+
log_info() {
|
|
22
|
+
echo -e "${BLUE}[INFO]${NC} $1"
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
log_success() {
|
|
26
|
+
echo -e "${GREEN}[SUCCESS]${NC} $1"
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
log_warning() {
|
|
30
|
+
echo -e "${YELLOW}[WARNING]${NC} $1"
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
log_error() {
|
|
34
|
+
echo -e "${RED}[ERROR]${NC} $1"
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
log_test() {
|
|
38
|
+
echo -e "${CYAN}[TEST]${NC} $1"
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
# Test counter
|
|
42
|
+
TESTS_RUN=0
|
|
43
|
+
TESTS_PASSED=0
|
|
44
|
+
|
|
45
|
+
run_test() {
|
|
46
|
+
local test_name="$1"
|
|
47
|
+
local test_command="$2"
|
|
48
|
+
local expected_result="${3:-}"
|
|
49
|
+
|
|
50
|
+
((TESTS_RUN++))
|
|
51
|
+
log_test "Running: $test_name"
|
|
52
|
+
|
|
53
|
+
local actual_result
|
|
54
|
+
if actual_result=$(eval "$test_command" 2>&1); then
|
|
55
|
+
if [[ -n "$expected_result" ]]; then
|
|
56
|
+
if [[ "$actual_result" == "$expected_result" ]]; then
|
|
57
|
+
log_success "✅ $test_name"
|
|
58
|
+
((TESTS_PASSED++))
|
|
59
|
+
else
|
|
60
|
+
log_error "❌ $test_name - Expected: '$expected_result', Got: '$actual_result'"
|
|
61
|
+
fi
|
|
62
|
+
else
|
|
63
|
+
log_success "✅ $test_name"
|
|
64
|
+
((TESTS_PASSED++))
|
|
65
|
+
fi
|
|
66
|
+
else
|
|
67
|
+
log_error "❌ $test_name - Command failed: $actual_result"
|
|
68
|
+
fi
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
# Test the commit analysis script
|
|
72
|
+
test_commit_analysis() {
|
|
73
|
+
log_info "Testing commit analysis functionality..."
|
|
74
|
+
|
|
75
|
+
# Test script exists and is executable
|
|
76
|
+
run_test "Commit analysis script exists" "test -x '$SCRIPT_DIR/analyze-commits.sh'"
|
|
77
|
+
|
|
78
|
+
# Test help output
|
|
79
|
+
run_test "Help output works" "$SCRIPT_DIR/analyze-commits.sh --help | grep -q 'Commit Analysis Script'"
|
|
80
|
+
|
|
81
|
+
# Test with sample commit ranges (if we have git history)
|
|
82
|
+
if git rev-list --count HEAD >/dev/null 2>&1; then
|
|
83
|
+
local commit_count=$(git rev-list --count HEAD)
|
|
84
|
+
|
|
85
|
+
if [[ $commit_count -gt 1 ]]; then
|
|
86
|
+
# Test analyzing last commit
|
|
87
|
+
run_test "Analyze last commit" "$SCRIPT_DIR/analyze-commits.sh HEAD~1..HEAD | grep -E '^(patch|minor|major|none)$'"
|
|
88
|
+
|
|
89
|
+
# Test analyzing multiple commits if available
|
|
90
|
+
if [[ $commit_count -gt 3 ]]; then
|
|
91
|
+
run_test "Analyze multiple commits" "$SCRIPT_DIR/analyze-commits.sh HEAD~3..HEAD | grep -E '^(patch|minor|major|none)$'"
|
|
92
|
+
fi
|
|
93
|
+
fi
|
|
94
|
+
else
|
|
95
|
+
log_warning "No git history available for commit analysis tests"
|
|
96
|
+
fi
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
# Test gem publication script compatibility
|
|
100
|
+
test_gem_publish_script() {
|
|
101
|
+
log_info "Testing gem publication script compatibility..."
|
|
102
|
+
|
|
103
|
+
# Test script exists and is executable
|
|
104
|
+
run_test "Gem publish script exists" "test -x '$SCRIPT_DIR/gem-publish.sh'"
|
|
105
|
+
|
|
106
|
+
# Test new automated options
|
|
107
|
+
run_test "Automated release option works" "$SCRIPT_DIR/gem-publish.sh --help | grep -q 'automated-release'"
|
|
108
|
+
run_test "Auto commit range option works" "$SCRIPT_DIR/gem-publish.sh --help | grep -q 'auto-commit-range'"
|
|
109
|
+
|
|
110
|
+
# Test dry run with automated options
|
|
111
|
+
if [[ -f "$PROJECT_ROOT/lib/jekyll-theme-zer0/version.rb" ]]; then
|
|
112
|
+
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'"
|
|
113
|
+
fi
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
# Test workflow files syntax
|
|
117
|
+
test_workflow_syntax() {
|
|
118
|
+
log_info "Testing GitHub Actions workflow syntax..."
|
|
119
|
+
|
|
120
|
+
# Check if yamllint is available
|
|
121
|
+
if command -v yamllint >/dev/null 2>&1; then
|
|
122
|
+
run_test "Auto-version-bump workflow syntax" "yamllint '$PROJECT_ROOT/.github/workflows/auto-version-bump.yml'"
|
|
123
|
+
else
|
|
124
|
+
# Basic YAML syntax check with Python
|
|
125
|
+
if command -v python3 >/dev/null 2>&1; then
|
|
126
|
+
run_test "Auto-version-bump workflow syntax" "python3 -c 'import yaml; yaml.safe_load(open(\"$PROJECT_ROOT/.github/workflows/auto-version-bump.yml\"))'"
|
|
127
|
+
else
|
|
128
|
+
log_warning "Neither yamllint nor python3 available for YAML validation"
|
|
129
|
+
fi
|
|
130
|
+
fi
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
# Test file permissions and executability
|
|
134
|
+
test_file_permissions() {
|
|
135
|
+
log_info "Testing file permissions..."
|
|
136
|
+
|
|
137
|
+
local scripts=(
|
|
138
|
+
"$SCRIPT_DIR/analyze-commits.sh"
|
|
139
|
+
"$SCRIPT_DIR/gem-publish.sh"
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
for script in "${scripts[@]}"; do
|
|
143
|
+
local script_name=$(basename "$script")
|
|
144
|
+
run_test "$script_name is executable" "test -x '$script'"
|
|
145
|
+
done
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
# Test integration between components
|
|
149
|
+
test_integration() {
|
|
150
|
+
log_info "Testing integration between components..."
|
|
151
|
+
|
|
152
|
+
# Test that analyze-commits.sh can be called by the workflow
|
|
153
|
+
if [[ -x "$SCRIPT_DIR/analyze-commits.sh" ]]; then
|
|
154
|
+
# Test with a simple commit range
|
|
155
|
+
if git rev-list --count HEAD >/dev/null 2>&1; then
|
|
156
|
+
local commit_count=$(git rev-list --count HEAD)
|
|
157
|
+
if [[ $commit_count -gt 0 ]]; then
|
|
158
|
+
run_test "Integration: commit analysis returns valid output" "$SCRIPT_DIR/analyze-commits.sh HEAD~1..HEAD | grep -E '^(patch|minor|major|none)$'"
|
|
159
|
+
fi
|
|
160
|
+
fi
|
|
161
|
+
fi
|
|
162
|
+
|
|
163
|
+
# Test that gem-publish.sh accepts the new parameters
|
|
164
|
+
if [[ -x "$SCRIPT_DIR/gem-publish.sh" ]]; then
|
|
165
|
+
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'"
|
|
166
|
+
fi
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
# Test conventional commit detection
|
|
170
|
+
test_conventional_commits() {
|
|
171
|
+
log_info "Testing conventional commit detection..."
|
|
172
|
+
|
|
173
|
+
# Create test commits in memory (don't actually commit)
|
|
174
|
+
local test_commits=(
|
|
175
|
+
"feat: add new feature"
|
|
176
|
+
"fix: resolve bug in component"
|
|
177
|
+
"BREAKING CHANGE: remove deprecated API"
|
|
178
|
+
"chore: update dependencies"
|
|
179
|
+
"docs: improve documentation"
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
local expected_results=(
|
|
183
|
+
"minor"
|
|
184
|
+
"patch"
|
|
185
|
+
"major"
|
|
186
|
+
"patch"
|
|
187
|
+
"patch"
|
|
188
|
+
)
|
|
189
|
+
|
|
190
|
+
# Note: This would require a more sophisticated test setup
|
|
191
|
+
# For now, just test that the patterns exist in the script
|
|
192
|
+
run_test "Conventional commit patterns exist" "grep -q 'feat.*minor' '$SCRIPT_DIR/analyze-commits.sh'"
|
|
193
|
+
run_test "Fix patterns exist" "grep -q 'fix.*patch' '$SCRIPT_DIR/analyze-commits.sh'"
|
|
194
|
+
run_test "Breaking change patterns exist" "grep -q 'BREAKING.*major' '$SCRIPT_DIR/analyze-commits.sh'"
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
# Main test execution
|
|
198
|
+
main() {
|
|
199
|
+
log_info "🧪 Starting Automated Version Bump System Tests"
|
|
200
|
+
echo "=================================================="
|
|
201
|
+
echo ""
|
|
202
|
+
|
|
203
|
+
# Change to project root
|
|
204
|
+
cd "$PROJECT_ROOT"
|
|
205
|
+
|
|
206
|
+
# Run all test suites
|
|
207
|
+
test_file_permissions
|
|
208
|
+
test_commit_analysis
|
|
209
|
+
test_gem_publish_script
|
|
210
|
+
test_workflow_syntax
|
|
211
|
+
test_integration
|
|
212
|
+
test_conventional_commits
|
|
213
|
+
|
|
214
|
+
# Test summary
|
|
215
|
+
echo ""
|
|
216
|
+
echo "=================================================="
|
|
217
|
+
log_info "🎯 Test Results Summary"
|
|
218
|
+
echo "Tests Run: $TESTS_RUN"
|
|
219
|
+
echo "Tests Passed: $TESTS_PASSED"
|
|
220
|
+
echo "Tests Failed: $((TESTS_RUN - TESTS_PASSED))"
|
|
221
|
+
|
|
222
|
+
if [[ $TESTS_PASSED -eq $TESTS_RUN ]]; then
|
|
223
|
+
log_success "🎉 All tests passed! Automated version bump system is ready."
|
|
224
|
+
exit 0
|
|
225
|
+
else
|
|
226
|
+
log_error "❌ Some tests failed. Please review the issues above."
|
|
227
|
+
exit 1
|
|
228
|
+
fi
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
# Show usage if requested
|
|
232
|
+
if [[ "${1:-}" == "--help" ]] || [[ "${1:-}" == "-h" ]]; then
|
|
233
|
+
cat << EOF
|
|
234
|
+
Test Script for Automated Version Bump System
|
|
235
|
+
|
|
236
|
+
USAGE:
|
|
237
|
+
$0
|
|
238
|
+
|
|
239
|
+
DESCRIPTION:
|
|
240
|
+
This script tests the automated version bump system including:
|
|
241
|
+
- Commit analysis functionality
|
|
242
|
+
- Gem publication script compatibility
|
|
243
|
+
- Workflow file syntax validation
|
|
244
|
+
- Integration between components
|
|
245
|
+
- Conventional commit detection
|
|
246
|
+
|
|
247
|
+
REQUIREMENTS:
|
|
248
|
+
- Git repository with commit history
|
|
249
|
+
- Executable scripts in scripts/ directory
|
|
250
|
+
- Valid GitHub Actions workflow files
|
|
251
|
+
|
|
252
|
+
OUTPUT:
|
|
253
|
+
Detailed test results and summary
|
|
254
|
+
Exit code 0 on success, 1 on failure
|
|
255
|
+
EOF
|
|
256
|
+
exit 0
|
|
257
|
+
fi
|
|
258
|
+
|
|
259
|
+
# Execute main function
|
|
260
|
+
main "$@"
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
###############################################################################
|
|
4
|
+
# Mermaid Integration Test Script
|
|
5
|
+
#
|
|
6
|
+
# Purpose: Comprehensive testing of Mermaid.js integration in Jekyll
|
|
7
|
+
# Usage: ./test-mermaid.sh [options]
|
|
8
|
+
# Options:
|
|
9
|
+
# --verbose Show detailed output
|
|
10
|
+
# --headless Run in headless mode (for CI/CD)
|
|
11
|
+
# --quick Run quick validation only
|
|
12
|
+
# --local Test local Jekyll server
|
|
13
|
+
# --docker Test Docker container
|
|
14
|
+
###############################################################################
|
|
15
|
+
|
|
16
|
+
set -euo pipefail
|
|
17
|
+
|
|
18
|
+
# Colors for output
|
|
19
|
+
RED='\033[0;31m'
|
|
20
|
+
GREEN='\033[0;32m'
|
|
21
|
+
YELLOW='\033[1;33m'
|
|
22
|
+
BLUE='\033[0;34m'
|
|
23
|
+
NC='\033[0m' # No Color
|
|
24
|
+
|
|
25
|
+
# Test counters
|
|
26
|
+
TESTS_PASSED=0
|
|
27
|
+
TESTS_FAILED=0
|
|
28
|
+
TOTAL_TESTS=0
|
|
29
|
+
|
|
30
|
+
# Configuration
|
|
31
|
+
VERBOSE=false
|
|
32
|
+
HEADLESS=false
|
|
33
|
+
QUICK=false
|
|
34
|
+
TEST_MODE="both" # local, docker, both
|
|
35
|
+
|
|
36
|
+
# Parse arguments
|
|
37
|
+
for arg in "$@"; do
|
|
38
|
+
case $arg in
|
|
39
|
+
--verbose)
|
|
40
|
+
VERBOSE=true
|
|
41
|
+
shift
|
|
42
|
+
;;
|
|
43
|
+
--headless)
|
|
44
|
+
HEADLESS=true
|
|
45
|
+
shift
|
|
46
|
+
;;
|
|
47
|
+
--quick)
|
|
48
|
+
QUICK=true
|
|
49
|
+
shift
|
|
50
|
+
;;
|
|
51
|
+
--local)
|
|
52
|
+
TEST_MODE="local"
|
|
53
|
+
shift
|
|
54
|
+
;;
|
|
55
|
+
--docker)
|
|
56
|
+
TEST_MODE="docker"
|
|
57
|
+
shift
|
|
58
|
+
;;
|
|
59
|
+
--help)
|
|
60
|
+
echo "Usage: $0 [options]"
|
|
61
|
+
echo "Options:"
|
|
62
|
+
echo " --verbose Show detailed output"
|
|
63
|
+
echo " --headless Run in headless mode (for CI/CD)"
|
|
64
|
+
echo " --quick Run quick validation only"
|
|
65
|
+
echo " --local Test local Jekyll server only"
|
|
66
|
+
echo " --docker Test Docker container only"
|
|
67
|
+
echo " --help Show this help message"
|
|
68
|
+
exit 0
|
|
69
|
+
;;
|
|
70
|
+
*)
|
|
71
|
+
echo "Unknown option: $arg"
|
|
72
|
+
echo "Use --help for usage information"
|
|
73
|
+
exit 1
|
|
74
|
+
;;
|
|
75
|
+
esac
|
|
76
|
+
done
|
|
77
|
+
|
|
78
|
+
# Logging functions
|
|
79
|
+
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
|
|
80
|
+
log_success() { echo -e "${GREEN}[✓]${NC} $1"; }
|
|
81
|
+
log_warning() { echo -e "${YELLOW}[!]${NC} $1"; }
|
|
82
|
+
log_error() { echo -e "${RED}[✗]${NC} $1"; }
|
|
83
|
+
|
|
84
|
+
# Test function
|
|
85
|
+
run_test() {
|
|
86
|
+
local test_name="$1"
|
|
87
|
+
local test_command="$2"
|
|
88
|
+
|
|
89
|
+
TOTAL_TESTS=$((TOTAL_TESTS + 1))
|
|
90
|
+
|
|
91
|
+
if [ "$VERBOSE" = true ]; then
|
|
92
|
+
log_info "Running: $test_name"
|
|
93
|
+
fi
|
|
94
|
+
|
|
95
|
+
if eval "$test_command" >/dev/null 2>&1; then
|
|
96
|
+
TESTS_PASSED=$((TESTS_PASSED + 1))
|
|
97
|
+
log_success "$test_name"
|
|
98
|
+
return 0
|
|
99
|
+
else
|
|
100
|
+
TESTS_FAILED=$((TESTS_FAILED + 1))
|
|
101
|
+
log_error "$test_name"
|
|
102
|
+
return 1
|
|
103
|
+
fi
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
# Test file existence
|
|
107
|
+
test_file_exists() {
|
|
108
|
+
local file_path="$1"
|
|
109
|
+
local description="$2"
|
|
110
|
+
|
|
111
|
+
run_test "$description" "[ -f '$file_path' ]"
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
# Test file content
|
|
115
|
+
test_file_content() {
|
|
116
|
+
local file_path="$1"
|
|
117
|
+
local pattern="$2"
|
|
118
|
+
local description="$3"
|
|
119
|
+
|
|
120
|
+
run_test "$description" "grep -q '$pattern' '$file_path'"
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
# Test URL accessibility
|
|
124
|
+
test_url() {
|
|
125
|
+
local url="$1"
|
|
126
|
+
local description="$2"
|
|
127
|
+
|
|
128
|
+
run_test "$description" "curl -s -f '$url' >/dev/null"
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
# Test Mermaid script loading
|
|
132
|
+
test_mermaid_script() {
|
|
133
|
+
local url="$1"
|
|
134
|
+
local description="$2"
|
|
135
|
+
|
|
136
|
+
run_test "$description" "curl -s '$url' | grep -q 'mermaid.min.js'"
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
# Test Mermaid initialization
|
|
140
|
+
test_mermaid_init() {
|
|
141
|
+
local url="$1"
|
|
142
|
+
local description="$2"
|
|
143
|
+
|
|
144
|
+
run_test "$description" "curl -s '$url' | grep -q 'mermaid.initialize'"
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
# Test diagram rendering
|
|
148
|
+
test_diagram_rendering() {
|
|
149
|
+
local url="$1"
|
|
150
|
+
local description="$2"
|
|
151
|
+
|
|
152
|
+
run_test "$description" "curl -s '$url' | grep -q 'class=\"mermaid\"'"
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
# Main test execution
|
|
156
|
+
main() {
|
|
157
|
+
echo "🧪 Mermaid Integration Test Suite"
|
|
158
|
+
echo "=================================="
|
|
159
|
+
echo "Mode: $TEST_MODE"
|
|
160
|
+
echo "Verbose: $VERBOSE"
|
|
161
|
+
echo "Quick: $QUICK"
|
|
162
|
+
echo ""
|
|
163
|
+
|
|
164
|
+
# Core file tests
|
|
165
|
+
log_info "Testing core files..."
|
|
166
|
+
|
|
167
|
+
test_file_exists "_includes/components/mermaid.html" "Mermaid include file exists"
|
|
168
|
+
test_file_exists "pages/_docs/jekyll/mermaid.md" "Main documentation exists"
|
|
169
|
+
test_file_exists "pages/_docs/jekyll/mermaid-test-suite.md" "Test suite exists"
|
|
170
|
+
test_file_exists "pages/_docs/jekyll/jekyll-diagram-with-mermaid.md" "Tutorial exists"
|
|
171
|
+
|
|
172
|
+
# Configuration tests
|
|
173
|
+
log_info "Testing configuration..."
|
|
174
|
+
|
|
175
|
+
test_file_content "_config.yml" "jekyll-mermaid" "Jekyll-mermaid plugin configured"
|
|
176
|
+
test_file_content "_config.yml" "mermaid:" "Mermaid configuration present"
|
|
177
|
+
test_file_content "_includes/core/head.html" "page.mermaid" "Conditional loading configured"
|
|
178
|
+
test_file_content "_includes/core/head.html" "mermaid.html" "Mermaid include referenced"
|
|
179
|
+
|
|
180
|
+
# Mermaid include file tests
|
|
181
|
+
log_info "Testing Mermaid include file..."
|
|
182
|
+
|
|
183
|
+
test_file_content "_includes/components/mermaid.html" "mermaid@10" "Mermaid v10 CDN link"
|
|
184
|
+
test_file_content "_includes/components/mermaid.html" "mermaid.initialize" "Mermaid initialization script"
|
|
185
|
+
test_file_content "_includes/components/mermaid.html" "forest" "Forest theme configured"
|
|
186
|
+
test_file_content "_includes/components/mermaid.html" "FontAwesome" "FontAwesome support included"
|
|
187
|
+
|
|
188
|
+
# Documentation tests
|
|
189
|
+
log_info "Testing documentation..."
|
|
190
|
+
|
|
191
|
+
test_file_content "pages/_docs/jekyll/mermaid.md" "mermaid: true" "Main docs have front matter"
|
|
192
|
+
test_file_content "pages/_docs/jekyll/mermaid-test-suite.md" "mermaid: true" "Test suite has front matter"
|
|
193
|
+
test_file_content "pages/_docs/jekyll/mermaid.md" "graph TD" "Main docs have examples"
|
|
194
|
+
test_file_content "pages/_docs/jekyll/mermaid-test-suite.md" "graph TD" "Test suite has examples"
|
|
195
|
+
|
|
196
|
+
# Server tests (if not quick mode)
|
|
197
|
+
if [ "$QUICK" = false ]; then
|
|
198
|
+
log_info "Testing server functionality..."
|
|
199
|
+
|
|
200
|
+
# Test local server if enabled
|
|
201
|
+
if [ "$TEST_MODE" = "local" ] || [ "$TEST_MODE" = "both" ]; then
|
|
202
|
+
log_info "Testing local Jekyll server..."
|
|
203
|
+
|
|
204
|
+
# Check if local server is running
|
|
205
|
+
if curl -s -f "http://localhost:4000" >/dev/null 2>&1; then
|
|
206
|
+
test_url "http://localhost:4000/docs/jekyll/mermaid/" "Main documentation accessible"
|
|
207
|
+
test_url "http://localhost:4000/docs/jekyll/mermaid-test-suite/" "Test suite accessible"
|
|
208
|
+
test_mermaid_script "http://localhost:4000/docs/jekyll/mermaid-test-suite/" "Mermaid script loads on test page"
|
|
209
|
+
test_mermaid_init "http://localhost:4000/docs/jekyll/mermaid-test-suite/" "Mermaid initializes on test page"
|
|
210
|
+
test_diagram_rendering "http://localhost:4000/docs/jekyll/mermaid-test-suite/" "Diagrams render on test page"
|
|
211
|
+
else
|
|
212
|
+
log_warning "Local Jekyll server not running. Start with: bundle exec jekyll serve"
|
|
213
|
+
fi
|
|
214
|
+
fi
|
|
215
|
+
|
|
216
|
+
# Test Docker server if enabled
|
|
217
|
+
if [ "$TEST_MODE" = "docker" ] || [ "$TEST_MODE" = "both" ]; then
|
|
218
|
+
log_info "Testing Docker container..."
|
|
219
|
+
|
|
220
|
+
# Check if Docker container is running
|
|
221
|
+
if docker ps | grep -q "zer0-mistakes-jekyll"; then
|
|
222
|
+
test_url "http://localhost:4000/docs/jekyll/mermaid/" "Docker: Main documentation accessible"
|
|
223
|
+
test_url "http://localhost:4000/docs/jekyll/mermaid-test-suite/" "Docker: Test suite accessible"
|
|
224
|
+
test_mermaid_script "http://localhost:4000/docs/jekyll/mermaid-test-suite/" "Docker: Mermaid script loads"
|
|
225
|
+
test_mermaid_init "http://localhost:4000/docs/jekyll/mermaid-test-suite/" "Docker: Mermaid initializes"
|
|
226
|
+
test_diagram_rendering "http://localhost:4000/docs/jekyll/mermaid-test-suite/" "Docker: Diagrams render"
|
|
227
|
+
else
|
|
228
|
+
log_warning "Docker container not running. Start with: docker-compose up -d"
|
|
229
|
+
fi
|
|
230
|
+
fi
|
|
231
|
+
fi
|
|
232
|
+
|
|
233
|
+
# Summary
|
|
234
|
+
echo ""
|
|
235
|
+
echo "📊 Test Results Summary"
|
|
236
|
+
echo "======================"
|
|
237
|
+
echo "Total Tests: $TOTAL_TESTS"
|
|
238
|
+
echo "Passed: $TESTS_PASSED"
|
|
239
|
+
echo "Failed: $TESTS_FAILED"
|
|
240
|
+
|
|
241
|
+
if [ $TESTS_FAILED -eq 0 ]; then
|
|
242
|
+
log_success "All tests passed! ✅"
|
|
243
|
+
exit 0
|
|
244
|
+
else
|
|
245
|
+
log_error "Some tests failed! ❌"
|
|
246
|
+
exit 1
|
|
247
|
+
fi
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
# Run main function
|
|
251
|
+
main "$@"
|
data/scripts/test.sh
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Test script for zer0-mistakes Jekyll theme
|
|
4
|
+
# Usage: ./scripts/test.sh [--verbose]
|
|
5
|
+
|
|
6
|
+
set -e
|
|
7
|
+
|
|
8
|
+
# Colors for output
|
|
9
|
+
RED='\033[0;31m'
|
|
10
|
+
GREEN='\033[0;32m'
|
|
11
|
+
YELLOW='\033[1;33m'
|
|
12
|
+
BLUE='\033[0;34m'
|
|
13
|
+
NC='\033[0m' # No Color
|
|
14
|
+
|
|
15
|
+
# Default values
|
|
16
|
+
VERBOSE=false
|
|
17
|
+
|
|
18
|
+
# Parse arguments
|
|
19
|
+
while [[ $# -gt 0 ]]; do
|
|
20
|
+
case $1 in
|
|
21
|
+
--verbose|-v)
|
|
22
|
+
VERBOSE=true
|
|
23
|
+
shift
|
|
24
|
+
;;
|
|
25
|
+
*)
|
|
26
|
+
echo -e "${RED}Unknown option: $1${NC}"
|
|
27
|
+
exit 1
|
|
28
|
+
;;
|
|
29
|
+
esac
|
|
30
|
+
done
|
|
31
|
+
|
|
32
|
+
# Function to log messages
|
|
33
|
+
log() {
|
|
34
|
+
echo -e "${GREEN}[TEST]${NC} $1"
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
warn() {
|
|
38
|
+
echo -e "${YELLOW}[WARNING]${NC} $1"
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
error() {
|
|
42
|
+
echo -e "${RED}[ERROR]${NC} $1"
|
|
43
|
+
exit 1
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
info() {
|
|
47
|
+
echo -e "${BLUE}[INFO]${NC} $1"
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
success() {
|
|
51
|
+
echo -e "${GREEN}✓${NC} $1"
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
fail() {
|
|
55
|
+
echo -e "${RED}✗${NC} $1"
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
# Test counter
|
|
59
|
+
TESTS_RUN=0
|
|
60
|
+
TESTS_PASSED=0
|
|
61
|
+
|
|
62
|
+
run_test() {
|
|
63
|
+
local test_name="$1"
|
|
64
|
+
local test_command="$2"
|
|
65
|
+
|
|
66
|
+
TESTS_RUN=$((TESTS_RUN + 1))
|
|
67
|
+
|
|
68
|
+
log "Running: $test_name"
|
|
69
|
+
|
|
70
|
+
if [[ "$VERBOSE" == true ]]; then
|
|
71
|
+
echo "Command: $test_command"
|
|
72
|
+
fi
|
|
73
|
+
|
|
74
|
+
if eval "$test_command" > /dev/null 2>&1; then
|
|
75
|
+
success "$test_name"
|
|
76
|
+
TESTS_PASSED=$((TESTS_PASSED + 1))
|
|
77
|
+
else
|
|
78
|
+
fail "$test_name"
|
|
79
|
+
if [[ "$VERBOSE" == true ]]; then
|
|
80
|
+
echo "Command output:"
|
|
81
|
+
eval "$test_command" 2>&1 || true
|
|
82
|
+
fi
|
|
83
|
+
fi
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
log "Running tests for zer0-mistakes Jekyll theme..."
|
|
87
|
+
|
|
88
|
+
# Test 1: Validate package.json
|
|
89
|
+
run_test "Validate package.json syntax" "jq empty package.json"
|
|
90
|
+
|
|
91
|
+
# Test 2: Validate package.json version
|
|
92
|
+
run_test "Validate package.json version format" "jq -r '.version' package.json | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$'"
|
|
93
|
+
|
|
94
|
+
# Test 3: Validate gemspec syntax
|
|
95
|
+
run_test "Validate gemspec syntax" "ruby -c jekyll-theme-zer0.gemspec"
|
|
96
|
+
|
|
97
|
+
# Test 4: Build gem (test build)
|
|
98
|
+
run_test "Test gem build" "gem build jekyll-theme-zer0.gemspec"
|
|
99
|
+
|
|
100
|
+
# Test 5: Check for required files
|
|
101
|
+
run_test "Check README.md exists" "test -f README.md"
|
|
102
|
+
run_test "Check LICENSE exists" "test -f LICENSE"
|
|
103
|
+
run_test "Check _layouts directory exists" "test -d _layouts"
|
|
104
|
+
run_test "Check _includes directory exists" "test -d _includes"
|
|
105
|
+
run_test "Check _sass directory exists" "test -d _sass"
|
|
106
|
+
run_test "Check assets directory exists" "test -d assets"
|
|
107
|
+
|
|
108
|
+
# Test 6: Validate YAML front matter in layouts
|
|
109
|
+
if [[ -d "_layouts" ]]; then
|
|
110
|
+
for layout in _layouts/*.html; do
|
|
111
|
+
if [[ -f "$layout" ]]; then
|
|
112
|
+
layout_name=$(basename "$layout")
|
|
113
|
+
run_test "Validate YAML front matter in $layout_name" "head -10 '$layout' | grep -q -- '---' && head -10 '$layout' | tail -n +2 | head -n -1 | ruby -ryaml -e 'YAML.load(STDIN.read)'"
|
|
114
|
+
fi
|
|
115
|
+
done
|
|
116
|
+
fi
|
|
117
|
+
|
|
118
|
+
# Test 7: Check for common Jekyll requirements
|
|
119
|
+
run_test "Check Jekyll dependency in gemspec" "grep -q 'jekyll' jekyll-theme-zer0.gemspec"
|
|
120
|
+
|
|
121
|
+
# Test 8: Validate version consistency
|
|
122
|
+
PACKAGE_VERSION=$(jq -r '.version' package.json)
|
|
123
|
+
if [[ -f "jekyll-theme-zer0-${PACKAGE_VERSION}.gem" ]]; then
|
|
124
|
+
run_test "Version consistency check" "test -f jekyll-theme-zer0-${PACKAGE_VERSION}.gem"
|
|
125
|
+
fi
|
|
126
|
+
|
|
127
|
+
# Test 9: Check scripts are executable
|
|
128
|
+
if [[ -d "scripts" ]]; then
|
|
129
|
+
for script in scripts/*.sh; do
|
|
130
|
+
if [[ -f "$script" ]]; then
|
|
131
|
+
script_name=$(basename "$script")
|
|
132
|
+
run_test "Check $script_name is executable" "test -x '$script'"
|
|
133
|
+
fi
|
|
134
|
+
done
|
|
135
|
+
fi
|
|
136
|
+
|
|
137
|
+
# Test 10: Validate bundle install
|
|
138
|
+
run_test "Test bundle install" "bundle install --quiet"
|
|
139
|
+
|
|
140
|
+
# Clean up test gem file
|
|
141
|
+
rm -f jekyll-theme-zer0-*.gem 2>/dev/null || true
|
|
142
|
+
|
|
143
|
+
# Test results
|
|
144
|
+
log ""
|
|
145
|
+
log "Test Results:"
|
|
146
|
+
log "Tests run: $TESTS_RUN"
|
|
147
|
+
log "Tests passed: $TESTS_PASSED"
|
|
148
|
+
log "Tests failed: $((TESTS_RUN - TESTS_PASSED))"
|
|
149
|
+
|
|
150
|
+
if [[ $TESTS_PASSED -eq $TESTS_RUN ]]; then
|
|
151
|
+
success "All tests passed!"
|
|
152
|
+
exit 0
|
|
153
|
+
else
|
|
154
|
+
fail "Some tests failed!"
|
|
155
|
+
exit 1
|
|
156
|
+
fi
|