generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add staging tests during JAR release
- Loading branch information
Showing
3 changed files
with
123 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
export PATH="$PWD/build/release:$PATH" | ||
|
||
info() { | ||
echo -e "\033[1;32m$*\033[0m" | ||
} | ||
|
||
error() { | ||
echo -e "\033[1;31m$*\033[0m" | ||
exit 1 | ||
} | ||
|
||
pull_staging_release() { | ||
info "Pulling release JARs from Sonatype OSSRH Staging" | ||
local version=$1 | ||
|
||
mvn dependency:get \ | ||
-DremoteRepositories=ossrh::default::https://s01.oss.sonatype.org/content/repositories/staging/ \ | ||
-Dartifact=xyz.block:ftl-runtime:${version}:jar -Dtransitive=false \ | ||
-Ddest=kotlin-runtime/ftl-runtime/target/ftl-runtime-${version}.jar | ||
|
||
mvn dependency:get \ | ||
-DremoteRepositories=ossrh::default::https://s01.oss.sonatype.org/content/repositories/staging/ \ | ||
-Dartifact=xyz.block:ftl-generator:${version}:jar:jar-with-dependencies -Dtransitive=false \ | ||
-Ddest=kotlin-runtime/ftl-generator/target/ftl-generator-${version}.jar | ||
} | ||
|
||
wait_for() { | ||
info "Waiting for $1" | ||
for _ in {1..240}; do | ||
if eval "$2"; then | ||
info "Success!" | ||
return 0 | ||
fi | ||
sleep 1 | ||
done | ||
error "Timed out waiting for $1" | ||
} | ||
|
||
stop_cluster() { | ||
kill %1 | ||
wait | ||
} | ||
|
||
start_cluster() { | ||
info "Starting cluster" | ||
ftl serve --recreate & | ||
wait_for "cluster to become ready" "ftl status" | ||
trap stop_cluster EXIT INT TERM | ||
} | ||
|
||
deploy_echo_kotlin() ( | ||
info "Deploying echo-kotlin" | ||
ftl deploy examples/kotlin/ftl-module-echo | ||
) | ||
|
||
deploy_fresh_kotlin() ( | ||
info "Deploying newly initialised Kotlin module" | ||
IT_MODULES=build/modules | ||
rm -rf "${IT_MODULES}" | ||
ftl init kotlin "${IT_MODULES}" echo2 | ||
ftl init kotlin "${IT_MODULES}" echo3 | ||
cd "${IT_MODULES}" | ||
ftl deploy ftl-module-echo2 | ||
ftl deploy ftl-module-echo3 | ||
) | ||
|
||
deploy_time_go() ( | ||
info "Deploying time" | ||
cd examples | ||
# Pull a supported platforms from the cluster. | ||
platform="$(ftl status | jq -r '(.runners // [])[].labels | "\(.os)-\(.arch)"' | sort | uniq | head -1)" | ||
ftl-go --os "${platform%-*}" --arch "${platform#*-}" deploy time | ||
) | ||
|
||
wait_for_deploys() { | ||
wait_for "deployments to come up" 'ftl status | jq -r "(.routes // [])[].module" | sort | paste -sd " " - | grep -q "echo echo2 echo3 time"' | ||
} | ||
|
||
pull_staging_release $1 | ||
start_cluster | ||
|
||
# Cluster is up, start interacting with it. | ||
deploy_time_go | ||
deploy_echo_kotlin | ||
deploy_fresh_kotlin | ||
|
||
wait_for_deploys | ||
|
||
info "Calling echo" | ||
message="$(ftl call echo.echo '{"name": "Alice"}' | jq -r .message)" | ||
[[ "$message" =~ "Hello, Alice! The time is " ]] || error "Unexpected response from echo: $message" | ||
|
||
message="$(ftl call echo2.echo '{"name": "Alice"}' | jq -r .message)" | ||
[[ "$message" =~ "Hello, Alice!" ]] || error "Unexpected response from echo2: $message" | ||
|
||
message="$(ftl call echo3.echo '{"name": "Alice"}' | jq -r .message)" | ||
[[ "$message" =~ "Hello, Alice!" ]] || error "Unexpected response from echo2: $message" | ||
|
||
info "Success!" |