Add the initialize_tenants command #398
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: testing | |
on: | |
push: | |
branches: master | |
pull_request: | |
jobs: | |
postgres: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: [3.11] | |
kiwitcms-url: [tcms.kiwitcms.org, public.tenant.kiwitcms.org] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Create database | |
run: | | |
docker-compose pull db | |
docker-compose up -d | |
- name: Configure ~/.tcms.conf for ${{ matrix.kiwitcms-url }} | |
run: | | |
echo "[tcms]" > ~/.tcms.conf | |
echo "url = https://${{ matrix.kiwitcms-url }}/xml-rpc/" >> ~/.tcms.conf | |
echo "username = kiwitcms-bot" >> ~/.tcms.conf | |
echo "password = ${{ secrets.TCMS_PASSWORD }}" >> ~/.tcms.conf | |
- name: Execute tests | |
run: | | |
pip install -U pip wheel setuptools | |
pip install -r devel.txt | |
# workaround for https://github.com/tomturner/django-tenants/issues/336 | |
pip install psycopg>=3.1.17 | |
# report to Kiwi TCMS only if we have access to secrets | |
if [ -n "${{ secrets.TCMS_PASSWORD }}" ]; then | |
export DJANGO_TEST_RUNNER="tcms_django_plugin.TestRunner" | |
export TCMS_PRODUCT=$GITHUB_REPOSITORY | |
export TCMS_PRODUCT_VERSION=$(echo $GITHUB_REF | sed "s|refs/heads/||" | sed "s|refs/||" | sed "s|/merge||") | |
export TCMS_BUILD=$(echo $GITHUB_SHA | cut -c1-7) | |
fi | |
make check | |
docker-compose down --volumes | |
# restart database for integration tests | |
docker-compose up -d | |
- name: Local coverage report | |
run: | | |
coverage report -m | |
- name: Send coverage to CodeCov | |
uses: codecov/codecov-action@v3 | |
with: | |
fail_ci_if_error: false | |
verbose: true | |
- name: Integration tests | |
run: | | |
# monkey-patch createsuperuser.py b/c it rejects input when not using a TTY | |
DJANGO_PATH=$(python -c "import os, django; print(os.path.dirname(django.__file__))") | |
sed -i "s/raise NotRunningInTTYException/pass/" "${DJANGO_PATH}/contrib/auth/management/commands/createsuperuser.py" | |
sed -i "s/getpass.getpass/input/" "${DJANGO_PATH}/contrib/auth/management/commands/createsuperuser.py" | |
echo -e "admin\[email protected]\nsecret-2a9a34cd-e51d-4039-b709-b45f629a5595\nsecret-2a9a34cd-e51d-4039-b709-b45f629a5595\npublic.test.com" | PYTHONPATH=.:../Kiwi/ KIWI_TENANTS_DOMAIN='test.com' ./manage.py initial_setup | |
PYTHONPATH=.:../Kiwi/ KIWI_TENANTS_DOMAIN='test.com' ./manage.py execute_integration_tests | |
- name: Test schema cloning | |
run: | | |
PYTHONPATH=.:../Kiwi/ KIWI_TENANTS_DOMAIN='test.com' ./manage.py clone_tenant \ | |
--clone_from empty --clone_tenant_fields False \ | |
--schema_name a-cloned-tenant --name "A cloned tenant" --organization "QA department" \ | |
--paid_until 3000-03-31 --publicly_readable False --owner_id 1 \ | |
--domain-domain a-cloned-tenant.test.com --domain-is_primary True |