34
34
35
35
echo "::set-output name=SCRIPTS_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- scripts | wc -l)"
36
36
37
+ echo "::set-output name=JS_CLIENT_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- clients/algoliasearch-client-javascript | wc -l)"
38
+ echo "::set-output name=JS_TEMPLATE_CHANGED::$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- templates/javascript | wc -l)"
39
+
37
40
- name : Compute specs matrix
38
41
id : spec-matrix
39
42
shell : bash
@@ -58,20 +61,58 @@ runs:
58
61
if [[ $specs == "" ]]; then
59
62
# client cannot be empty or the matrix will fail
60
63
specs_matrix='{"client":["no-run"]}'
61
- run_specs=0
64
+ run_specs="false"
62
65
else
63
66
specs_matrix=$((
64
67
echo '{ "client" : ['
65
68
echo $specs | xargs | sed 's/ /, /g' | xargs -n 1 echo | sed -r 's/^([^,]*)(,?)$/"\1"\2/'
66
69
echo " ]}"
67
70
) | jq -c .)
68
- run_specs=1
71
+ run_specs="true"
69
72
fi
70
73
echo $specs_matrix
71
74
echo "Run specs: $run_specs"
72
75
echo ::set-output name=SPECS_MATRIX::$specs_matrix
73
76
echo ::set-output name=RUN_SPECS::$run_specs
74
77
78
+ - name : Compute JS client build matrix
79
+ id : js-matrix
80
+ shell : bash
81
+ run : |
82
+ # Read from openapitools.json to get the clients and folders (not pretty jq)
83
+ clients=$(cat openapitools.json | jq '."generator-cli".generators | with_entries(if (.key | test("javascript-.*")) then ({key:.key,value:.value}) else empty end) | to_entries | map({client:.key | sub("javascript-";""),folder:.value.output | sub("#{cwd}/";"")}) | .[]')
84
+
85
+ base_changed=${{ github.ref == 'refs/heads/main' || steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.COMMON_SPECS_CHANGED > 0 || steps.diff.outputs.SCRIPTS_CHANGED > 0 || steps.diff.outputs.JS_TEMPLATE_CHANGED > 0 }}
86
+
87
+ to_test='{"client": []}'
88
+ for pair in "${clients[@]}"; do
89
+ client=$(echo $pair | jq '.client')
90
+ folder=$(echo $pair | jq '.folder')
91
+ spec_changed=$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- specs/$client | wc -l)
92
+ client_changed=$(git diff --shortstat origin/${{ github.base_ref }}..HEAD -- $folder | wc -l)
93
+ if [[ $base_changed || $spec_changed > 0 || $client_changed > 0 ]]; then
94
+ to_test="$to_test $client"
95
+ fi
96
+ done
97
+
98
+ # Convert the array to json for the matrix
99
+ if [[ $to_test == "" ]]; then
100
+ # client cannot be empty or the matrix will fail
101
+ js_matrix='{"client":["no-run"]}'
102
+ run_js="false"
103
+ else
104
+ js_matrix=$((
105
+ echo '{ "client" : ['
106
+ echo $to_test | xargs | sed 's/ /, /g' | xargs -n 1 echo | sed -r 's/^([^,]*)(,?)$/"\1"\2/'
107
+ echo " ]}"
108
+ ) | jq -c .)
109
+ run_js="true"
110
+ fi
111
+ echo $js_matrix
112
+ echo "Run JS: $run_js"
113
+ echo ::set-output name=JS_MATRIX::$js_matrix
114
+ echo ::set-output name=RUN_JS::$run_js
115
+
75
116
outputs :
76
117
RUN_SPECS :
77
118
description : Whether to run specs or not
@@ -81,6 +122,14 @@ outputs:
81
122
description : Generate the matrix for specs
82
123
value : ${{ steps.spec-matrix.outputs.SPECS_MATRIX }}
83
124
125
+ RUN_JS :
126
+ description : Whether to run specs or not
127
+ value : ${{ steps.js-matrix.outputs.RUN_JS }}
128
+
129
+ JS_MATRIX :
130
+ description : Generate the matrix for specs
131
+ value : ${{ steps.js-matrix.outputs.JS_MATRIX }}
132
+
84
133
RUN_CTS :
85
134
description : Determine if the `cts` job should run
86
135
value : ${{ github.ref_name == 'main' || steps.diff.outputs.GITHUB_ACTIONS_CHANGED > 0 || steps.diff.outputs.SPECS_CHANGED > 0 || steps.diff.outputs.TESTS_CHANGED > 0 || steps.diff.outputs.JS_CLIENT_CHANGED > 0 || steps.diff.outputs.JS_TEMPLATE_CHANGED > 0 || steps.diff.outputs.JAVA_CLIENT_CHANGED > 0 || steps.diff.outputs.JAVA_TEMPLATE_CHANGED > 0 }}
0 commit comments