@@ -7,6 +7,8 @@ function cleanup {
77trap cleanup EXIT
88cleanup
99
10+ pluginToTest=$1
11+
1012pinnedDBJson=$( curl -s -X GET \
1113 ' https://api.supertokens.io/0/plugin/pinned?planType=FREE' \
1214 -H ' api-version: 0' )
8688
8789 i=$(( i+ 1 ))
8890
89- if [[ $currPinnedDb == " sqlite " ]]
91+ if [[ $currPinnedDb == $pluginToTest ]]
9092 then
91- # shellcheck disable=SC2034
92- continue=1
93- else
94- response=$( curl -s -X GET \
95- " https://api.supertokens.io/0/plugin-interface/dependency/plugin/latest?password=$SUPERTOKENS_API_KEY &planType=FREE&mode=DEV&version=$piVersion &pluginName=$currPinnedDb " \
96- -H ' api-version: 0' )
97- if [[ $( echo " $response " | jq .plugin) == " null" ]]
98- then
99- echo " fetching latest X.Y version for $currPinnedDb given plugin-interface X.Y version: $piVersion gave response: $response "
100- exit 1
101- fi
102- pinnedDbVersionX2=$( echo $response | jq .plugin | tr -d ' "' )
10393
104- response=$( curl -s -X GET \
105- " https://api.supertokens.io/0/plugin/latest?password=$SUPERTOKENS_API_KEY &planType=FREE&mode=DEV&version=$pinnedDbVersionX2 &name=$currPinnedDb " \
106- -H ' api-version: 0' )
107- if [[ $( echo " $response " | jq .tag) == " null" ]]
94+ echo " "
95+ echo " "
96+ echo " "
97+ echo " "
98+ echo " "
99+ echo " ===== testing $currPinnedDb with plugin-interface $currVersion ====="
100+ echo " "
101+ echo " "
102+ echo " "
103+ echo " "
104+ echo " "
105+
106+ if [[ $currPinnedDb == " sqlite" ]]
108107 then
109- echo " fetching latest X.Y.Z version for $currPinnedDb , X.Y version: $pinnedDbVersionX2 gave response: $response "
110- exit 1
108+ # shellcheck disable=SC2034
109+ continue=1
110+ else
111+ response=$( curl -s -X GET \
112+ " https://api.supertokens.io/0/plugin-interface/dependency/plugin/latest?password=$SUPERTOKENS_API_KEY &planType=FREE&mode=DEV&version=$piVersion &pluginName=$currPinnedDb " \
113+ -H ' api-version: 0' )
114+ if [[ $( echo " $response " | jq .plugin) == " null" ]]
115+ then
116+ echo " fetching latest X.Y version for $currPinnedDb given plugin-interface X.Y version: $piVersion gave response: $response "
117+ exit 1
118+ fi
119+ pinnedDbVersionX2=$( echo $response | jq .plugin | tr -d ' "' )
120+
121+ response=$( curl -s -X GET \
122+ " https://api.supertokens.io/0/plugin/latest?password=$SUPERTOKENS_API_KEY &planType=FREE&mode=DEV&version=$pinnedDbVersionX2 &name=$currPinnedDb " \
123+ -H ' api-version: 0' )
124+ if [[ $( echo " $response " | jq .tag) == " null" ]]
125+ then
126+ echo " fetching latest X.Y.Z version for $currPinnedDb , X.Y version: $pinnedDbVersionX2 gave response: $response "
127+ exit 1
128+ fi
129+ pinnedDbVersionTag=$( echo " $response " | jq .tag | tr -d ' "' )
130+ pinnedDbVersion=$( echo " $response " | jq .version | tr -d ' "' )
131+ ./startDb.sh " $currPinnedDb "
111132 fi
112- pinnedDbVersionTag=$( echo " $response " | jq .tag | tr -d ' "' )
113- pinnedDbVersion=$( echo " $response " | jq .version | tr -d ' "' )
114- ./startDb.sh " $currPinnedDb "
115- fi
116133
117- cd ../../
118- git clone
[email protected] :supertokens/supertokens-root.git
119- cd supertokens-root
134+ cd ../../
135+ git clone
[email protected] :supertokens/supertokens-root.git
136+ cd supertokens-root
120137
121- update-alternatives --install " /usr/bin/java" " java" " /usr/java/jdk-15.0.1/bin/java" 2
122- update-alternatives --install " /usr/bin/javac" " javac" " /usr/java/jdk-15.0.1/bin/javac" 2
123-
124- coreX=$( cut -d' .' -f1 <<< " $coreVersion" )
125- coreY=$( cut -d' .' -f2 <<< " $coreVersion" )
126- if [[ $currPinnedDb == " sqlite" ]]
127- then
128- echo -e " core,$coreX .$coreY \nplugin-interface,$piVersion " > modules.txt
129- else
130- echo -e " core,$coreX .$coreY \nplugin-interface,$piVersion \n$currPinnedDb -plugin,$pinnedDbVersionX2 " > modules.txt
131- fi
132- ./loadModules
133- cd supertokens-core
134- git checkout dev-v$coreVersion
135- cd ../supertokens-plugin-interface
136- git checkout $currTag
137- if [[ $currPinnedDb == " sqlite" ]]
138- then
139- # shellcheck disable=SC2034
140- continue=1
141- else
142- cd ../supertokens-$currPinnedDb -plugin
143- git checkout $pinnedDbVersionTag
144- fi
145- cd ../
146- echo $SUPERTOKENS_API_KEY > apiPassword
147- ./startTestingEnv --cicd
138+ update-alternatives --install " /usr/bin/java" " java" " /usr/java/jdk-15.0.1/bin/java" 2
139+ update-alternatives --install " /usr/bin/javac" " javac" " /usr/java/jdk-15.0.1/bin/javac" 2
148140
149- if [[ $? -ne 0 ]]
150- then
151- cat logs/*
152- cd ../project/
153- echo " test failed... exiting!"
154- exit 1
155- fi
156- cd ../
157- rm -rf supertokens-root
141+ coreX=$( cut -d' .' -f1 <<< " $coreVersion" )
142+ coreY=$( cut -d' .' -f2 <<< " $coreVersion" )
143+ if [[ $currPinnedDb == " sqlite" ]]
144+ then
145+ echo -e " core,$coreX .$coreY \nplugin-interface,$piVersion " > modules.txt
146+ else
147+ echo -e " core,$coreX .$coreY \nplugin-interface,$piVersion \n$currPinnedDb -plugin,$pinnedDbVersionX2 " > modules.txt
148+ fi
149+ ./loadModules
150+ cd supertokens-core
151+ git checkout dev-v$coreVersion
152+ cd ../supertokens-plugin-interface
153+ git checkout $currTag
154+ if [[ $currPinnedDb == " sqlite" ]]
155+ then
156+ # shellcheck disable=SC2034
157+ continue=1
158+ else
159+ cd ../supertokens-$currPinnedDb -plugin
160+ git checkout $pinnedDbVersionTag
161+ fi
162+ cd ../
163+ echo $SUPERTOKENS_API_KEY > apiPassword
164+ ./startTestingEnv --cicd
158165
159- if [[ $currPinnedDb == " sqlite" ]]
160- then
161- # shellcheck disable=SC2034
162- continue=1
163- else
164- curl -o supertokens.zip -s -X GET \
165- " https://api.supertokens.io/0/app/download?pluginName=$currPinnedDb &os=linux&mode=DEV&binary=FREE&targetCore=$coreVersion &targetPlugin=$pinnedDbVersion " \
166- -H ' api-version: 0'
167- unzip supertokens.zip -d .
168- rm supertokens.zip
169- cd supertokens
170- ../project/.circleci/testCli.sh
171166 if [[ $? -ne 0 ]]
172167 then
173- echo " cli testing failed... exiting!"
168+ echo " "
169+ echo " "
170+ echo " "
171+ echo " "
172+ echo " "
173+ echo " ===== testing $currPinnedDb with plugin-interface $currVersion FAILED ====="
174+ echo " "
175+ echo " "
176+ echo " "
177+ echo " "
178+ echo " "
179+
180+ cat logs/*
181+ cd ../project/
182+ echo " test failed... exiting!"
174183 exit 1
175184 fi
185+
186+ echo " "
187+ echo " "
188+ echo " "
189+ echo " "
190+ echo " "
191+ echo " ===== testing $currPinnedDb with plugin-interface $currVersion SUCCEEDED ====="
192+ echo " "
193+ echo " "
194+ echo " "
195+ echo " "
196+ echo " "
197+
176198 cd ../
177- fi
199+ rm -rf supertokens-root
200+
201+ if [[ $currPinnedDb == " sqlite" ]]
202+ then
203+ # shellcheck disable=SC2034
204+ continue=1
205+ else
206+ curl -o supertokens.zip -s -X GET \
207+ " https://api.supertokens.io/0/app/download?pluginName=$currPinnedDb &os=linux&mode=DEV&binary=FREE&targetCore=$coreVersion &targetPlugin=$pinnedDbVersion " \
208+ -H ' api-version: 0'
209+ unzip supertokens.zip -d .
210+ rm supertokens.zip
211+ cd supertokens
212+ ../project/.circleci/testCli.sh
213+ if [[ $? -ne 0 ]]
214+ then
215+ echo " cli testing failed... exiting!"
216+ exit 1
217+ fi
218+ cd ../
219+ fi
220+
221+ rm -rf supertokens
222+ cd project/.circleci
223+ if [[ $currPinnedDb == " sqlite" ]]
224+ then
225+ # shellcheck disable=SC2034
226+ continue=1
227+ else
228+ ./stopDb.sh $currPinnedDb
229+ fi
178230
179- rm -rf supertokens
180- cd project/.circleci
181- if [[ $currPinnedDb == " sqlite" ]]
182- then
183- # shellcheck disable=SC2034
184- continue=1
185- else
186- ./stopDb.sh $currPinnedDb
187231 fi
232+
188233 done
189234done 10< pluginInterfaceExactVersionsOutput
190235
191236if [[ $someTestsRan = " true" ]]
192237then
193- echo " calling /core PATCH to make testing passed"
194- responseStatus=$( curl -s -o /dev/null -w " %{http_code}" -X PATCH \
195- https://api.supertokens.io/0/core \
196- -H ' Content-Type: application/json' \
197- -H ' api-version: 0' \
198- -d " {
199- \" password\" : \" $SUPERTOKENS_API_KEY \" ,
200- \" planType\" :\" FREE\" ,
201- \" version\" :\" $coreVersion \" ,
202- \" testPassed\" : true
203- }" )
204- if [ " $responseStatus " -ne " 200" ]
205- then
206- echo " patch api failed"
207- exit 1
208- fi
238+ echo " tests ran successfully"
209239else
210240 echo " no test ran"
211241 exit 1
0 commit comments