forked from OpenAPITools/openapi-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathensure-up-to-date
executable file
·140 lines (130 loc) · 5.1 KB
/
ensure-up-to-date
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
#!/usr/bin/env bash
# this bash script runs the scripts for the 'mature' generators by default.
# Supports --batch option which will compile all generators defined under bin/ci/*.json
# it ensures that all changes are committed into the 'samples/' folder
# shellcheck disable=SC2155
declare cwd="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
declare root="$(cd "$cwd" && cd ../../ && pwd)"
declare executable="${root}/modules/openapi-generator-cli/target/openapi-generator-cli.jar"
declare batch_mode="false"
echo "# START SCRIPT: $0"
echo "IMPORTANT: this script should be run by the CI (e.g. Shippable) to ensure that the 'samples/' folder is up to date."
if [ "--batch" = "$1" ]; then
batch_mode="true"
echo "Running in 'batch mode' (single JVM, mutliple threads)."
else
echo "When running locally execute with argument --batch."
fi
echo "Please press CTRL+C to stop or the script will continue in 5 seconds."
sleep 5
declare -a samples=(
"${root}/bin/ruby-client-petstore.sh"
"${root}/bin/ruby-client-petstore-faraday.sh"
"${root}/bin/openapi3/ruby-client-petstore.sh"
"${root}/bin/openapi3/ruby-client-faraday-petstore.sh"
"${root}/bin/java-petstore-all.sh"
"${root}/bin/java-jaxrs-petstore-server-all.sh"
"${root}/bin/java-msf4j-petstore-server.sh"
"${root}/bin/openapi3/jaxrs-jersey-petstore.sh"
"${root}/bin/spring-all-petstore.sh"
"${root}/bin/javascript-petstore-all.sh"
"${root}/bin/kotlin-client-all.sh"
"${root}/bin/kotlin-server-petstore.sh"
"${root}/bin/kotlin-springboot-petstore-server.sh"
"${root}/bin/kotlin-springboot-petstore-server-reactive.sh"
"${root}/bin/mysql-schema-petstore.sh"
"${root}/bin/nim-client-petstore.sh"
"${root}/bin/python-petstore-all.sh"
"${root}/bin/python-server-all.sh"
"${root}/bin/openapi3/python-petstore.sh"
"${root}/bin/openapi3/python-experimental-petstore.sh"
"${root}/bin/php-petstore.sh"
"${root}/bin/php-silex-petstore-server.sh"
"${root}/bin/php-symfony-petstore.sh"
"${root}/bin/php-lumen-petstore-server.sh"
"${root}/bin/php-slim-server-petstore.sh"
#"${root}/bin/php-slim4-server-petstore.sh"
"${root}/bin/php-ze-ph-petstore-server.sh"
"${root}/bin/openapi3/php-petstore.sh"
"${root}/bin/typescript-angularjs-petstore.sh"
"${root}/bin/typescript-angular-petstore-all.sh"
"${root}/bin/typescript-aurelia-petstore.sh"
"${root}/bin/typescript-axios-petstore-all.sh"
"${root}/bin/typescript-fetch-petstore-all.sh"
"${root}/bin/typescript-inversify-petstore.sh"
"${root}/bin/typescript-jquery-petstore-all.sh"
"${root}/bin/typescript-node-petstore-all.sh"
"${root}/bin/typescript-rxjs-petstore-all.sh"
"${root}/bin/rust-server-petstore.sh"
"${root}/bin/r-petstore.sh"
"${root}/bin/haskell-http-client-petstore.sh"
"${root}/bin/csharp-petstore.sh"
"${root}/bin/csharp-netcore-petstore-all.sh"
"${root}/bin/elixir-petstore.sh"
"${root}/bin/openapi3/go-petstore.sh"
"${root}/bin/openapi3/go-experimental-petstore.sh"
"${root}/bin/go-experimental-petstore.sh"
"${root}/bin/go-petstore.sh"
"${root}/bin/go-petstore-withxml.sh"
"${root}/bin/go-petstore-server.sh"
"${root}/bin/go-gin-petstore-server.sh"
"${root}/bin/groovy-petstore.sh"
"${root}/bin/apex-petstore.sh"
"${root}/bin/perl-petstore-all.sh"
"${root}/bin/dart-jaguar-petstore.sh"
#"${root}/bin/dart-dio-petstore.sh"
"${root}/bin/dart-petstore.sh"
"${root}/bin/dart2-petstore.sh"
"${root}/bin/java-play-framework-petstore-server-all.sh"
#"${root}/bin/elm-petstore-all.sh"
"${root}/bin/typescript-redux-query-petstore-with-npm-version.sh"
"${root}/bin/cpp-restsdk-petstore.sh"
"${root}/bin/cpp-qt5-qhttpengine-server-petstore.sh"
#"${root}/bin/openapi3/powershell-experimental-petstore.sh"
)
# Some special case generators may expect to be run as a stanalone process (e.g. modifying classpath)
# Docs should always be run, regardless of batch or operation.
declare -a always_iterate=(
"${root}/bin/meta-codegen.sh"
"${root}/bin/utils/export_docs_generators.sh"
"${root}/bin/utils/copy-to-website.sh"
"${root}/bin/utils/export_generators_readme.sh"
)
export JAVA_OPTS="${JAVA_OPTS} -Djava.awt.headless=true -Dorg.slf4j.simpleLogger.defaultLogLevel=warn"
if [ "true" = "$batch_mode" ]; then
if [ ! -f "$executable" ]; then
(cd "${root}" && mvn -B clean package -DskipTests=true -Dmaven.javadoc.skip=true)
fi
# shellcheck disable=SC2086
java $JAVA_OPTS -jar "$executable" batch --includes-base-dir "${root}" --fail-fast -- "${root}"/bin/ci/*
else
for script in "${samples[@]}"; do
if eval "$script" > /dev/null 2>&1; then
echo "Executed $script successfully!"
else
echo "ERROR: Failed to run $script"
exit 1
fi
done
fi
for i in "${always_iterate[@]}"; do
if eval "$i" > /dev/null 2>&1; then
echo "Executed $i successfully!"
else
echo "ERROR: Failed to run $i"
exit 1
fi
done
# Check:
if [ -n "$(git status --porcelain)" ]; then
echo "UNCOMMITTED CHANGES ERROR"
echo "There are uncommitted changes in working tree after execution of 'bin/ensure-up-to-date'"
echo "Perform git diff"
git --no-pager diff
echo "Perform git status"
git status
echo "Please run 'bin/utils/ensure-up-to-date' locally and commit changes (UNCOMMITTED CHANGES ERROR)"
exit 1
else
echo "Git working tree is clean"
fi