jekyll-theme-zer0 0.7.2 → 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 +272 -3
- data/README.md +83 -21
- 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/_plugins/preview_image_generator.rb +258 -0
- data/_plugins/theme_version.rb +88 -0
- data/_sass/core/_theme.scss +4 -1
- 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/bin/build +115 -0
- data/scripts/bin/release +240 -0
- data/scripts/bin/test +203 -0
- data/scripts/build +115 -0
- data/scripts/example-usage.sh +102 -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/fix-markdown-format.sh +265 -0
- data/scripts/generate-preview-images.sh +791 -0
- data/scripts/install-preview-generator.sh +531 -0
- data/scripts/lib/README.md +291 -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/setup.sh +155 -0
- 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/test-auto-version.sh +260 -0
- data/scripts/test-mermaid.sh +251 -0
- data/scripts/test.sh +156 -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 +178 -0
- metadata +50 -2
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Unit tests for changelog.sh library
|
|
4
|
+
|
|
5
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
6
|
+
LIB_DIR="$(cd "$SCRIPT_DIR/../../lib" && pwd)"
|
|
7
|
+
|
|
8
|
+
# Set up test environment
|
|
9
|
+
export DRY_RUN=true
|
|
10
|
+
export INTERACTIVE=false
|
|
11
|
+
export VERBOSE=false
|
|
12
|
+
|
|
13
|
+
# Source the library
|
|
14
|
+
source "$LIB_DIR/changelog.sh"
|
|
15
|
+
|
|
16
|
+
# Disable errexit for test assertions
|
|
17
|
+
set +e
|
|
18
|
+
|
|
19
|
+
print_suite_header "changelog.sh"
|
|
20
|
+
|
|
21
|
+
# Test: clean_commit_message
|
|
22
|
+
echo "Testing clean_commit_message..."
|
|
23
|
+
|
|
24
|
+
result=$(clean_commit_message "feat: add new feature")
|
|
25
|
+
assert_equals "Add new feature" "$result" "Clean 'feat:' prefix"
|
|
26
|
+
|
|
27
|
+
result=$(clean_commit_message "fix: resolve bug")
|
|
28
|
+
assert_equals "Resolve bug" "$result" "Clean 'fix:' prefix"
|
|
29
|
+
|
|
30
|
+
result=$(clean_commit_message "feat(scope): add scoped feature")
|
|
31
|
+
assert_equals "Add scoped feature" "$result" "Clean 'feat(scope):' prefix"
|
|
32
|
+
|
|
33
|
+
result=$(clean_commit_message "chore: update dependencies")
|
|
34
|
+
assert_equals "Update dependencies" "$result" "Clean 'chore:' prefix"
|
|
35
|
+
|
|
36
|
+
result=$(clean_commit_message "docs: improve readme")
|
|
37
|
+
assert_equals "Improve readme" "$result" "Clean 'docs:' prefix and capitalize"
|
|
38
|
+
|
|
39
|
+
result=$(clean_commit_message "regular commit message")
|
|
40
|
+
assert_equals "Regular commit message" "$result" "Capitalize regular message"
|
|
41
|
+
|
|
42
|
+
# Test: categorize_commit (requires git, so we test the logic patterns)
|
|
43
|
+
echo -e "\nTesting commit categorization patterns..."
|
|
44
|
+
|
|
45
|
+
# Simulate commit subjects for categorization
|
|
46
|
+
test_categorization() {
|
|
47
|
+
local subject="$1"
|
|
48
|
+
local expected="$2"
|
|
49
|
+
|
|
50
|
+
# Create temporary test function that returns category based on patterns
|
|
51
|
+
local subject_lower=$(echo "$subject" | tr '[:upper:]' '[:lower:]')
|
|
52
|
+
local category="other"
|
|
53
|
+
|
|
54
|
+
case "$subject_lower" in
|
|
55
|
+
feat:*|feature:*|add:*|new:*)
|
|
56
|
+
category="added"
|
|
57
|
+
;;
|
|
58
|
+
fix:*|bugfix:*|bug:*|patch:*)
|
|
59
|
+
category="fixed"
|
|
60
|
+
;;
|
|
61
|
+
*breaking*)
|
|
62
|
+
category="breaking"
|
|
63
|
+
;;
|
|
64
|
+
perf:*|performance:*|refactor:*|style:*|docs:*|doc:*|test:*|chore:*|ci:*|build:*)
|
|
65
|
+
category="changed"
|
|
66
|
+
;;
|
|
67
|
+
revert:*|remove:*|delete:*)
|
|
68
|
+
category="removed"
|
|
69
|
+
;;
|
|
70
|
+
deprecate:*|deprecated:*)
|
|
71
|
+
category="deprecated"
|
|
72
|
+
;;
|
|
73
|
+
security:*|sec:*)
|
|
74
|
+
category="security"
|
|
75
|
+
;;
|
|
76
|
+
esac
|
|
77
|
+
|
|
78
|
+
assert_equals "$expected" "$category" "Categorize: '$subject' → $expected"
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
test_categorization "feat: new feature" "added"
|
|
82
|
+
test_categorization "fix: bug fix" "fixed"
|
|
83
|
+
test_categorization "chore: update" "changed"
|
|
84
|
+
test_categorization "docs: improve" "changed"
|
|
85
|
+
test_categorization "remove: old code" "removed"
|
|
86
|
+
test_categorization "security: patch vulnerability" "security"
|
|
87
|
+
test_categorization "BREAKING: major change" "breaking"
|
|
88
|
+
test_categorization "random commit" "other"
|
|
89
|
+
|
|
90
|
+
echo -e "\n${GREEN}changelog.sh tests complete${NC}"
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Unit tests for gem.sh library
|
|
4
|
+
|
|
5
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
6
|
+
LIB_DIR="$(cd "$SCRIPT_DIR/../../lib" && pwd)"
|
|
7
|
+
|
|
8
|
+
# Set up test environment
|
|
9
|
+
export DRY_RUN=true
|
|
10
|
+
export INTERACTIVE=false
|
|
11
|
+
export VERBOSE=false
|
|
12
|
+
|
|
13
|
+
# Source the library
|
|
14
|
+
source "$LIB_DIR/gem.sh"
|
|
15
|
+
|
|
16
|
+
# Disable errexit for test assertions
|
|
17
|
+
set +e
|
|
18
|
+
|
|
19
|
+
print_suite_header "gem.sh"
|
|
20
|
+
|
|
21
|
+
# Test: gem_version_exists
|
|
22
|
+
echo "Testing gem_version_exists..."
|
|
23
|
+
|
|
24
|
+
# Test with a version that should exist (v1.0.0 is common)
|
|
25
|
+
if gem_version_exists "1.0.0" 2>/dev/null; then
|
|
26
|
+
echo -e "${YELLOW}ℹ${NC} Version 1.0.0 exists on RubyGems"
|
|
27
|
+
else
|
|
28
|
+
echo -e "${YELLOW}ℹ${NC} Version 1.0.0 does not exist on RubyGems"
|
|
29
|
+
fi
|
|
30
|
+
|
|
31
|
+
# Test with a version that definitely shouldn't exist
|
|
32
|
+
if gem_version_exists "999.999.999" 2>/dev/null; then
|
|
33
|
+
assert_false "true" "Non-existent version not found"
|
|
34
|
+
else
|
|
35
|
+
assert_false "false" "Non-existent version not found"
|
|
36
|
+
fi
|
|
37
|
+
|
|
38
|
+
# Test: Gem operations (dry run)
|
|
39
|
+
echo -e "\nTesting gem operations in dry run mode..."
|
|
40
|
+
|
|
41
|
+
# Test build_gem in dry run
|
|
42
|
+
if build_gem "1.0.0" 2>/dev/null; then
|
|
43
|
+
assert_true "true" "Dry run: build_gem"
|
|
44
|
+
else
|
|
45
|
+
assert_true "false" "Dry run: build_gem"
|
|
46
|
+
fi
|
|
47
|
+
|
|
48
|
+
# Test publish_gem in dry run
|
|
49
|
+
if publish_gem "1.0.0" 2>/dev/null; then
|
|
50
|
+
assert_true "true" "Dry run: publish_gem"
|
|
51
|
+
else
|
|
52
|
+
# May fail due to missing gem file, that's ok in dry run
|
|
53
|
+
echo -e "${YELLOW}ℹ${NC} Dry run: publish_gem (skipped - no gem file)"
|
|
54
|
+
fi
|
|
55
|
+
|
|
56
|
+
# Test create_github_release in dry run
|
|
57
|
+
if create_github_release "1.0.0" 2>/dev/null; then
|
|
58
|
+
assert_true "true" "Dry run: create_github_release"
|
|
59
|
+
else
|
|
60
|
+
# May fail if gh CLI not available, that's ok
|
|
61
|
+
echo -e "${YELLOW}ℹ${NC} Dry run: create_github_release (skipped - gh CLI may not be available)"
|
|
62
|
+
fi
|
|
63
|
+
|
|
64
|
+
# Test run_tests in dry run
|
|
65
|
+
if run_tests 2>/dev/null; then
|
|
66
|
+
assert_true "true" "Dry run: run_tests"
|
|
67
|
+
else
|
|
68
|
+
assert_true "false" "Dry run: run_tests"
|
|
69
|
+
fi
|
|
70
|
+
|
|
71
|
+
echo -e "\n${GREEN}gem.sh tests complete${NC}"
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Unit tests for git.sh library
|
|
4
|
+
|
|
5
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
6
|
+
LIB_DIR="$(cd "$SCRIPT_DIR/../../lib" && pwd)"
|
|
7
|
+
|
|
8
|
+
# Set up test environment
|
|
9
|
+
export DRY_RUN=true
|
|
10
|
+
export INTERACTIVE=false
|
|
11
|
+
export VERBOSE=false
|
|
12
|
+
|
|
13
|
+
# Source the library
|
|
14
|
+
source "$LIB_DIR/git.sh"
|
|
15
|
+
|
|
16
|
+
# Disable errexit for test assertions
|
|
17
|
+
set +e
|
|
18
|
+
|
|
19
|
+
print_suite_header "git.sh"
|
|
20
|
+
|
|
21
|
+
# Test: get_current_branch
|
|
22
|
+
echo "Testing get_current_branch..."
|
|
23
|
+
|
|
24
|
+
current_branch=$(get_current_branch)
|
|
25
|
+
if [[ -n "$current_branch" ]]; then
|
|
26
|
+
assert_true "true" "Get current branch: $current_branch"
|
|
27
|
+
else
|
|
28
|
+
assert_true "false" "Get current branch"
|
|
29
|
+
fi
|
|
30
|
+
|
|
31
|
+
# Test: get_remote_url
|
|
32
|
+
echo -e "\nTesting get_remote_url..."
|
|
33
|
+
|
|
34
|
+
remote_url=$(get_remote_url "origin" 2>/dev/null)
|
|
35
|
+
if [[ -n "$remote_url" ]]; then
|
|
36
|
+
assert_true "true" "Get remote URL: $remote_url"
|
|
37
|
+
else
|
|
38
|
+
echo -e "${YELLOW}ℹ${NC} No remote URL found (may not be in git repo)"
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
# Test: get_repo_info
|
|
42
|
+
echo -e "\nTesting get_repo_info..."
|
|
43
|
+
|
|
44
|
+
if [[ -n "$remote_url" ]]; then
|
|
45
|
+
repo_info=$(get_repo_info "origin" 2>/dev/null)
|
|
46
|
+
if [[ -n "$repo_info" ]]; then
|
|
47
|
+
assert_true "true" "Extract repo info: $repo_info"
|
|
48
|
+
else
|
|
49
|
+
echo -e "${YELLOW}ℹ${NC} Could not extract repo info from URL"
|
|
50
|
+
fi
|
|
51
|
+
fi
|
|
52
|
+
|
|
53
|
+
# Test: tag_exists
|
|
54
|
+
echo -e "\nTesting tag_exists..."
|
|
55
|
+
|
|
56
|
+
# Test with a tag that likely doesn't exist
|
|
57
|
+
if tag_exists "v999.999.999"; then
|
|
58
|
+
assert_false "true" "Non-existent tag not found"
|
|
59
|
+
else
|
|
60
|
+
assert_false "false" "Non-existent tag not found"
|
|
61
|
+
fi
|
|
62
|
+
|
|
63
|
+
# Test: get_last_version_tag
|
|
64
|
+
echo -e "\nTesting get_last_version_tag..."
|
|
65
|
+
|
|
66
|
+
last_tag=$(get_last_version_tag 2>/dev/null)
|
|
67
|
+
if [[ -n "$last_tag" ]]; then
|
|
68
|
+
assert_true "true" "Get last version tag: $last_tag"
|
|
69
|
+
else
|
|
70
|
+
echo -e "${YELLOW}ℹ${NC} No version tags found (using initial commit)"
|
|
71
|
+
fi
|
|
72
|
+
|
|
73
|
+
# Test: count_commits_since
|
|
74
|
+
echo -e "\nTesting count_commits_since..."
|
|
75
|
+
|
|
76
|
+
if [[ -n "$last_tag" ]]; then
|
|
77
|
+
commit_count=$(count_commits_since "$last_tag" 2>/dev/null)
|
|
78
|
+
if [[ "$commit_count" =~ ^[0-9]+$ ]]; then
|
|
79
|
+
assert_true "true" "Count commits since $last_tag: $commit_count"
|
|
80
|
+
else
|
|
81
|
+
assert_true "false" "Count commits returns number"
|
|
82
|
+
fi
|
|
83
|
+
fi
|
|
84
|
+
|
|
85
|
+
echo -e "\n${GREEN}git.sh tests complete${NC}"
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Unit tests for validation.sh library
|
|
4
|
+
|
|
5
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
6
|
+
LIB_DIR="$(cd "$SCRIPT_DIR/../../lib" && pwd)"
|
|
7
|
+
|
|
8
|
+
# Set up test environment
|
|
9
|
+
export DRY_RUN=true
|
|
10
|
+
export INTERACTIVE=false
|
|
11
|
+
export VERBOSE=false
|
|
12
|
+
|
|
13
|
+
# Source the library
|
|
14
|
+
source "$LIB_DIR/validation.sh"
|
|
15
|
+
|
|
16
|
+
# Disable errexit for test assertions
|
|
17
|
+
set +e
|
|
18
|
+
|
|
19
|
+
print_suite_header "validation.sh"
|
|
20
|
+
|
|
21
|
+
# Test: validate_git_repo (should pass since we're in a git repo)
|
|
22
|
+
echo "Testing validate_git_repo..."
|
|
23
|
+
|
|
24
|
+
if validate_git_repo 2>/dev/null; then
|
|
25
|
+
assert_true "true" "Detects git repository"
|
|
26
|
+
else
|
|
27
|
+
assert_true "false" "Detects git repository"
|
|
28
|
+
fi
|
|
29
|
+
|
|
30
|
+
# Test: validate_required_files
|
|
31
|
+
echo -e "\nTesting validate_required_files..."
|
|
32
|
+
|
|
33
|
+
# This will fail if we're not in the project root, but that's expected for tests
|
|
34
|
+
if validate_required_files 2>/dev/null; then
|
|
35
|
+
assert_true "true" "Required files exist"
|
|
36
|
+
else
|
|
37
|
+
# If files don't exist (running from test dir), that's ok for unit tests
|
|
38
|
+
echo -e "${YELLOW}ℹ${NC} Required files check skipped (not in project root)"
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
# Test: command_exists (from common.sh)
|
|
42
|
+
echo -e "\nTesting command_exists..."
|
|
43
|
+
|
|
44
|
+
if command_exists "git"; then
|
|
45
|
+
assert_true "true" "Git command exists"
|
|
46
|
+
else
|
|
47
|
+
assert_true "false" "Git command exists"
|
|
48
|
+
fi
|
|
49
|
+
|
|
50
|
+
if command_exists "bash"; then
|
|
51
|
+
assert_true "true" "Bash command exists"
|
|
52
|
+
else
|
|
53
|
+
assert_true "false" "Bash command exists"
|
|
54
|
+
fi
|
|
55
|
+
|
|
56
|
+
if command_exists "nonexistent_command_xyz"; then
|
|
57
|
+
assert_false "true" "Nonexistent command not found"
|
|
58
|
+
else
|
|
59
|
+
assert_false "false" "Nonexistent command not found"
|
|
60
|
+
fi
|
|
61
|
+
|
|
62
|
+
# Test: validate_dependencies
|
|
63
|
+
echo -e "\nTesting validate_dependencies..."
|
|
64
|
+
|
|
65
|
+
# Test that common dependencies are found
|
|
66
|
+
common_commands=("git" "ruby" "bundle" "jq")
|
|
67
|
+
for cmd in "${common_commands[@]}"; do
|
|
68
|
+
if command_exists "$cmd"; then
|
|
69
|
+
assert_true "true" "Required command exists: $cmd"
|
|
70
|
+
else
|
|
71
|
+
echo -e "${YELLOW}ℹ${NC} Optional command not found: $cmd (skipping)"
|
|
72
|
+
fi
|
|
73
|
+
done
|
|
74
|
+
|
|
75
|
+
echo -e "\n${GREEN}validation.sh tests complete${NC}"
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Unit tests for version.sh library
|
|
4
|
+
|
|
5
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
6
|
+
LIB_DIR="$(cd "$SCRIPT_DIR/../../lib" && pwd)"
|
|
7
|
+
|
|
8
|
+
# Set up test environment
|
|
9
|
+
export DRY_RUN=true
|
|
10
|
+
export INTERACTIVE=false
|
|
11
|
+
export VERBOSE=false
|
|
12
|
+
|
|
13
|
+
# Source the library
|
|
14
|
+
source "$LIB_DIR/version.sh"
|
|
15
|
+
|
|
16
|
+
# Disable errexit for test assertions (sourcing common.sh enables it)
|
|
17
|
+
set +e
|
|
18
|
+
|
|
19
|
+
print_suite_header "version.sh"
|
|
20
|
+
|
|
21
|
+
# Test: validate_version_format
|
|
22
|
+
echo "Testing validate_version_format..."
|
|
23
|
+
|
|
24
|
+
valid_versions=("0.0.1" "1.0.0" "10.20.30" "999.999.999")
|
|
25
|
+
for version in "${valid_versions[@]}"; do
|
|
26
|
+
# Run in subshell because error() calls exit 1
|
|
27
|
+
if (validate_version_format "$version" 2>/dev/null); then
|
|
28
|
+
assert_true "true" "Valid version format accepted: $version"
|
|
29
|
+
else
|
|
30
|
+
assert_true "false" "Valid version format accepted: $version"
|
|
31
|
+
fi
|
|
32
|
+
done
|
|
33
|
+
|
|
34
|
+
invalid_versions=("1.0" "1.0.0.0" "v1.0.0" "1.0.0-beta" "abc.def.ghi")
|
|
35
|
+
for version in "${invalid_versions[@]}"; do
|
|
36
|
+
# Run in subshell because error() calls exit 1
|
|
37
|
+
if (validate_version_format "$version" 2>/dev/null); then
|
|
38
|
+
assert_false "true" "Invalid version format rejected: $version"
|
|
39
|
+
else
|
|
40
|
+
assert_false "false" "Invalid version format rejected: $version"
|
|
41
|
+
fi
|
|
42
|
+
done
|
|
43
|
+
|
|
44
|
+
# Test: calculate_new_version
|
|
45
|
+
echo -e "\nTesting calculate_new_version..."
|
|
46
|
+
|
|
47
|
+
result=$(calculate_new_version "1.2.3" "patch")
|
|
48
|
+
assert_equals "1.2.4" "$result" "Patch bump: 1.2.3 → 1.2.4"
|
|
49
|
+
|
|
50
|
+
result=$(calculate_new_version "1.2.3" "minor")
|
|
51
|
+
assert_equals "1.3.0" "$result" "Minor bump: 1.2.3 → 1.3.0"
|
|
52
|
+
|
|
53
|
+
result=$(calculate_new_version "1.2.3" "major")
|
|
54
|
+
assert_equals "2.0.0" "$result" "Major bump: 1.2.3 → 2.0.0"
|
|
55
|
+
|
|
56
|
+
result=$(calculate_new_version "0.0.9" "patch")
|
|
57
|
+
assert_equals "0.0.10" "$result" "Patch bump with digit rollover: 0.0.9 → 0.0.10"
|
|
58
|
+
|
|
59
|
+
result=$(calculate_new_version "0.9.9" "minor")
|
|
60
|
+
assert_equals "0.10.0" "$result" "Minor bump resets patch: 0.9.9 → 0.10.0"
|
|
61
|
+
|
|
62
|
+
result=$(calculate_new_version "9.9.9" "major")
|
|
63
|
+
assert_equals "10.0.0" "$result" "Major bump resets minor and patch: 9.9.9 → 10.0.0"
|
|
64
|
+
|
|
65
|
+
# Test: version_less_than
|
|
66
|
+
echo -e "\nTesting version_less_than..."
|
|
67
|
+
|
|
68
|
+
if version_less_than "1.0.0" "2.0.0"; then
|
|
69
|
+
assert_true "true" "1.0.0 < 2.0.0"
|
|
70
|
+
else
|
|
71
|
+
assert_true "false" "1.0.0 < 2.0.0"
|
|
72
|
+
fi
|
|
73
|
+
|
|
74
|
+
if version_less_than "1.2.3" "1.2.4"; then
|
|
75
|
+
assert_true "true" "1.2.3 < 1.2.4"
|
|
76
|
+
else
|
|
77
|
+
assert_true "false" "1.2.3 < 1.2.4"
|
|
78
|
+
fi
|
|
79
|
+
|
|
80
|
+
if version_less_than "2.0.0" "1.0.0"; then
|
|
81
|
+
assert_false "true" "2.0.0 not < 1.0.0"
|
|
82
|
+
else
|
|
83
|
+
assert_false "false" "2.0.0 not < 1.0.0"
|
|
84
|
+
fi
|
|
85
|
+
|
|
86
|
+
if version_less_than "1.2.3" "1.2.3"; then
|
|
87
|
+
assert_false "true" "1.2.3 not < 1.2.3 (equal)"
|
|
88
|
+
else
|
|
89
|
+
assert_false "false" "1.2.3 not < 1.2.3 (equal)"
|
|
90
|
+
fi
|
|
91
|
+
|
|
92
|
+
# Test: get_version_from_tag
|
|
93
|
+
echo -e "\nTesting get_version_from_tag..."
|
|
94
|
+
|
|
95
|
+
result=$(get_version_from_tag "v1.2.3")
|
|
96
|
+
assert_equals "1.2.3" "$result" "Remove 'v' prefix: v1.2.3 → 1.2.3"
|
|
97
|
+
|
|
98
|
+
result=$(get_version_from_tag "1.2.3")
|
|
99
|
+
assert_equals "1.2.3" "$result" "No prefix to remove: 1.2.3 → 1.2.3"
|
|
100
|
+
|
|
101
|
+
echo -e "\n${GREEN}version.sh tests complete${NC}"
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Theme validation tests for zer0-mistakes Jekyll theme
|
|
4
|
+
# Usage: ./scripts/test/theme/validate
|
|
5
|
+
|
|
6
|
+
set -euo pipefail
|
|
7
|
+
|
|
8
|
+
# Get script and library directories
|
|
9
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
10
|
+
SCRIPTS_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
|
11
|
+
LIB_DIR="$SCRIPTS_ROOT/lib"
|
|
12
|
+
PROJECT_ROOT="$(cd "$SCRIPTS_ROOT/.." && pwd)"
|
|
13
|
+
|
|
14
|
+
# Source common library for logging and utilities
|
|
15
|
+
source "$LIB_DIR/common.sh"
|
|
16
|
+
|
|
17
|
+
# Test counter
|
|
18
|
+
TESTS_RUN=0
|
|
19
|
+
TESTS_PASSED=0
|
|
20
|
+
|
|
21
|
+
run_test() {
|
|
22
|
+
local test_name="$1"
|
|
23
|
+
local test_command="$2"
|
|
24
|
+
|
|
25
|
+
((TESTS_RUN++)) || true
|
|
26
|
+
|
|
27
|
+
step "Running: $test_name"
|
|
28
|
+
|
|
29
|
+
if [[ "${VERBOSE:-false}" == "true" ]]; then
|
|
30
|
+
debug "Command: $test_command"
|
|
31
|
+
fi
|
|
32
|
+
|
|
33
|
+
if eval "$test_command" > /dev/null 2>&1; then
|
|
34
|
+
success "$test_name"
|
|
35
|
+
((TESTS_PASSED++)) || true
|
|
36
|
+
else
|
|
37
|
+
warn "$test_name - FAILED"
|
|
38
|
+
if [[ "${VERBOSE:-false}" == "true" ]]; then
|
|
39
|
+
echo "Command output:"
|
|
40
|
+
eval "$test_command" 2>&1 || true
|
|
41
|
+
fi
|
|
42
|
+
fi
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
log "Running theme validation tests for zer0-mistakes..."
|
|
46
|
+
|
|
47
|
+
cd "$PROJECT_ROOT"
|
|
48
|
+
|
|
49
|
+
# Test 1: Validate package.json
|
|
50
|
+
run_test "Validate package.json syntax" "jq empty package.json"
|
|
51
|
+
|
|
52
|
+
# Test 2: Validate package.json version
|
|
53
|
+
run_test "Validate package.json version format" "jq -r '.version' package.json | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$'"
|
|
54
|
+
|
|
55
|
+
# Test 3: Validate gemspec syntax
|
|
56
|
+
run_test "Validate gemspec syntax" "ruby -c jekyll-theme-zer0.gemspec"
|
|
57
|
+
|
|
58
|
+
# Test 4: Build gem (test build)
|
|
59
|
+
run_test "Test gem build" "gem build jekyll-theme-zer0.gemspec"
|
|
60
|
+
|
|
61
|
+
# Test 5: Check for required files
|
|
62
|
+
run_test "Check README.md exists" "test -f README.md"
|
|
63
|
+
run_test "Check LICENSE exists" "test -f LICENSE"
|
|
64
|
+
run_test "Check _layouts directory exists" "test -d _layouts"
|
|
65
|
+
run_test "Check _includes directory exists" "test -d _includes"
|
|
66
|
+
run_test "Check _sass directory exists" "test -d _sass"
|
|
67
|
+
run_test "Check assets directory exists" "test -d assets"
|
|
68
|
+
|
|
69
|
+
# Test 6: Validate YAML front matter in layouts
|
|
70
|
+
if [[ -d "_layouts" ]]; then
|
|
71
|
+
for layout in _layouts/*.html; do
|
|
72
|
+
if [[ -f "$layout" ]]; then
|
|
73
|
+
layout_name=$(basename "$layout")
|
|
74
|
+
run_test "Validate front matter in $layout_name" "head -10 '$layout' | grep -q -- '---'"
|
|
75
|
+
fi
|
|
76
|
+
done
|
|
77
|
+
fi
|
|
78
|
+
|
|
79
|
+
# Test 7: Check for common Jekyll requirements
|
|
80
|
+
run_test "Check Jekyll dependency in gemspec" "grep -q 'jekyll' jekyll-theme-zer0.gemspec"
|
|
81
|
+
|
|
82
|
+
# Test 8: Validate version consistency
|
|
83
|
+
PACKAGE_VERSION=$(jq -r '.version' package.json)
|
|
84
|
+
if [[ -f "jekyll-theme-zer0-${PACKAGE_VERSION}.gem" ]]; then
|
|
85
|
+
run_test "Version consistency check" "test -f jekyll-theme-zer0-${PACKAGE_VERSION}.gem"
|
|
86
|
+
fi
|
|
87
|
+
|
|
88
|
+
# Test 9: Check scripts are executable
|
|
89
|
+
if [[ -d "scripts/bin" ]]; then
|
|
90
|
+
for script in scripts/bin/*; do
|
|
91
|
+
if [[ -f "$script" ]]; then
|
|
92
|
+
script_name=$(basename "$script")
|
|
93
|
+
run_test "Check $script_name is executable" "test -x '$script'"
|
|
94
|
+
fi
|
|
95
|
+
done
|
|
96
|
+
fi
|
|
97
|
+
|
|
98
|
+
# Test 10: Validate bundle install
|
|
99
|
+
run_test "Test bundle install" "bundle install --quiet"
|
|
100
|
+
|
|
101
|
+
# Clean up test gem file
|
|
102
|
+
rm -f jekyll-theme-zer0-*.gem 2>/dev/null || true
|
|
103
|
+
|
|
104
|
+
# Test results
|
|
105
|
+
echo ""
|
|
106
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
107
|
+
info "Test Results"
|
|
108
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
109
|
+
echo " Tests run: $TESTS_RUN"
|
|
110
|
+
echo " Tests passed: $TESTS_PASSED"
|
|
111
|
+
echo " Tests failed: $((TESTS_RUN - TESTS_PASSED))"
|
|
112
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
113
|
+
|
|
114
|
+
if [[ $TESTS_PASSED -eq $TESTS_RUN ]]; then
|
|
115
|
+
success "All tests passed!"
|
|
116
|
+
exit 0
|
|
117
|
+
else
|
|
118
|
+
error "Some tests failed!"
|
|
119
|
+
exit 1
|
|
120
|
+
fi
|