#!/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/openapi3/elm.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" "${root}/bin/scala-akka-petstore.sh" "${root}/bin/openapi3/scala-akka-petstore.sh" "${root}/bin/openapi3/scala-sttp-petstore.sh" "${root}/bin/lua-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