1
+ function cleanup {
2
+ if test -f " pluginInterfaceExactVersionsOutput" ; then
3
+ rm pluginInterfaceExactVersionsOutput
4
+ fi
5
+ }
6
+
7
+ trap cleanup EXIT
8
+ cleanup
9
+
10
+ pinnedDBJson=` curl -s -X GET \
11
+ ' https://api.supertokens.io/0/plugin/pinned?planType=FREE' \
12
+ -H ' api-version: 0' `
13
+ pinnedDBLength=` echo $pinnedDBJson | jq " .plugins | length" `
14
+ pinnedDBArray=` echo $pinnedDBJson | jq " .plugins" `
15
+ echo " got pinned dbs..."
16
+
17
+ pluginInterfaceJson=` cat ../pluginInterfaceSupported.json`
18
+ pluginInterfaceLength=` echo $pluginInterfaceJson | jq " .versions | length" `
19
+ pluginInterfaceArray=` echo $pluginInterfaceJson | jq " .versions" `
20
+ echo " got plugin interface relations"
21
+
22
+ coreDriverJson=` cat ../coreDriverInterfaceSupported.json`
23
+ coreDriverLength=` echo $coreDriverJson | jq " .versions | length" `
24
+ coreDriverArray=` echo $coreDriverJson | jq " .versions" `
25
+ echo " got core driver relations"
26
+
27
+ ./getPluginInterfaceExactVersions.sh $pluginInterfaceLength " $pluginInterfaceArray "
28
+
29
+ if [[ $? -ne 0 ]]
30
+ then
31
+ echo " all plugin interfaces found... failed. exiting!"
32
+ exit 1
33
+ else
34
+ echo " all plugin interfaces found..."
35
+ fi
36
+
37
+ # get core version
38
+ coreVersion=` cat ../build.gradle | grep -e " version =" -e " version=" `
39
+ while IFS=' "' read -ra ADDR; do
40
+ counter=0
41
+ for i in " ${ADDR[@]} " ; do
42
+ if [ $counter == 1 ]
43
+ then
44
+ coreVersion=$i
45
+ fi
46
+ counter=$(( $counter + 1 ))
47
+ done
48
+ done <<< " $coreVersion"
49
+
50
+ responseStatus=` curl -s -o /dev/null -w " %{http_code}" -X PUT \
51
+ https://api.supertokens.io/0/core \
52
+ -H ' Content-Type: application/json' \
53
+ -H ' api-version: 0' \
54
+ -d " {
55
+ \" password\" : \" $SUPERTOKENS_API_KEY \" ,
56
+ \" planType\" :\" FREE\" ,
57
+ \" version\" :\" $coreVersion \" ,
58
+ \" pluginInterfaces\" : $pluginInterfaceArray ,
59
+ \" coreDriverInterfaces\" : $coreDriverArray
60
+ }" `
61
+ if [ $responseStatus -ne " 200" ]
62
+ then
63
+ echo " failed core PUT API status code: $responseStatus . Exiting!"
64
+ exit 1
65
+ fi
66
+
67
+ someTestsRan=false
68
+ while read line
69
+ do
70
+ if [[ $line = " " ]]; then
71
+ continue
72
+ fi
73
+ i=0
74
+ currTag=` echo $line | jq .tag`
75
+ currTag=` echo $currTag | tr -d ' "' `
76
+
77
+ currVersion=` echo $line | jq .version`
78
+ currVersion=` echo $currVersion | tr -d ' "' `
79
+ piX=$( cut -d' .' -f1 <<< " $currVersion" )
80
+ piY=$( cut -d' .' -f2 <<< " $currVersion" )
81
+ piVersion=" $piX .$piY "
82
+
83
+ while [ $i -lt $pinnedDBLength ]; do
84
+ someTestsRan=true
85
+ currPinnedDb=` echo $pinnedDBArray | jq " .[$i ]" `
86
+ currPinnedDb=` echo $currPinnedDb | tr -d ' "' `
87
+
88
+ i=$(( i+ 1 ))
89
+
90
+ response=` curl -s -X GET \
91
+ " https://api.supertokens.io/0/plugin-interface/dependency/plugin/latest?password=$SUPERTOKENS_API_KEY
92
+ &planType=FREE&mode=DEV&version=$piVersion &pluginName=$currPinnedDb " \
93
+ -H ' api-version: 0' `
94
+ if [[ ` echo $response | jq .plugin` == " null" ]]
95
+ then
96
+ echo " fetching latest X.Y version for $currPinnedDb given plugin-interface X.Y version: $piVersion gave response: $response "
97
+ exit 1
98
+ fi
99
+ pinnedDbVersionX2=$( echo $response | jq .plugin | tr -d ' "' )
100
+
101
+ response=` curl -s -X GET \
102
+ " https://api.supertokens.io/0/plugin/latest?password=$SUPERTOKENS_API_KEY &planType=FREE&mode=DEV&version
103
+ =$pinnedDbVersionX2 &name=$currPinnedDb " \
104
+ -H ' api-version: 0' `
105
+ if [[ ` echo $response | jq .tag` == " null" ]]
106
+ then
107
+ echo " fetching latest X.Y.Z version for $currPinnedDb , X.Y version: $pinnedDbVersionX2 gave response: $response "
108
+ exit 1
109
+ fi
110
+ pinnedDbVersionTag=$( echo $response | jq .tag | tr -d ' "' )
111
+ pinnedDbVersion=$( echo $response | jq .version | tr -d ' "' )
112
+ ./startDb.sh $currPinnedDb
113
+ cd ../../
114
+ git clone
[email protected] :vrai-labs/com-root.git
115
+ cd com-root
116
+ coreX=$( cut -d' .' -f1 <<< " $coreVersion" )
117
+ coreY=$( cut -d' .' -f2 <<< " $coreVersion" )
118
+ echo -e " core,$coreX .$coreY \nplugin-interface,$piVersion \n$currPinnedDb -plugin,$pinnedDbVersionX2 " > modules.txt
119
+ ./loadModules
120
+ cd com-core
121
+ git checkout dev-v$coreVersion
122
+ cd ../com-plugin-interface
123
+ git checkout $currTag
124
+ cd ../com-$currPinnedDb -plugin
125
+ git checkout $pinnedDbVersionTag
126
+ cd ../
127
+ echo $SUPERTOKENS_API_KEY > apiPassword
128
+ ./startTestingEnv --cicd
129
+
130
+ if [[ $? -ne 0 ]]
131
+ then
132
+ cat logs/*
133
+ cd ../project/
134
+ echo " test failed... exiting!"
135
+ exit 1
136
+ fi
137
+ cd ../
138
+ rm -rf com-root
139
+ curl -o supertokens.zip -s -X GET \
140
+ " https://api.supertokens.io/0/app/download?pluginName=$currPinnedDb &os=linux&mode=DEV&binary=FREE&targetCore
141
+ =$coreVersion &targetPlugin=$pinnedDbVersion " \
142
+ -H ' api-version: 0'
143
+ unzip supertokens.zip -d .
144
+ rm supertokens.zip
145
+ cd supertokens
146
+ curl -s -X GET \
147
+ " https://api.supertokens.io/0/development/license-key?password=$SUPERTOKENS_API_KEY &planType=FREE&onExpiry
148
+ =DOWNGRADE&expired=false" \
149
+ -H ' api-version: 0' \
150
+ -H ' cache-control: no-cache' > licenseKey
151
+ ../project/.circleci/testCli.sh
152
+ if [[ $? -ne 0 ]]
153
+ then
154
+ echo " cli testing failed... exiting!"
155
+ exit 1
156
+ fi
157
+ cd ../
158
+ rm -rf supertokens
159
+ cd project/.circleci
160
+ ./stopDb.sh $currPinnedDb
161
+ done
162
+ done <<< ` cat pluginInterfaceExactVersionsOutput`
163
+
164
+ if [[ $someTestsRan = " true" ]]
165
+ then
166
+ echo " calling /core PATCH to make testing passed"
167
+ responseStatus=` curl -s -o /dev/null -w " %{http_code}" -X PATCH \
168
+ https://api.supertokens.io/0/core \
169
+ -H ' Content-Type: application/json' \
170
+ -H ' api-version: 0' \
171
+ -d " {
172
+ \" password\" : \" $SUPERTOKENS_API_KEY \" ,
173
+ \" planType\" :\" FREE\" ,
174
+ \" version\" :\" $coreVersion \" ,
175
+ \" testPassed\" : true
176
+ }" `
177
+ if [ $responseStatus -ne " 200" ]
178
+ then
179
+ echo " patch api failed"
180
+ exit 1
181
+ fi
182
+ else
183
+ echo " no test ran"
184
+ exit 1
185
+ fi
0 commit comments