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

Try workflow #5125

Open
wants to merge 46 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
252f279
Try workflow
gannetson Jun 9, 2022
71722f6
Try Elastic threads
gannetson Jun 29, 2022
47d7c25
fix
gannetson Jun 29, 2022
131c99a
RabbitMQ
gannetson Jun 29, 2022
d794664
Merge branch 'master' into poc/workflow
gannetson Jul 8, 2022
25473a4
Merge remote-tracking branch 'origin/master' into poc/workflow
gannetson Aug 19, 2022
5cf4a28
Merge branch 'master' into poc/workflow
gannetson Oct 13, 2022
4a3d7af
Merge branch 'master' into poc/workflow
gannetson Oct 13, 2022
60975b4
Merge remote-tracking branch 'origin/master' into poc/workflow
gannetson Mar 16, 2023
e27cf8b
Try self hosted
gannetson Mar 16, 2023
8b1b650
Pyhon 3.8
gannetson Mar 16, 2023
60db42f
No travis
gannetson Mar 16, 2023
f520775
self
gannetson Mar 16, 2023
e22e465
GoodUp
gannetson Mar 16, 2023
1de05fd
Docker
gannetson Mar 16, 2023
46bdccc
Try
gannetson Mar 16, 2023
0a00186
trigger
gannetson Mar 16, 2023
eaa0b02
skip apt-get
gannetson Mar 16, 2023
6382a39
no apt get
gannetson Mar 16, 2023
285e9d4
pin pyhton
gannetson Mar 16, 2023
ba235cc
Whatever
gannetson Mar 16, 2023
c5706fa
Py 3.11
gannetson Mar 16, 2023
d4d23b2
old py
gannetson Mar 16, 2023
5ff590b
Py 3.9.7
gannetson Mar 16, 2023
e27379d
Use gihub runners
gannetson Mar 16, 2023
89eab01
fix
gannetson Mar 16, 2023
e6d2a2e
Merge branch 'master' into poc/workflow
gannetson Mar 23, 2023
c264112
Change python setup
gannetson Mar 23, 2023
33b71b8
pip setup
gannetson Mar 23, 2023
49a3b58
Cache once
gannetson Mar 23, 2023
b6f121e
libxml
gannetson Mar 23, 2023
e41f42d
More packages
gannetson Mar 23, 2023
48c182a
Update deps
gannetson Mar 23, 2023
5477ead
Try non parallel
gannetson Mar 23, 2023
9fce456
Try self hosted again
gannetson Mar 23, 2023
d12669f
Revert "Try self hosted again"
gannetson Mar 23, 2023
5fb30bb
chore: pin social-auth-core version
mauricekleine Mar 20, 2023
0868138
Try parallel again
gannetson Mar 23, 2023
ea49d1e
Skip some tests
gannetson Mar 23, 2023
bd753fa
Older python
gannetson Mar 23, 2023
24f3686
Other python version again
gannetson Mar 23, 2023
bd57507
Python 3.8
gannetson Mar 24, 2023
93d2777
Upgrade tblib
gannetson Mar 24, 2023
eb48f47
Fix
gannetson Mar 24, 2023
33e1279
Upgrade memcached lib
gannetson Mar 27, 2023
44495c8
Merge remote-tracking branch 'origin/master' into poc/workflow
gannetson Feb 27, 2024
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
68 changes: 68 additions & 0 deletions .github/workflows/django.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Bluebottle CI

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
test:
runs-on: ubuntu-latest
services:
db:
image: postgis/postgis:11-2.5
env:
POSTGRES_USER: bb
POSTGRES_PASSWORD: bb
POSTGRES_DB: test_bluebottle_test
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:6.8.23
env:
discovery.type: single-node
options: >-
--health-cmd "curl http://localhost:9200/_cluster/health"
--health-interval 10s
--health-timeout 5s
--health-retries 10
ports:
- 9200:9200
rabbitmq:
image: rabbitmq
ports:
- 5672:5672
celery:
image: celery
steps:
- uses: actions/checkout@v3
- name: Update apt
run: sudo apt-get update
- name: Install packages
run: sudo apt-get install libxmlsec1 libxmlsec1-dev libgdal-dev swig openjdk-8-jdk-headless
- uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Test data
run: |
psql -h localhost -U bb test_bluebottle_test < testdata.sql
env:
PGPASSWORD: bb
- name: Setup Locale
run: |
export LC_ALL="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"
sudo dpkg-reconfigure locales
- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ hashFiles('setup.py') }}-${{ hashFiles('setup.py') }}
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[test] --trusted-host github.com
- name: Run Tests
run: |
python -m coverage run --parallel-mode --source=bluebottle manage.py test --parallel=8 --keepdb --settings bluebottle.settings.github
49 changes: 0 additions & 49 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion bluebottle/exports/tests/test_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
from bluebottle.exports.tasks import plain_export
from bluebottle.funding.tests.factories import FundingFactory
from bluebottle.impact.models import ImpactType
from bluebottle.initiatives.tests.factories import InitiativePlatformSettingsFactory
from bluebottle.initiatives.tests.factories import InitiativeFactory
from bluebottle.initiatives.tests.factories import InitiativePlatformSettingsFactory
from bluebottle.segments.tests.factories import SegmentTypeFactory, SegmentFactory
from bluebottle.test.factory_models.accounts import BlueBottleUserFactory
from bluebottle.test.utils import BluebottleTestCase
Expand Down
18 changes: 18 additions & 0 deletions bluebottle/settings/github.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# flake8: noqa

from .testing import *

DATABASES = {
'default': {
"ENGINE": "bluebottle.clients.postgresql_backend",
'HOST': 'localhost',
'PORT': '5432',
'NAME': 'bluebottle_test',
'USER': 'bb',
'PASSWORD': 'bb'
}
}

PASSWORD_HASHERS = ['django.contrib.auth.hashers.MD5PasswordHasher']

DEBUG = False
2 changes: 1 addition & 1 deletion bluebottle/settings/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
}


TEST_RUNNER = 'bluebottle.test.test_runner.MultiTenantRunner'
TEST_RUNNER = 'django_slowtests.testrunner.DiscoverSlowestTestsRunner'
NUM_SLOW_TESTS = 50

DEBUG = False
Expand Down
79 changes: 29 additions & 50 deletions bluebottle/test/test_runner.py
Original file line number Diff line number Diff line change
@@ -1,64 +1,43 @@
import locale
from builtins import range

from django.conf import settings
from django.db import connection, IntegrityError
from django.test.runner import ParallelTestSuite
from django_elasticsearch_dsl.registries import registry
from django_slowtests.testrunner import DiscoverSlowestTestsRunner
from djmoney.contrib.exchange.models import Rate, ExchangeBackend
from tenant_schemas.utils import get_tenant_model
from elasticsearch_dsl.connections import connections

from bluebottle.test.utils import InitProjectDataMixin
_worker_id = 0


class MultiTenantRunner(DiscoverSlowestTestsRunner, InitProjectDataMixin):
def setup_databases(self, *args, **kwargs):
self.keepdb = getattr(settings, 'KEEPDB', self.keepdb)
parallel = self.parallel
self.parallel = 0
result = super(MultiTenantRunner, self).setup_databases(**kwargs)
self.parallel = parallel
# Set local explicitely so test also run on OSX
locale.setlocale(locale.LC_ALL, 'en_GB.UTF-8')
def _elastic_search_init_worker(counter):
global _worker_id

connection.set_schema_to_public()
with counter.get_lock():
counter.value += 1
_worker_id = counter.value

tenant2, _created = get_tenant_model().objects.get_or_create(
domain_url='testserver2',
name='Test Too',
schema_name='test2',
client_name='test2')
for alias in connections:
connection = connections[alias]
settings_dict = connection.creation.get_test_db_clone_settings(_worker_id)
connection.settings_dict.update(settings_dict)
connection.close()

connection.set_tenant(tenant2)
self.init_projects()
worker_connection_postfix = f"_worker_{_worker_id}"
for alias in connections:
connections.configure(**{alias + worker_connection_postfix: settings.ELASTICSEARCH_DSL["default"]})

connection.set_schema_to_public()
for doc in registry.get_documents():
doc._doc_type.index += f"_{_worker_id}"
doc._doc_type._using = doc.doc_type._using + worker_connection_postfix

tenant, _created = get_tenant_model().objects.get_or_create(
domain_url='testserver',
name='Test',
schema_name='test',
client_name='test')
for index in registry.get_indices():
index._name += f"_{_worker_id}"
index._using = doc.doc_type._using + worker_connection_postfix
index.delete(ignore=[404])
index.create()

connection.set_tenant(tenant)
self.init_projects()

try:
backend, _created = ExchangeBackend.objects.get_or_create(base_currency='USD')
Rate.objects.update_or_create(backend=backend, currency='USD', defaults={'value': 1})
Rate.objects.update_or_create(backend=backend, currency='EUR', defaults={'value': 1.5})
Rate.objects.update_or_create(backend=backend, currency='XOF', defaults={'value': 1000})
Rate.objects.update_or_create(backend=backend, currency='NGN', defaults={'value': 500})
Rate.objects.update_or_create(backend=backend, currency='UGX', defaults={'value': 5000})
Rate.objects.update_or_create(backend=backend, currency='KES', defaults={'value': 100})
except IntegrityError:
pass
class ElasticParallelTestSuite(ParallelTestSuite):
init_worker = _elastic_search_init_worker

if parallel > 1:
for index in range(parallel):
connection.creation.clone_test_db(
number=index + 1,
verbosity=self.verbosity,
keepdb=self.keepdb,
)

return result
class MultiTenantRunner(DiscoverSlowestTestsRunner):
parallel_test_suite = ElasticParallelTestSuite
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def read_file(name):
'pyparsing==3.0.9',
'python-dateutil==2.6.1',
'python-magic==0.4.15',
'python-memcached==1.58',
'python-memcached==1.59',
'python-social-auth==0.3.6',
'python3-saml==1.9.0',
'rave-python==1.0.2',
Expand Down Expand Up @@ -150,7 +150,7 @@ def read_file(name):
'pylint==2.7.0',
'pyquery==1.2.17',
'pylint-django==2.4.4',
'tblib==1.3.2',
'tblib==1.7',
'tdaemon==0.1.1',
'WebTest==2.0.27',
'sniffer==0.4.0',
Expand Down
Loading