Skip to content

Commit

Permalink
fix: circle ci
Browse files Browse the repository at this point in the history
  • Loading branch information
sattvikc committed Jul 29, 2024
1 parent d33398b commit 4a5b24f
Show file tree
Hide file tree
Showing 4 changed files with 189 additions and 49 deletions.
12 changes: 6 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ workflows:
version: 2
tagged-build:
jobs:
- setup:
filters:
tags:
only: /dev-v[0-9]+(\.[0-9]+)*/
branches:
only: /test-cicd\/.*/
- setup: {}
# filters:
# tags:
# only: /dev-v[0-9]+(\.[0-9]+)*/
# branches:
# only: /test-cicd\/.*/
120 changes: 77 additions & 43 deletions .circleci/config_continue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,26 @@ jobs:
- run: go get ./...
- run: (cd .circleci/ && ./doUnitTests.sh << parameters.cdi-version >>)
- slack/status
test-backend-sdk-testing:
docker:
- image: rishabhpoddar/supertokens_go_driver_testing
resource_class: large
parameters:
cdi-version:
type: string
fdi-version:
type: string
steps:
- checkout
- run: apt-get install lsof
- run: echo "127.0.0.1 localhost.org" >> /etc/hosts
- run: go version
- run: rm -rf /etc/alternatives/java
- run: ln -s /usr/java/jdk-15.0.1/bin/java /etc/alternatives/java
- run: wget https://go.dev/dl/go1.18.10.linux-amd64.tar.gz && rm -rf /usr/local/go && tar -C /usr/local -xzf go*.tar.gz
- run: go get ./...
- run: (cd .circleci/ && ./doBackendSDKTests.sh << parameters.cdi-version >> << parameters.fdi-version >>)
- slack/status
test-website:
docker:
- image: rishabhpoddar/supertokens_go_driver_testing
Expand Down Expand Up @@ -89,55 +109,69 @@ 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
# - 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:
# cdi-version: placeholder
# - test-website:
# requires:
# - test-dev-tag-as-not-passed
# context:
# - slack-notification
# filters:
# tags:
# only: /dev-v[0-9]+(\.[0-9]+)*/
# branches:
# only: /test-cicd\/.*/
# - test-authreact:
# requires:
# - test-dev-tag-as-not-passed
# context:
# - slack-notification
# filters:
# tags:
# only: /dev-v[0-9]+(\.[0-9]+)*/
# branches:
# only: /test-cicd\/.*/
- test-backend-sdk-testing:
# requires:
# - test-dev-tag-as-not-passed
context:
- slack-notification
filters:
tags:
only: /dev-v[0-9]+(\.[0-9]+)*/
branches:
only: /test-cicd\/.*/
# filters:
# tags:
# only: /dev-v[0-9]+(\.[0-9]+)*/
# branches:
# only: /test-cicd\/.*/
matrix:
parameters:
cdi-version: placeholder
- test-website:
requires:
- test-dev-tag-as-not-passed
context:
- slack-notification
filters:
tags:
only: /dev-v[0-9]+(\.[0-9]+)*/
branches:
only: /test-cicd\/.*/
- test-authreact:
requires:
- test-dev-tag-as-not-passed
context:
- slack-notification
filters:
tags:
only: /dev-v[0-9]+(\.[0-9]+)*/
branches:
only: /test-cicd\/.*/
fdi-version: placeholder
- test-success:
requires:
- test-unit
- test-website
- test-authreact
# - test-unit
# - test-website
# - test-authreact
- test-backend-sdk-testing
context:
- slack-notification
filters:
tags:
only: /dev-v[0-9]+(\.[0-9]+)*/
branches:
ignore: /.*/

# filters:
# tags:
# only: /dev-v[0-9]+(\.[0-9]+)*/
# branches:
# ignore: /.*/
29 changes: 29 additions & 0 deletions .circleci/doBackendSDKTests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
echo "Starting tests for CDI $1, FDI $2";

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

coreDriverVersion=$1
coreDriverVersion=`echo $coreDriverVersion | tr -d '"'`

frontendDriverVersion=$2

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&driverName=golang" \
-H 'api-version: 1'`
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 '"')

./setupAndTestBackendSDKWithFreeCore.sh $coreFree $coreDriverVersion $frontendDriverVersion
if [[ $? -ne 0 ]]
then
echo "test failed... exiting!"
exit 1
fi
rm -rf ../../supertokens-root
77 changes: 77 additions & 0 deletions .circleci/setupAndTestBackendSDKWithFreeCore.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
coreInfo=`curl -s -X GET \
"https://api.supertokens.io/0/core/latest?password=$SUPERTOKENS_API_KEY&planType=FREE&mode=DEV&version=$1" \
-H 'api-version: 0'`
if [[ `echo $coreInfo | jq .tag` == "null" ]]
then
echo "fetching latest X.Y.Z version for core, X.Y version: $1, planType: FREE gave response: $coreInfo"
exit 1
fi
coreTag=$(echo $coreInfo | jq .tag | tr -d '"')
coreVersion=$(echo $coreInfo | jq .version | tr -d '"')

pluginInterfaceVersionXY=`curl -s -X GET \
"https://api.supertokens.io/0/core/dependency/plugin-interface/latest?password=$SUPERTOKENS_API_KEY&planType=FREE&mode=DEV&version=$1" \
-H 'api-version: 0'`
if [[ `echo $pluginInterfaceVersionXY | jq .pluginInterface` == "null" ]]
then
echo "fetching latest X.Y version for plugin-interface, given core X.Y version: $1, planType: FREE gave response: $pluginInterfaceVersionXY"
exit 1
fi
pluginInterfaceVersionXY=$(echo $pluginInterfaceVersionXY | jq .pluginInterface | tr -d '"')

pluginInterfaceInfo=`curl -s -X GET \
"https://api.supertokens.io/0/plugin-interface/latest?password=$SUPERTOKENS_API_KEY&planType=FREE&mode=DEV&version=$pluginInterfaceVersionXY" \
-H 'api-version: 0'`
if [[ `echo $pluginInterfaceInfo | jq .tag` == "null" ]]
then
echo "fetching latest X.Y.Z version for plugin-interface, X.Y version: $pluginInterfaceVersionXY, planType: FREE gave response: $pluginInterfaceInfo"
exit 1
fi
pluginInterfaceTag=$(echo $pluginInterfaceInfo | jq .tag | tr -d '"')
pluginInterfaceVersion=$(echo $pluginInterfaceInfo | jq .version | tr -d '"')

echo "Backend SDK Testing with FREE core: $coreVersion, plugin-interface: $pluginInterfaceVersion, fdi-version: $3"

cd ../../
git clone [email protected]:supertokens/supertokens-root.git
cd supertokens-root
if [[ $2 == "2.0" ]] || [[ $2 == "2.1" ]] || [[ $2 == "2.2" ]]
then
git checkout 36e5af1b9a4e3b07247d0cf333cf82a071a78681
fi
echo -e "core,$1\nplugin-interface,$pluginInterfaceVersionXY" > modules.txt
./loadModules --ssh
cd supertokens-core
git checkout $coreTag
cd ../supertokens-plugin-interface
git checkout $pluginInterfaceTag
cd ../
echo $SUPERTOKENS_API_KEY > apiPassword
./utils/setupTestEnvLocal
cd ../project/

API_PORT=3030
ST_CONNECTION_URI=http://localhost:8081

# start test-server
pushd test/test-server
API_PORT=$API_PORT ST_CONNECTION_URI=$ST_CONNECTION_URI go run . &
popd

frontendDriverVersion=$3
# run tests
cd ../
git clone [email protected]:supertokens/backend-sdk-testing.git
cd backend-sdk-testing
git checkout $frontendDriverVersion
npm install
npm run build

if ! [[ -z "${CIRCLE_NODE_TOTAL}" ]]; then
API_PORT=$API_PORT TEST_MODE=testing SUPERTOKENS_CORE_TAG=$coreTag NODE_PORT=8081 INSTALL_PATH=../supertokens-root npx mocha --node-option no-experimental-fetch -r test/fetch-polyfill.mjs --no-config --timeout 500000 $(npx mocha-split-tests -r ./runtime.log -t $CIRCLE_NODE_TOTAL -g $CIRCLE_NODE_INDEX -f 'test/**/*.test.js')
else
API_PORT=$API_PORT TEST_MODE=testing SUPERTOKENS_CORE_TAG=$coreTag NODE_PORT=8081 INSTALL_PATH=../supertokens-root npm test
fi

# kill test-server
kill $(lsof -t -i:$API_PORT)

0 comments on commit 4a5b24f

Please sign in to comment.