Skip to content

Commit d8176cf

Browse files
committed
Run the api import in parallel
1 parent df299ad commit d8176cf

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

.github/update-templates.sh

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,31 @@ updateAll() {
1818

1919
for dir in ../*; do
2020
if [[ -d "$dir" ]]; then
21-
22-
set +e
23-
(update "${dir#../}" "$wiremock_cloud_url" "$wiremock_cloud_username" "$wiremock_cloud_api_token")
24-
local result=$?
25-
set -e
26-
27-
if [[ result -eq 0 ]]; then
28-
echo "Imported $dir"
29-
else
30-
>&2 echo "Failed to import $dir"
21+
(updateAsync) &
22+
if [[ $(jobs -r -p | wc -l) -ge 10 ]]; then
23+
# now there are $N jobs already running, so wait here for any job
24+
# to be finished so there is a place to start next one.
25+
wait -n
3126
fi
3227
fi
3328
done
29+
30+
wait
31+
32+
echo "All imported"
33+
}
34+
35+
updateAsync() {
36+
set +e
37+
(update "${dir#../}" "$wiremock_cloud_url" "$wiremock_cloud_username" "$wiremock_cloud_api_token")
38+
local result=$?
39+
set -e
40+
41+
if [[ result -eq 0 ]]; then
42+
echo "Imported $dir"
43+
else
44+
>&2 echo "Failed to import $dir"
45+
fi
3446
}
3547

3648
update() {
@@ -89,4 +101,4 @@ curl_auth() {
89101
"$@"
90102
}
91103

92-
update "$@"
104+
updateAll "$@"

0 commit comments

Comments
 (0)