@@ -13,15 +13,18 @@ inputs:
13
13
dir :
14
14
description : App/package directory
15
15
required : true
16
+ pattern : " ^[a-zA-Z0-9._/-]+$"
16
17
17
18
node_version :
18
- description : Node version to use
19
+ description : Node version to use (e.g., '18', '20', '22')
19
20
required : true
21
+ pattern : ' ^[0-9]+(\.[0-9]+)*$'
20
22
21
23
# ## Typical / recommended
22
24
cache :
23
25
description : Package manager for caching; e.g. npm, yarn, pnpm
24
26
default : npm
27
+ pattern : " ^(npm|yarn|pnpm)$"
25
28
26
29
sonar_args :
27
30
# https://docs.sonarcloud.io/advanced-setup/analysis-parameters/
@@ -32,6 +35,7 @@ inputs:
32
35
33
36
sonar_token :
34
37
description : Sonar token, provide unpopulated token for pre-setup (will skip)
38
+ pattern : " ^[a-zA-Z0-9]{20,}$"
35
39
36
40
triggers :
37
41
description : Paths (array) used to trigger a build; e.g. ('./backend/' './frontend/)
@@ -40,14 +44,17 @@ inputs:
40
44
diff_branch :
41
45
description : Branch to diff against
42
46
default : ${{ github.event.repository.default_branch }}
47
+ pattern : " ^[a-zA-Z0-9._/-]+$"
43
48
44
49
repository :
45
50
description : Non-default repository to clone (used for testing this action)
46
51
default : ${{ github.repository }}
52
+ pattern : " ^[a-zA-Z0-9-_]+/[a-zA-Z0-9-_]+$"
47
53
48
54
branch :
49
55
description : Non-default branch to clone (used for testing this action)
50
56
default : " "
57
+ pattern : " ^[a-zA-Z0-9._/-]*$"
51
58
52
59
outputs :
53
60
triggered :
@@ -61,24 +68,14 @@ runs:
61
68
shell : bash
62
69
run : |
63
70
# Warnings for breaking changes
64
-
65
- # node_version now required
66
- if [ -z "${{ inputs.node_version }}" ]; then
67
- echo -e "\nnode_version now required. Previous default: 16."
68
- echo -e "\n\tAction: add a node_version parameter\n"
69
- exit 1
70
- fi
71
-
72
- # sonar_project_token renamed sonar_token
73
71
if [ ! -z "${{ inputs.sonar_project_token }}" ]; then
74
- echo -e "\nsonar_project_token renamed. Please correct this and try again. "
72
+ echo -e "\n⚠️ Breaking change: sonar_project_token renamed "
75
73
echo -e "\n\tAction: rename sonar_project_token to sonar_token\n"
76
74
exit 1
77
75
fi
78
76
79
- #
80
77
if [ ! -z "${{ inputs.sonar_comment_token }}" ]; then
81
- echo -e "\nsonar_comment_token deprecated. Please correct this and try again. "
78
+ echo -e "\n⚠️ Breaking change: sonar_comment_token deprecated "
82
79
echo -e "\n\tAction: remove sonar_comment_token parameter\n"
83
80
exit 1
84
81
fi
@@ -110,8 +107,35 @@ runs:
110
107
shell : bash
111
108
working-directory : ${{ inputs.dir }}
112
109
run : |
113
- # Run Tests
114
- ${{ inputs.commands }}
110
+ echo "🚀 Running test commands in ${{ inputs.dir }}..."
111
+ echo "Commands: ${{ inputs.commands }}"
112
+
113
+ # Run Tests with error handling
114
+ if ! (${{ inputs.commands }}); then
115
+ echo ""
116
+ echo "❌ Test commands failed!"
117
+ echo ""
118
+ echo "🔧 Common troubleshooting steps:"
119
+ echo " 1. Check if package.json exists and has test scripts"
120
+ echo " 2. Verify all dependencies are installed (npm ci)"
121
+ echo " 3. Check if test files exist and are properly configured"
122
+ echo " 4. Ensure Node.js version compatibility"
123
+ echo ""
124
+ echo "📋 Debug information:"
125
+ echo " - Working directory: $(pwd)"
126
+ echo " - Node version: $(node --version)"
127
+ echo " - NPM version: $(npm --version)"
128
+ echo " - Available scripts:"
129
+ if [ -f package.json ]; then
130
+ npm run 2>/dev/null | grep -E '^ [a-z]' | head -10 || echo " (no scripts found)"
131
+ else
132
+ echo " (no package.json found)"
133
+ fi
134
+ echo ""
135
+ exit 1
136
+ fi
137
+
138
+ echo "✅ Test commands completed successfully"
115
139
116
140
# ## Optional SonarCloud
117
141
0 commit comments