Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add job and script for rdmo-app check #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
50 changes: 50 additions & 0 deletions .github/rdmo-app-ci-script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash

git clone https://$GITHUB_TOKEN@github.com/rdmorganiser/rdmo.git
# need rdmo only for testing/config/settings
git clone https://$GITHUB_TOKEN@github.com/rdmorganiser/rdmo-app.git
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the pluging can be tested in rdmo/testing/ alone, right? So cloning rdmo (no token needed) woulsd suffice.


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 - || exit 1
pip install .
cp rdmo_radar/sample.local.py rdmo-app/config/settings/local.py
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 || exit 1
mkdir vendor
# set up instance
# python manage.py download_vendor_files # download front-end vendor files
python manage.py migrate # initializes the database
python manage.py setup_groups # optional: create groups with different permissions

python manage.py loaddata -v 2 "../rdmo/testing/fixtures/users.json"
python manage.py loaddata -v 2 ../rdmo/testing/fixtures/*

python manage.py check

# function for testing presence of plugin name in a certain django setting
test_if_settings_contain_plugin () {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you @triole! Ive included your suggestions and refactored the last part into a function. Looks good to you?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this is just testing that the plugin is in settings which is rather pointless, since the settings are part of the test setup. I think a simple ./manage.py check would suffice, right?

SETTING_NAME=$1
SETTING_VALUE="$(python manage.py print_settings -f $SETTING_NAME --format=value)"
echo "Testing if the value of the django setting ${SETTING_NAME} contains $2"
if [[ ${SETTING_VALUE} == *"$2"* ]]; then
echo -e "OK, Plugin $2 is in ${SETTING_NAME}.\n\t${SETTING_VALUE}"
else
echo -e "ERROR, Plugin $2 is not in ${SETTING_NAME}.\n\t${SETTING_VALUE}"
exit 1
fi
}

test_if_settings_contain_plugin "PROJECT_EXPORTS" $PLUGIN_NAME

test_if_settings_contain_plugin "PROJECT_IMPORTS" $PLUGIN_NAME
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,21 @@ jobs:
- run: python -Im pip install -e .[dev]
- run: python -Ic 'import rdmo_radar; print(rdmo_radar.__version__)'

rdmo-app-check:
name: Build in rdmo-app
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.12"
cache: pip
- name: Run rdmo-app build and check script
run: bash .github/rdmo-app-ci-script.sh
env:
GITHUB_TOKEN: ${{ github.token }}


required-checks-pass:
if: always()
needs:
Expand Down
10 changes: 10 additions & 0 deletions rdmo_radar/sample.local.py
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part should not be part of the repo. If it is only needed for testing it should just be part of the ci job.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this can just be solved with some echo > magic and multiline yaml fields >-.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# ruff: noqa: F821
PROJECT_EXPORTS += [
('radar-xml', _('as RADAR XML'), 'rdmo_radar.exports.RadarExport')
]
PROJECT_IMPORTS += [
('radar', _('from RADAR XML'), 'rdmo_radar.imports.RadarImport')
]
PROJECT_EXPORTS += [
('radar', _('directly to RADAR'), 'rdmo_radar.exports.RadarExportProvider')
]
Loading