Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 14 additions & 16 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
version: 2.1

# this allows you to use CircleCI's dynamic configuration feature
setup: true

orbs:
continuation: circleci/[email protected]
slack: circleci/[email protected]
jq: circleci/[email protected]
jobs:
Expand All @@ -16,27 +21,20 @@ jobs:
./publish.sh
- slack/status
test:
docker:
- image: rishabhpoddar/supertokens_website_sdk_testing
machine:
image: ubuntu-2204:2024.04.4
steps:
- checkout
- run: update-alternatives --install "/usr/bin/java" "java" "/usr/java/jdk-15.0.1/bin/java" 2
- run: update-alternatives --install "/usr/bin/javac" "javac" "/usr/java/jdk-15.0.1/bin/javac" 2
- run: echo "127.0.0.1 localhost.org" >> /etc/hosts
- run: npm i -d
- run:
name: Run tests
command: cd .circleci/ && ./doTests.sh
no_output_timeout: 30m
- store_artifacts:
path: ../supertokens-root/logs
destination: logfiles
- run: npm run size
- slack/status
name: Generate config
command: cd .circleci && ./generateConfig.sh
- continuation/continue:
configuration_path: .circleci/config_continue.yml
update-docs:
docker:
- image: rishabhpoddar/supertokens_website_sdk_testing
- image: rishabhpoddar/supertokens_website_sdk_testing_node_16
steps:
- run: git config --global url."https://github.com/".insteadOf ssh://[email protected]/ # This makes npm use http instead of ssh (required for node 16)
- checkout
- run: cd ../ && git clone [email protected]:supertokens/supertokens-backend-website.git
- run: (cd .circleci && ./updateDocsInWebsite.sh)
Expand Down Expand Up @@ -64,7 +62,7 @@ workflows:
only: /test-cicd\/.*/
- update-docs:
context:
- slack-notification
- slack-notification
filters:
branches:
only:
Expand Down
75 changes: 75 additions & 0 deletions .circleci/config_continue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
version: 2.1
orbs:
continuation: circleci/[email protected]
slack: circleci/[email protected]
jq: circleci/[email protected]
jobs:
test-dev-tag-as-not-passed:
docker:
- image: rishabhpoddar/supertokens_website_sdk_testing_node_16
steps:
- run: git config --global url."https://github.com/".insteadOf ssh://[email protected]/ # This makes npm use http instead of ssh (required for node 16)
- checkout
- run: (cd .circleci/ && ./markDevTagAsTestNotPassed.sh)
test-unit:
docker:
- image: rishabhpoddar/supertokens_website_sdk_testing_node_16
parameters:
fdi-version:
type: string
parallelism: 4
steps:
- run: mkdir -p ~/reports/
- run: git config --global url."https://github.com/".insteadOf ssh://[email protected]/ # This makes npm use http instead of ssh (required for node 16)
- checkout
- run: echo "127.0.0.1 localhost.org" >> /etc/hosts
- run: npm i -d
- run:
command: for i in $(seq 1 5); do (cd .circleci/ && ./doTests.sh << parameters.fdi-version >>) && s=0 && break || s=$? && sleep 10; done; (exit $s) # https://support.circleci.com/hc/en-us/articles/5728720104347-How-To-Retry-an-Intermittently-Failing-Step
environment:
JEST_JUNIT_OUTPUT_DIR: ~/reports/
- run: npm run size
- store_test_results:
path: ~/reports/
test-success:
docker:
- image: rishabhpoddar/supertokens_website_sdk_testing_node_16
steps:
- run: git config --global url."https://github.com/".insteadOf ssh://[email protected]/ # This makes npm use http instead of ssh (required for node 16)
- checkout
- run: (cd .circleci/ && ./markAsSuccess.sh)
- slack/status

workflows:
version: 2
tagged-build:
jobs:
- test-dev-tag-as-not-passed:
filters:
tags:
only: /dev-v[0-9]+(\.[0-9]+)*/
branches:
only: /test-cicd\/.*/
- test-unit:
requires:
- test-dev-tag-as-not-passed
context:
- slack-notification
filters:
tags:
only: /dev-v[0-9]+(\.[0-9]+)*/
branches:
only: /test-cicd\/.*/
matrix:
parameters:
fdi-version: placeholder
- test-success:
requires:
- test-unit
context:
- slack-notification
filters:
tags:
only: /dev-v[0-9]+(\.[0-9]+)*/
branches:
ignore: /.*/
170 changes: 48 additions & 122 deletions .circleci/doTests.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
frontendDriverJson=`cat ../frontendDriverInterfaceSupported.json`
frontendDriverLength=`echo $frontendDriverJson | jq ".versions | length"`
frontendDriverArray=`echo $frontendDriverJson | jq ".versions"`
echo "got frontend driver relations"
echo "Starting tests for FDI $1";

if [ -z "$SUPERTOKENS_API_KEY" ]; then
echo "SUPERTOKENS_API_KEY not set"
exit 1
fi
frontendDriverVersion=$1

# get sdk version
version=`cat ../package.json | grep -e '"version":'`
Expand All @@ -16,131 +19,54 @@ while IFS='"' read -ra ADDR; do
done
done <<< "$version"

responseStatus=`curl -s -o /dev/null -w "%{http_code}" -X PUT \
https://api.supertokens.io/0/frontend \
-H 'Content-Type: application/json' \
-H 'api-version: 0' \
-d "{
\"password\": \"$SUPERTOKENS_API_KEY\",
\"version\":\"$version\",
\"name\": \"react-native\",
\"frontendDriverInterfaces\": $frontendDriverArray
}"`
if [ $responseStatus -ne "200" ]
driverVersionXY=`curl -s -X GET \
"https://api.supertokens.io/0/frontend-driver-interface/dependency/driver/latest?password=$SUPERTOKENS_API_KEY&mode=DEV&version=$frontendDriverVersion&driverName=node" \
-H 'api-version: 0'`
if [[ `echo $driverVersionXY | jq .driver` == "null" ]]
then
echo "failed core PUT API status code: $responseStatus. Exiting!"
exit 1
echo "fetching latest X.Y version for driver given frontend-driver-interface X.Y version: $frontendDriverVersion gave response: $driverVersionXY. Please make sure all relevant drivers have been pushed."
exit 1
fi
driverVersionXY=$(echo $driverVersionXY | jq .driver | tr -d '"')

someTestsRan=false
i=0
while [ $i -lt $frontendDriverLength ]; do
frontendDriverVersion=`echo $frontendDriverArray | jq ".[$i]"`
frontendDriverVersion=`echo $frontendDriverVersion | tr -d '"'`
i=$((i+1))

driverVersionXY=`curl -s -X GET \
"https://api.supertokens.io/0/frontend-driver-interface/dependency/driver/latest?password=$SUPERTOKENS_API_KEY&mode=DEV&version=$frontendDriverVersion&driverName=node" \
-H 'api-version: 0'`
if [[ `echo $driverVersionXY | jq .driver` == "null" ]]
then
echo "fetching latest X.Y version for driver given frontend-driver-interface X.Y version: $frontendDriverVersion gave response: $driverVersionXY. Please make sure all relevant drivers have been pushed."
exit 1
fi
driverVersionXY=$(echo $driverVersionXY | jq .driver | tr -d '"')

driverInfo=`curl -s -X GET \
"https://api.supertokens.io/0/driver/latest?password=$SUPERTOKENS_API_KEY&mode=DEV&version=$driverVersionXY&name=node" \
-H 'api-version: 0'`
if [[ `echo $driverInfo | jq .tag` == "null" ]]
then
echo "fetching latest X.Y.Z version for driver, X.Y version: $driverVersionXY gave response: $driverInfo"
exit 1
fi
driverTag=$(echo $driverInfo | jq .tag | tr -d '"')
driverVersion=$(echo $driverInfo | jq .version | tr -d '"')

git clone [email protected]:supertokens/supertokens-node.git
cd supertokens-node
git checkout $driverTag
coreDriverJson=`cat ./coreDriverInterfaceSupported.json`
coreDriverLength=`echo $coreDriverJson | jq ".versions | length"`
coreDriverArray=`echo $coreDriverJson | jq ".versions"`
coreDriverVersion=`echo $coreDriverArray | jq ". | last"`
coreDriverVersion=`echo $coreDriverVersion | tr -d '"'`
cd ../
rm -rf supertokens-node

coreFree=`curl -s -X GET \
"https://api.supertokens.io/0/core-driver-interface/dependency/core/latest?password=$SUPERTOKENS_API_KEY&planType=FREE&mode=DEV&version=$coreDriverVersion" \
-H 'api-version: 0'`
if [[ `echo $coreFree | jq .core` == "null" ]]
then
echo "fetching latest X.Y version for core given core-driver-interface X.Y version: $coreDriverVersion, planType: FREE gave response: $coreFree. Please make sure all relevant cores have been pushed."
exit 1
fi
coreFree=$(echo $coreFree | jq .core | tr -d '"')

someTestsRan=true
tries=1

while [ $tries -le 3 ]
do
tries=$(( $tries + 1 ))
./setupAndTestWithFreeCore.sh $coreFree $driverTag $version

if [[ $? -ne 0 ]]
then
if [[ $tries -le 3 ]]
then
rm -rf ../../supertokens-root
rm -rf ../TestingApp/test/server/node_modules/supertokens-node
git checkout HEAD -- ../TestingApp/test/server/package.json
echo "test failed... retrying!"
else
echo "test failed... exiting!"
exit 1
fi
else
rm -rf ../../supertokens-root
rm -rf ../TestingApp/test/server/node_modules/supertokens-node
git checkout HEAD -- ../TestingApp/test/server/package.json
break
fi
done
done

# get git branch name-----------
branch_name="$(git symbolic-ref HEAD 2>/dev/null)" ||
branch_name="(unnamed branch)" # detached HEAD
driverInfo=`curl -s -X GET \
"https://api.supertokens.io/0/driver/latest?password=$SUPERTOKENS_API_KEY&mode=DEV&version=$driverVersionXY&name=node" \
-H 'api-version: 0'`
if [[ `echo $driverInfo | jq .tag` == "null" ]]
then
echo "fetching latest X.Y.Z version for driver, X.Y version: $driverVersionXY gave response: $driverInfo"
exit 1
fi
driverTag=$(echo $driverInfo | jq .tag | tr -d '"')
driverVersion=$(echo $driverInfo | jq .version | tr -d '"')

branch_name=${branch_name##refs/heads/}
git clone [email protected]:supertokens/supertokens-node.git
cd supertokens-node
git checkout $driverTag
coreDriverJson=`cat ./coreDriverInterfaceSupported.json`
coreDriverLength=`echo $coreDriverJson | jq ".versions | length"`
coreDriverArray=`echo $coreDriverJson | jq ".versions"`
coreDriverVersion=`echo $coreDriverArray | jq ". | last"`
coreDriverVersion=`echo $coreDriverVersion | tr -d '"'`
cd ../
rm -rf supertokens-node

if [[ $branch_name =~ ^test-cicd/.*$ ]]
coreFree=`curl -s -X GET \
"https://api.supertokens.io/0/core-driver-interface/dependency/core/latest?password=$SUPERTOKENS_API_KEY&planType=FREE&mode=DEV&version=$coreDriverVersion" \
-H 'api-version: 0'`
if [[ `echo $coreFree | jq .core` == "null" ]]
then
echo "This is a ci testing branch ($branch_name), exiting early"
exit 0
echo "fetching latest X.Y version for core given core-driver-interface X.Y version: $coreDriverVersion, planType: FREE gave response: $coreFree. Please make sure all relevant cores have been pushed."
exit 1
fi
coreFree=$(echo $coreFree | jq .core | tr -d '"')

if [[ $someTestsRan = "true" ]]
./setupAndTestWithFreeCore.sh $coreFree $driverTag $version
if [[ $? -ne 0 ]]
then
echo "calling /frontend PATCH to make testing passed"
responseStatus=`curl -s -o /dev/null -w "%{http_code}" -X PATCH \
https://api.supertokens.io/0/frontend \
-H 'Content-Type: application/json' \
-H 'api-version: 0' \
-d "{
\"password\": \"$SUPERTOKENS_API_KEY\",
\"version\":\"$version\",
\"name\": \"react-native\",
\"testPassed\": true
}"`
if [ $responseStatus -ne "200" ]
then
echo "patch api failed"
exit 1
fi
else
echo "no test ran"
echo "test failed... exiting!"
exit 1
fi
fi
rm -rf ../../supertokens-root
rm -rf ../TestingApp/test/server/node_modules/supertokens-node
git checkout HEAD -- ../TestingApp/test/server/package.json
9 changes: 9 additions & 0 deletions .circleci/generateConfig.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
frontendDriverJson=`cat ../frontendDriverInterfaceSupported.json`
frontendDriverArray=`echo $frontendDriverJson | jq ".versions"`

if [ -z "$SUPERTOKENS_API_KEY" ]; then
echo "SUPERTOKENS_API_KEY missing"
exit 1;
fi

sed -i -e 's/fdi-version: placeholder/fdi-version: '`printf "%q" $frontendDriverArray`'/' config_continue.yml
46 changes: 46 additions & 0 deletions .circleci/markAsSuccess.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# get git branch name-----------
branch_name="$(git symbolic-ref HEAD 2>/dev/null)" ||
branch_name="(unnamed branch)" # detached HEAD

branch_name=${branch_name##refs/heads/}

if [[ $branch_name =~ ^test-cicd/.*$ ]]
then
echo "This is a ci testing branch ($branch_name), exiting early"
exit 0
fi

frontendDriverJson=`cat ../frontendDriverInterfaceSupported.json`
frontendDriverLength=`echo $frontendDriverJson | jq ".versions | length"`
frontendDriverArray=`echo $frontendDriverJson | jq ".versions"`
echo "got frontend driver relations"

# get sdk version
version=`cat ../package.json | grep -e '"version":'`
while IFS='"' read -ra ADDR; do
counter=0
for i in "${ADDR[@]}"; do
if [ $counter == 3 ]
then
version=$i
fi
counter=$(($counter+1))
done
done <<< "$version"

echo "calling /frontend PATCH to make testing passed"
responseStatus=`curl -s -o /dev/null -w "%{http_code}" -X PATCH \
https://api.supertokens.io/0/frontend \
-H 'Content-Type: application/json' \
-H 'api-version: 0' \
-d "{
\"password\": \"$SUPERTOKENS_API_KEY\",
\"version\":\"$version\",
\"name\": \"react-native\",
\"testPassed\": true
}"`
if [ $responseStatus -ne "200" ]
then
echo "patch api failed"
exit 1
fi
Loading
Loading