Use expected hostname for test databases #23
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
--- | |
# Borrowed heavily from django-snowflake | |
# https://github.com/Snowflake-Labs/django-snowflake/blob/25c603482b39109509eb2a549672cd9404e5dc6c/.github/workflows/tests.yml | |
name: Tests | |
on: [push] | |
jobs: | |
django-tests: | |
runs-on: ubuntu-latest | |
name: Django Test Suite | |
steps: | |
- name: Checkout django-libsql | |
uses: actions/checkout@v3 | |
- name: Checkout Django | |
uses: actions/checkout@v3 | |
with: | |
repository: 'django/django' | |
ref: '4.2' | |
path: 'django_repo' | |
- name: Setup sqld server | |
run: | | |
# Databases are handled by host header | |
echo -e "127.0.0.1 test-db.local\n127.0.0.1 test-otherdb.local\n127.0.0.1 db.local\n127.0.0.1 otherdb.local" | sudo tee -a /etc/hosts | |
# Verify hosts file | |
cat /etc/hosts | |
set -x | |
nslookup test-db.local | |
nslookup test-otherdb.local | |
nslookup db.local | |
nslookup otherdb.local | |
# Start the server | |
docker run --rm --detach -p 8080:8080 -p 9090:9090 --name sqld -e RUST_LOG=sqld=debug,info ghcr.io/tursodatabase/libsql-server:main /bin/sqld --admin-listen-addr 0.0.0.0:9090 --enable-namespaces | |
sleep 5 | |
curl -sv test-db.local:8080 | |
curl -sv test-otherdb.local:8080 | |
- name: Install system packages for Django's Python test dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install libmemcached-dev | |
- name: Install Django and its Python test dependencies | |
run: | | |
pip3 install -U pip | |
cd django_repo/tests/ | |
pip3 install -e .. | |
pip3 install -r requirements/py3.txt | |
- name: install the django-libsql backend | |
run: pip3 install . | |
- name: Copy the test settings file | |
run: cp .github/workflows/libsql_settings.py django_repo/tests/ | |
- name: Run the tests | |
run: | | |
export LIBSQL_AUTH_TOKEN="" | |
export LIBSQL_SYNC_URL=http://db.local:8080 | |
export OTHER_LIBSQL_SYNC_URL=http://otherdb.local:8080 | |
python3 django_repo/tests/runtests.py --settings libsql_settings -v 2 | |
- name: Dump sqld logs and stop | |
if: always() | |
run: | | |
docker logs sqld | |
docker ps | grep sqld && docker kill sqld |