-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidate-action.sh
More file actions
executable file
·152 lines (129 loc) · 3.46 KB
/
validate-action.sh
File metadata and controls
executable file
·152 lines (129 loc) · 3.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/bin/bash
# Validation script for action.yml
# This script validates the GitHub Action configuration
set -e
echo "🔍 Validating Aptos CLI Action Configuration"
echo "============================================"
# Check if action.yml exists
if [ ! -f "action.yml" ]; then
echo "❌ action.yml not found"
exit 1
fi
echo "✅ action.yml found"
# Check required fields
echo ""
echo "📋 Checking Required Fields"
echo "---------------------------"
# Check name
if grep -q "^name:" action.yml; then
echo "✅ name field present"
else
echo "❌ name field missing"
exit 1
fi
# Check description
if grep -q "^description:" action.yml; then
echo "✅ description field present"
else
echo "❌ description field missing"
exit 1
fi
# Check inputs
if grep -q "^inputs:" action.yml; then
echo "✅ inputs section present"
else
echo "❌ inputs section missing"
exit 1
fi
# Check runs
if grep -q "^runs:" action.yml; then
echo "✅ runs section present"
else
echo "❌ runs section missing"
exit 1
fi
# Check using
if grep -q "using: \"composite\"" action.yml; then
echo "✅ using: composite present"
else
echo "❌ using: composite missing"
exit 1
fi
# Check steps
if grep -q "^ steps:" action.yml; then
echo "✅ steps section present"
else
echo "❌ steps section missing"
exit 1
fi
# Check for required steps
echo ""
echo "📋 Checking Required Steps"
echo "--------------------------"
required_steps=(
"Get version tag"
"Build download URL"
"Download ZIP archive"
"Unpack & install"
"Verify installation"
)
for step in "${required_steps[@]}"; do
if grep -q "name: $step" action.yml; then
echo "✅ Step '$step' present"
else
echo "❌ Step '$step' missing"
exit 1
fi
done
# Check YAML syntax
echo ""
echo "📋 Checking YAML Syntax"
echo "----------------------"
# Check for basic YAML structure
if command -v python3 >/dev/null 2>&1; then
if python3 -c "import yaml" 2>/dev/null; then
if python3 -c "import yaml; yaml.safe_load(open('action.yml'))" 2>/dev/null; then
echo "✅ YAML syntax is valid"
else
echo "❌ YAML syntax is invalid"
exit 1
fi
else
echo "⚠️ PyYAML not available, skipping YAML syntax check"
fi
else
echo "⚠️ Python3 not available, skipping YAML syntax check"
fi
# Check for common issues
echo ""
echo "📋 Checking for Common Issues"
echo "----------------------------"
# Check for proper indentation
if grep -q "^[[:space:]]*[^[:space:]]" action.yml; then
echo "✅ Proper indentation detected"
else
echo "⚠️ Indentation might be incorrect"
fi
# Check for proper shell specification
if grep -q "shell: bash" action.yml; then
echo "✅ bash shell specified"
else
echo "⚠️ bash shell not specified for all steps"
fi
# Check for proper PowerShell specification on Windows
if grep -q "shell: pwsh" action.yml; then
echo "✅ PowerShell specified for Windows"
else
echo "⚠️ PowerShell not specified for Windows steps"
fi
# Check for proper conditional statements
if grep -q "if: runner.os" action.yml; then
echo "✅ OS-specific conditions present"
else
echo "⚠️ OS-specific conditions might be missing"
fi
echo ""
echo "🎉 Action validation completed!"
echo "=============================="
echo "The action.yml file appears to be properly configured."
echo "You can now use this action in your GitHub workflows."