Skip to content

Commit

Permalink
ci: update and refactor rdmo-app script
Browse files Browse the repository at this point in the history
  • Loading branch information
MyPyDavid committed Feb 1, 2024
1 parent 4b8afbf commit 0d441a7
Showing 1 changed file with 21 additions and 23 deletions.
44 changes: 21 additions & 23 deletions .github/rdmo-app-ci-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@ git clone https://[email protected]/rdmorganiser/rdmo.git
# need rdmo only for testing/config/settings
git clone https://$GITHUB_TOKEN@github.com/rdmorganiser/rdmo-app.git

cd rdmo-app
cd rdmo-app || exit 1
python3 -m venv env
source env/bin/activate
pip install --upgrade pip setuptools
pip install rdmo"[allauth]"

# install and set-up plugin
cd ..
cd - || exit 1
pip install .
cp rdmo_radar/sample.local.py rdmo-app/config/settings/local.py
PLUGIN=$(basename $(pwd))
PLUGIN="$(basename "$(pwd)")"
PLUGIN_NAME="${PLUGIN/rdmo-plugins-/}"

# set up rdmo-app settings
# write to rdmo-app/config/settings/__init__.py
cp rdmo/testing/config/settings/* rdmo-app/config/settings
cd rdmo-app
cd rdmo-app || exit 1
# set up instance
# python manage.py download_vendor_files # download front-end vendor files
python manage.py migrate # initializes the database
Expand All @@ -31,22 +31,20 @@ python manage.py loaddata -v 2 ../rdmo/testing/fixtures/*

python manage.py check

# test PROJECT_EXPORTS setting
PROJECT_EXPORTS=$(python manage.py print_settings -f PROJECT_EXPORTS --format=value)
echo "Testing for presence of setting in django settings"
if [[ $PROJECT_EXPORTS == *"$PLUGIN_NAME"* ]]; then
echo "Plugin $PLUGIN_NAME is in PROJECT_EXPORTS.\n\t${PROJECT_EXPORTS}"
else
echo "Plugin $PLUGIN_NAME is not in PROJECT_EXPORTS.\n\t${PROJECT_EXPORTS}"
exit 1
fi

# test PROJECT_IMPORTS setting
PROJECT_IMPORTS=$(python manage.py print_settings -f PROJECT_IMPORTS --format=value)
echo "Testing for presence of setting in django settings"
if [[ $PROJECT_IMPORTS == *"$PLUGIN_NAME"* ]]; then
echo "Plugin $PLUGIN_NAME is in PROJECT_IMPORTS.\n\t${PROJECT_IMPORTS}"
else
echo "Plugin $PLUGIN_NAME is not in PROJECT_IMPORTS.\n\t${PROJECT_IMPORTS}"
exit 1
fi
# function for testing presence of plugin name in a certain django setting
test_if_settings_contains_plugin () {
SETTING_NAME=$1
SETTING_VALUE="$(python manage.py print_settings -f $SETTING_NAME --format=value)"
echo "Testing for presence of ${SETTING_NAME} setting in django settings"
if [[ ${SETTING_VALUE} == *"$PLUGIN_NAME"* ]]; then
echo -e "OK, Plugin $PLUGIN_NAME is in ${SETTING_NAME}.\n\t${SETTING_VALUE}"
else
echo -e "ERROR, Plugin $PLUGIN_NAME is not in ${SETTING_NAME}.\n\t${SETTING_VALUE}"
exit 1
fi
}

test_if_settings_contains_plugin "PROJECT_EXPORTS"

test_if_settings_contains_plugin "PROJECT_IMPORTS"

0 comments on commit 0d441a7

Please sign in to comment.