Skip to content

Commit

Permalink
Consolidate setupTestEnv, cleanTestEnv, and startTestEnv
Browse files Browse the repository at this point in the history
- `startTestingEnv` is now `startTestEnv`
- `setupTestEnvLocal` is now `setupTestEnv --local` or `setupTestEnv`
- `cleanTestEnvLocal` is now `cleanTestEnv --local` or `cleanTestEnv`
- `setupTestEnvCicd` is now `setupTestEnv --cicd`
- `cleanTestEnvCicd` is now `cleanTestEnv --cicd`
  • Loading branch information
JeremyEastham committed Apr 22, 2022
1 parent be681f3 commit 8f34d07
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 201 deletions.
2 changes: 1 addition & 1 deletion .idea/runConfigurations/Run_All_Tests.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/runConfigurations/Start_Testing_Environment.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docker/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Docker image for testing

- the script `createPostgresqlImage.sh` here is used to create docker image with postgresql plugin.
- Before the user runs this script, they need to start the testing env (i.e. `./startTestingEnv --wait`).
- Before the user runs this script, they need to start the testing env (i.e. `./startTestEnv --wait`).
- This script can only be used for postgresql plugin. No other plugin is supported. So before running the script, make sure to switch to postgresql-plugin in the `modules.txt`.


Expand Down
8 changes: 4 additions & 4 deletions runCore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

function cleanup {
kill %1 > /dev/null # Send exit to startTestingEnv
kill %1 > /dev/null # Send exit to startTestEnv
}

usage="Usage: runCore [--help] [--silent] [--cicd] [--force]"
Expand All @@ -24,15 +24,15 @@ done
if [[ $force = true && -f .testEnvRunning ]]; then
[[ $silent = false ]] && echo "Removing previous testing environment..."
if [[ $cicd = true ]]; then
./utils/cleanTestEnvCicd
./utils/cleanTestEnv --cicd
else
./utils/cleanTestEnvLocal
./utils/cleanTestEnv --local
fi
fi

trap cleanup EXIT

./startTestingEnv --wait --silent & # Run in background
./startTestEnv --wait --silent & # Run in background

[[ $silent = false ]] && echo "Waiting for testing environment to start..."
until [[ -f .testEnvRunning ]]
Expand Down
10 changes: 5 additions & 5 deletions startTestingEnv → startTestEnv
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

function cleanup {
if [[ $cicd = true ]]; then
./utils/cleanTestEnvCicd
./utils/cleanTestEnv --cicd
else
./utils/cleanTestEnvLocal
./utils/cleanTestEnv --local
fi
}

usage="Usage: startTestingEnv [--help] [--wait] [--silent] [--cicd] [--force]"
usage="Usage: startTestEnv [--help] [--wait] [--silent] [--cicd] [--force]"
wait=false
silent=false
cicd=false
Expand Down Expand Up @@ -36,9 +36,9 @@ trap cleanup EXIT

[[ $silent = false ]] && echo "Setting up testing environment..."
if [[ $cicd = true ]]; then
./utils/setupTestEnvCicd
./utils/setupTestEnv --cicd
else
./utils/setupTestEnvLocal
./utils/setupTestEnv --local
fi


Expand Down
27 changes: 27 additions & 0 deletions utils/cleanTestEnv
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

usage="Usage: cleanTestEnv [--help] [ [--cicd] | [--local] ]"
cicd=false

# Based on https://stackoverflow.com/a/33826763/11827673
while [[ "$#" -gt 0 ]]; do
case $1 in
-h|--help) echo "$usage"; exit ;;
-c|--cicd) cicd=true ;;
-l|--local) cicd=false ;;
*) echo "Unknown parameter passed: $1"; echo "$usage"; exit 1 ;;
esac
shift
done

rm -rf core
rm -rf plugin-interface
rm -rf plugin
rm -rf cli
rm -rf downloader
rm version.yaml
rm -rf temp
rm install
rm install.bat
rm LICENSE.md
rm .testEnvRunning
12 changes: 0 additions & 12 deletions utils/cleanTestEnvCicd

This file was deleted.

12 changes: 0 additions & 12 deletions utils/cleanTestEnvLocal

This file was deleted.

59 changes: 54 additions & 5 deletions utils/setupTestEnvLocal → utils/setupTestEnv
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
#!/bin/bash

usage="Usage: setupTestEnvLocal [--help] [ [--cicd] | [--local] ]"
cicd=false

# Based on https://stackoverflow.com/a/33826763/11827673
while [[ "$#" -gt 0 ]]; do
case $1 in
-h|--help) echo "$usage"; exit ;;
-c|--cicd) cicd=true ;;
-l|--local) cicd=false ;;
*) echo "Unknown parameter passed: $1"; echo "$usage"; exit 1 ;;
esac
shift
done

# load version and jars
# setup jars, dependencies and version

./gradlew clean
Expand Down Expand Up @@ -43,7 +59,9 @@ do
(cd $dir_name/downloader/ && ./runBuild noJarFolderChange)
mkdir core > /dev/null 2>&1
cp $dir_name/build/libs/* core
cp $dir_name/build/dependencies/* core > /dev/null 2>&1
if [[ $cicd = false ]]; then
cp $dir_name/build/dependencies/* core > /dev/null 2>&1
fi

# add to version_temp.yaml
core_version=`cat $dir_name/build.gradle | grep -e "version =" -e "version="`
Expand All @@ -58,10 +76,24 @@ do
done
done <<< "$core_version"
echo "core_version: $core_version" >> version_temp.yaml


if [[ $cicd = true ]]; then
curl -X GET \
"https://api.supertokens.io/core/dependency/jars?version=$core_version&planType=FREE&mode=DEV&withSource=false" \
-H 'api-version: 0' | jq '.links' | jq -c '.[]' | while read i; do \
wget -P core/ `echo $i | sed -e 's/^"//' -e 's/"$//'`; done
fi
mkdir cli > /dev/null 2>&1
cp $dir_name/cli/build/libs/* cli
cp $dir_name/cli/build/dependencies/* cli > /dev/null 2>&1
if [[ $cicd = true ]]; then
curl -X GET \
"https://api.supertokens.io/cli/dependency/jars?version=$core_version&planType=FREE&mode=DEV
&withSource=false" \
-H 'api-version: 0' | jq '.links' | jq -c '.[]' | while read i; do \
wget -P cli/ `echo $i | sed -e 's/^"//' -e 's/"$//'`; done
else
cp $dir_name/cli/build/dependencies/* cli > /dev/null 2>&1
fi

mkdir downloader > /dev/null 2>&1
cp $dir_name/downloader/build/libs/* downloader
Expand All @@ -74,7 +106,9 @@ do
then
mkdir plugin-interface > /dev/null 2>&1
cp $dir_name/build/libs/* plugin-interface
cp $dir_name/build/dependencies/* plugin-interface > /dev/null 2>&1
if [[ $cicd = false ]]; then
cp $dir_name/build/dependencies/* plugin-interface > /dev/null 2>&1
fi

# add to version_temp.yaml
pi_version=`cat $dir_name/build.gradle | grep -e "version =" -e "version="`
Expand All @@ -90,11 +124,20 @@ do
done <<< "$pi_version"
echo "plugin_interface_version: $pi_version" >> version_temp.yaml

if [[ $cicd = true ]]; then
curl -X GET \
"https://api.supertokens.io/plugin-interface/dependency/jars?version=$pi_version&planType=FREE&mode=DEV&withSource=false" \
-H 'api-version: 0' | jq '.links' | jq -c '.[]' | while read i; do \
wget -P plugin-interface/ `echo $i | sed -e 's/^"//' -e 's/"$//'`; done
fi

elif [[ $repo_name != "sqlite-plugin" ]]
then
mkdir plugin > /dev/null 2>&1
cp $dir_name/build/libs/* plugin
cp $dir_name/build/dependencies/* plugin > /dev/null 2>&1
if [[ $cicd = false ]]; then
cp $dir_name/build/dependencies/* plugin > /dev/null 2>&1
fi


# add to version_temp.yaml
Expand Down Expand Up @@ -122,6 +165,12 @@ do
done <<< "$p_name"
echo "plugin_version: $p_version" >> version_temp.yaml
echo "plugin_name: $p_name" >> version_temp.yaml
if [[ $cicd = true ]]; then
curl -X GET \
"https://api.supertokens.io/plugin/dependency/jars?version=$p_version&name=$p_name&planType=FREE&mode=DEV&withSource=false" \
-H 'api-version: 0' | jq '.links' | jq -c '.[]' | while read i; do \
wget -P plugin/ `echo $i | sed -e 's/^"//' -e 's/"$//'`; done
fi
else
mkdir plugin > /dev/null 2>&1
fi
Expand Down
Loading

0 comments on commit 8f34d07

Please sign in to comment.