1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

ci: SQLite upgrade testing comments

This commit is contained in:
Steven Tang 2022-12-06 18:28:23 +11:00
parent 5242df2b7d
commit f5395e36ad
No known key found for this signature in database
GPG Key ID: 1597520C734BAE66
2 changed files with 21 additions and 10 deletions

View File

@ -117,4 +117,4 @@ jobs:
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Run sqlite - name: Run sqlite
run: ./testing/run_api_tests.sh sqlite y run: ./testing/run_api_tests.sh sqlite --migration

View File

@ -1,5 +1,4 @@
#!/bin/bash #!/bin/bash
set -e
if ! command -v newman &> /dev/null if ! command -v newman &> /dev/null
then then
@ -7,6 +6,15 @@ then
exit 1 exit 1
fi fi
for i in "$@"; do
case $i in
--migration)
MIGRATION=1
shift
;;
esac
done
script_path=$(realpath "${BASH_SOURCE[0]}") script_path=$(realpath "${BASH_SOURCE[0]}")
script_dir=$(dirname "$script_path") script_dir=$(dirname "$script_path")
@ -16,13 +24,14 @@ echo "Compiling."
cd "$script_dir" || exit 1 cd "$script_dir" || exit 1
# Download previous release (when upgrade testing) # Download previous release (when upgrade testing)
INITIAL_RUN_EXE="../wakapi" initial_run_exe="../wakapi"
if [[ "$2" == "y" ]]; then if [[ $MIGRATION -eq 1 ]]; then
if [ ! -f wakapi_linux_amd64.zip ]; then if [ ! -f wakapi_linux_amd64.zip ]; then
echo "Downloading latest release"
curl https://github.com/muety/wakapi/releases/latest/download/wakapi_linux_amd64.zip -O -L curl https://github.com/muety/wakapi/releases/latest/download/wakapi_linux_amd64.zip -O -L
fi fi
unzip -o wakapi_linux_amd64.zip unzip -o wakapi_linux_amd64.zip
INITIAL_RUN_EXE="./wakapi" initial_run_exe="./wakapi"
echo "Running tests with release version" echo "Running tests with release version"
fi fi
@ -37,7 +46,7 @@ case $1 in
echo "Importing seed data ..." echo "Importing seed data ..."
sqlite3 wakapi_testing.db < data.sql sqlite3 wakapi_testing.db < data.sql
CONFIG="config.testing.yml" config="config.testing.yml"
;; ;;
esac esac
@ -54,13 +63,15 @@ wait_for_wakapi () {
sleep 1 sleep 1
counter=$((counter+1)) counter=$((counter+1))
done done
sleep 1
printf "\n" printf "\n"
} }
# Run tests # Run tests
echo "Running Wakapi testing instance in background ..." echo "Running Wakapi testing instance in background ..."
"$INITIAL_RUN_EXE" -config "$CONFIG" & "$initial_run_exe" -config "$config" &
pid=$! pid=$!
wait_for_wakapi
echo "Running test collection ..." echo "Running test collection ..."
newman run "wakapi_api_tests.postman_collection.json" newman run "wakapi_api_tests.postman_collection.json"
@ -70,9 +81,9 @@ echo "Shutting down Wakapi ..."
kill -TERM $pid kill -TERM $pid
# Run upgrade tests # Run upgrade tests
if [[ "$2" == "y" ]]; then if [[ $MIGRATION -eq 1 ]]; then
echo "Now running migrations with build" echo "Running migrations with build"
../wakapi -config "$CONFIG" & ../wakapi -config "$config" &
pid=$! pid=$!
wait_for_wakapi wait_for_wakapi