Skip to content

Commit

Permalink
ci: experiment with manually runnable ci with pre-set branchnames
Browse files Browse the repository at this point in the history
  • Loading branch information
porcellus committed Sep 25, 2024
1 parent 9506071 commit a7d426e
Show file tree
Hide file tree
Showing 11 changed files with 322 additions and 210 deletions.
95 changes: 55 additions & 40 deletions .circleci/authReact.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,59 +23,74 @@ done <<< "$version"

coreDriverVersion=`echo $coreDriverArray | jq ". | last"`
coreDriverVersion=`echo $coreDriverVersion | tr -d '"'`
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=node" \
-H 'api-version: 1'`
if [[ `echo $coreFree | jq .core` == "null" ]]
if [ -f cdi-core-map.json ]
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
coreFree=$coreDriverVersion
else
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=node" \
-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 '"')
fi
coreFree=$(echo $coreFree | jq .core | tr -d '"')

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

nodeVersionXY=`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&frontendName=auth-react" \
-H 'api-version: 1'`
if [[ `echo $nodeVersionXY | jq .driver` == "null" ]]
if [ -f fdi-node-map.json ]
then
echo "fetching latest X.Y version for driver given frontend-driver-interface X.Y version: $frontendDriverVersion gave response: $nodeVersionXY. Please make sure all relevant drivers have been pushed."
exit 1
fi
nodeVersionXY=$(echo $nodeVersionXY | jq .driver | tr -d '"')
nodeTag=`cat fdi-node-map.json | jq '.["'$frontendDriverVersion'"]'`
else
nodeVersionXY=`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&frontendName=auth-react" \
-H 'api-version: 1'`
if [[ `echo $nodeVersionXY | jq .driver` == "null" ]]
then
echo "fetching latest X.Y version for driver given frontend-driver-interface X.Y version: $frontendDriverVersion gave response: $nodeVersionXY. Please make sure all relevant drivers have been pushed."
exit 1
fi
nodeVersionXY=$(echo $nodeVersionXY | jq .driver | tr -d '"')

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

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

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

if [[ $frontendDriverVersion == '1.3' || $frontendDriverVersion == '1.8' ]]; then
# we skip this since the tests for auth-react here are not reliable due to race conditions...
Expand Down
28 changes: 21 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,31 @@ jobs:
setup:
machine:
image: ubuntu-2204:2024.04.4
parameters:
force:
type: boolean
default: false
cdi-core-map:
type: string
default: "{}"
cdi-plugin-interface-map:
type: string
default: "{}"
fdi-node-map:
type: string
default: "{}"
fdi-auth-react-map:
type: string
default: "{}"
fdi-website-map:
type: string
default: "{}"
steps:
- checkout
- run:
name: Generate config
command: |
cd .circleci && ./generateConfig.sh
cd .circleci && ./generateConfig.sh << parameters.force >> '<< parameters.cdi-core-map >>' '<< parameters.cdi-plugin-interface-map >>' '<< parameters.fdi-node-map >>' '<< parameters.fdi-auth-react-map >>' '<< parameters.fdi-website-map >>'
- continuation/continue:
configuration_path: .circleci/config_continue.yml # use newly generated config to continue

Expand All @@ -52,12 +71,7 @@ workflows:
only: /v[0-9]+(\.[0-9]+)*/
branches:
ignore: /.*/
- setup:
filters:
tags:
only: /dev-v[0-9]+(\.[0-9]+)*/
branches:
only: /test-cicd\/.*/
- setup
- update-docs:
context:
- slack-notification
Expand Down
14 changes: 6 additions & 8 deletions .circleci/config_continue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ jobs:
- run: echo "Testing branch << pipeline.git.branch >>"
- when:
condition:
not:
matches:
pattern: "^test-cicd/.*$"
value: << pipeline.git.branch >>
matches:
pattern: "^[0-9]+\\.[0-9]+$" # X.Y branches
value: << pipeline.git.branch >>
steps:
- checkout
- run: (cd .circleci/ && ./markDevTagAsTestNotPassed.sh)
Expand Down Expand Up @@ -100,10 +99,9 @@ jobs:
- run: echo "Testing passed for branch << pipeline.git.branch >>"
- when:
condition:
not:
matches:
pattern: "^test-cicd/.*$"
value: << pipeline.git.branch >>
matches:
pattern: "^[0-9]+\\.[0-9]+$" # X.Y branches
value: << pipeline.git.branch >>
steps:
- checkout
- run: (cd .circleci/ && ./markAsSuccess.sh)
Expand Down
19 changes: 12 additions & 7 deletions .circleci/doBackendSDKTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,20 @@ 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=node" \
-H 'api-version: 1'`
if [[ `echo $coreFree | jq .core` == "null" ]]
if [ -f cdi-core-map.json ]
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
coreFree=$coreDriverVersion
else
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=node" \
-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 '"')
fi
coreFree=$(echo $coreFree | jq .core | tr -d '"')

cd ..
./test/testExports.sh
Expand Down
19 changes: 12 additions & 7 deletions .circleci/doUnitTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,20 @@ fi
coreDriverVersion=$1
coreDriverVersion=`echo $coreDriverVersion | tr -d '"'`

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=node" \
-H 'api-version: 1'`
if [[ `echo $coreFree | jq .core` == "null" ]]
if [ -f cdi-core-map.json ]
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
coreFree=`cat cdi-core-map.json | jq '.["'$coreDriverVersion'"]'`
else
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=node" \
-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 '"')
fi
coreFree=$(echo $coreFree | jq .core | tr -d '"')

cd ..
./test/testExports.sh
Expand Down
9 changes: 9 additions & 0 deletions .circleci/generateConfig.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,12 @@ fi

sed -i -e 's/cdi-version: placeholder/cdi-version: '`printf "%q" $coreDriverArray`'/' config_continue.yml
sed -i -e 's/fdi-version: placeholder/fdi-version: '`printf "%q" $frontendDriverArray`'/' config_continue.yml

if [ "$1" = "true" ]; then
sed -i -e 's/test-cicd\\\/\.\*/.*/' config_continue.yml
sed -i -e "s@^ - checkout@ - checkout\n - run: echo '$2' >> .circleci\/cdi-core-map.json/@" config_continue.yml
sed -i -e "s@^ - checkout@ - checkout\n - run: echo '$3' >> .circleci\/cdi-plugin-interface-map.json/@" config_continue.yml
sed -i -e "s@^ - checkout@ - checkout\n - run: echo '$4' >> .circleci\/fdi-node-map.json/@" config_continue.yml
sed -i -e "s@^ - checkout@ - checkout\n - run: echo '$5' >> .circleci\/fdi-auth-react-map.json/@" config_continue.yml
sed -i -e "s@^ - checkout@ - checkout\n - run: echo '$6' >> .circleci\/fdi-website-map.json/@" config_continue.yml
fi
63 changes: 38 additions & 25 deletions .circleci/setupAndTestBackendSDKWithFreeCore.sh
Original file line number Diff line number Diff line change
@@ -1,34 +1,47 @@
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" ]]
if [ -f "cdi-core-map.json" ]
then
echo "fetching latest X.Y.Z version for core, X.Y version: $1, planType: FREE gave response: $coreInfo"
exit 1
coreTag=`cat cdi-core-map.json | jq '.["'$1'"]'`
coreVersion=$coreTag
else
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 '"')
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" ]]
if [ -f "cdi-plugin-interface-map.json" ]
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 '"')
pluginInterfaceTag=`cat cdi-plugin-interface-map.json | jq '.["'$coreDriverVersion'"]'`
pluginInterfaceVersionXY=$pluginInterfaceTag
pluginInterfaceVersion=$pluginInterfaceTag
else
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
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 '"')
fi
pluginInterfaceTag=$(echo $pluginInterfaceInfo | jq .tag | tr -d '"')
pluginInterfaceVersion=$(echo $pluginInterfaceInfo | jq .version | tr -d '"')

echo "Testing with FREE core: $coreVersion, plugin-interface: $pluginInterfaceVersion"

Expand Down
Loading

0 comments on commit a7d426e

Please sign in to comment.