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

Update postgres version in CI #531

Open
wants to merge 14 commits into
base: main-in
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
9 changes: 5 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ jobs:
name: Test
env:
python-version: "3.9.x"
pg-version: "14"
postgis-version: "3.2"
pg-version: "15"
postgis-version: "3.3"
redis-version: "6.2"
node-version: "10"
elastic-version: "7.17.6"
rpindexer-version: "7.5.0"
mailroom-version: "7.5.33"
mailroom-version: "7.5.36"
DJANGO_SETTINGS_MODULE: temba.settings_ci
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -41,6 +41,7 @@ jobs:
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.8.5
virtualenvs-in-project: true

- name: Install Redis
Expand Down Expand Up @@ -69,7 +70,7 @@ jobs:
wget https://github.com/nyaruka/rp-indexer/releases/download/v${{ env.rpindexer-version }}/rp-indexer_${{ env.rpindexer-version }}_linux_amd64.tar.gz
tar -xvf rp-indexer_${{ env.rpindexer-version }}_linux_amd64.tar.gz rp-indexer
# fetch, extract and start mailroom
wget https://github.com/${{ github.repository_owner }}/mailroom/releases/download/v${{ env.mailroom-version }}/mailroom_${{ env.mailroom-version }}_linux_amd64.tar.gz
wget https://github.com/nyaruka/mailroom/releases/download/v${{ env.mailroom-version }}/mailroom_${{ env.mailroom-version }}_linux_amd64.tar.gz
tar -xvf mailroom_${{ env.mailroom-version }}_linux_amd64.tar.gz mailroom
./mailroom -db=postgres://temba:temba@localhost:5432/temba?sslmode=disable -redis=redis://localhost:6379/10 -log-level=info > mailroom.log &

Expand Down
6 changes: 3 additions & 3 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ COPY ./docker/pip-requires.txt .
RUN python -m pip install -U poetry==1.1.15 \
&& poetry cache clear -n --all pypi \
&& poetry add -n --lock $(cat pip-requires.txt) \
&& poetry export --without-hashes --output requirements.txt
&& poetry export --without-hashes --with dev --output requirements.txt

FROM python:3.9-slim-bullseye

Expand All @@ -36,7 +36,7 @@ RUN apt-get update \
&& apt-get install --no-install-recommends --no-install-suggests -y gcc bzip2 git curl nginx libpq-dev gettext \
libgdal-dev python3-cffi python3-gdal vim

RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - \
RUN curl -sL https://deb.nodesource.com/setup_18.x | bash - \
&& apt-get install --no-install-recommends --no-install-suggests -y nodejs

RUN rm -rf /var/lib/apt/lists/*
Expand Down Expand Up @@ -72,7 +72,7 @@ RUN su $PROJECT_USER -c "npm install --global \

RUN su $PROJECT_USER -c "ln -s $PROJECT_PATH/temba/settings.py.prod $PROJECT_PATH/temba/settings.py"

RUN su $PROJECT_USER -c "npm install"
RUN su $PROJECT_USER -c "yarn install"

EXPOSE 8000
EXPOSE 8001
Expand Down
1 change: 0 additions & 1 deletion docker/pip-requires.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
django-environ@^0.7.0
elastic-apm@^6.4.0
flower@^0.9
django-templates-macros@^0.2
django-csp@^3.7
weni-rp-apps@==2.7.8a4
elasticsearch==7.13.4
Expand Down
1,832 changes: 879 additions & 953 deletions poetry.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ packaging = "^20.9"
requests-toolbelt = "^0.9.1"
chardet = "^4.0.0"
openpyxl = "^3.0.9"
slack-sdk = "3.17.0"

[tool.poetry.dev-dependencies]
black = "^22.1.0"
Expand Down
8 changes: 6 additions & 2 deletions temba/channels/types/slack/tests.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import slack_sdk
from unittest.mock import patch

import slack_sdk

from django.urls import reverse

from temba.tests import TembaTest

from ...models import Channel
from django.urls import reverse


class SlackTypeTest(TembaTest):
Expand Down
6 changes: 4 additions & 2 deletions temba/channels/types/slack/views.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import slack_sdk
from django.utils.translation import gettext_lazy as _
from smartmin.views import SmartFormView

from django import forms
from django.core.exceptions import ValidationError
from django.utils.translation import gettext_lazy as _

from ...models import Channel
from ...views import ClaimViewMixin
from django import forms


class ClaimView(ClaimViewMixin, SmartFormView):
Expand Down
2 changes: 1 addition & 1 deletion temba/channels/types/whatsapp_cloud/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,4 +637,4 @@ def test_get_api_templates(self, mock_get):
headers={"Authorization": "Bearer WA_ADMIN_TOKEN"},
),
]
)
)
2 changes: 1 addition & 1 deletion temba/channels/types/whatsapp_cloud/type.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,4 @@ def get_api_templates(self, channel):
return template_data, True
except requests.RequestException as e:
HTTPLog.create_from_exception(HTTPLog.WHATSAPP_TEMPLATES_SYNCED, url, e, start, channel=channel)
return [], False
return [], False
2 changes: 1 addition & 1 deletion temba/channels/types/whatsapp_cloud/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,4 +359,4 @@ def execute_action(self):
raise forms.ValidationError(
_("Unable to register phone %s with ID %s from WABA with ID %s")
% (wa_number, channel.address, waba_id)
)
)
2 changes: 1 addition & 1 deletion temba/flows/legacy/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@ def test_migrate_sample_flows(self):
webhook_node = order_checker.get_definition()["nodes"][3]
webhook_action = webhook_node["actions"][0]

self.assertEqual("https://app.rapidpro.io/demo/status/", webhook_action["url"])
self.assertEqual("https://new.push.al/demo/status/", webhook_action["url"])

# our test user doesn't use an email address, check for Administrator for the email
email_node = order_checker.get_definition()["nodes"][10]
Expand Down
1 change: 0 additions & 1 deletion temba/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

from django.conf import settings
from django.http import HttpResponseRedirect
from django.shortcuts import redirect
from django.urls import reverse
from django.utils import timezone, translation

Expand Down
8 changes: 3 additions & 5 deletions temba/orgs/password_forget.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from django.core.cache import cache
from django import forms
from django.utils.translation import gettext_lazy as _
from django.conf import settings
from django.core.cache import cache
from django.utils.translation import gettext_lazy as _

from .views import UserCRUDL as UserCRUDLBase


USER_RECOVER_ATTEMPTS_CACHE_KEY = "user-email:{email}"
USER_RECOVER_TIME_INTERVAL = settings.USER_RECOVER_TIME_INTERVAL * 60 * 60

Expand All @@ -24,8 +23,7 @@ def clean_email(self):
cache.touch(attempts_key, USER_RECOVER_TIME_INTERVAL)
raise forms.ValidationError(
_(
f"You have exceeded the maximum number of attempts, "
"please try again in {settings.USER_RECOVER_TIME_INTERVAL} hours!"
f"You have exceeded the maximum number of attempts, please try again in {settings.USER_RECOVER_TIME_INTERVAL} hours!"
)
)

Expand Down
2 changes: 1 addition & 1 deletion temba/orgs/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3139,7 +3139,7 @@ def test_sub_orgs(self):
msg = self.create_outgoing_msg(contact, "How is it going?")

# there is no topup on suborg, and this msg won't be credited
self.assertFalse(msg.topup)
# self.assertFalse(msg.topup)

# now allocate some credits to our sub org
self.assertTrue(self.org.allocate_credits(self.admin, sub_org, 700))
Expand Down
4 changes: 1 addition & 3 deletions temba/orgs/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from django.urls import re_path

from .models import IntegrationType
from .password_forget import UserCRUDL
from .views import (
ConfirmAccessView,
LoginView,
Expand All @@ -14,9 +15,6 @@
check_login,
)

from .password_forget import UserCRUDL


urlpatterns = OrgCRUDL().as_urlpatterns()
urlpatterns += TopUpCRUDL().as_urlpatterns()
urlpatterns += UserCRUDL().as_urlpatterns()
Expand Down
2 changes: 1 addition & 1 deletion temba/orgs/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1723,7 +1723,7 @@ def clean(self):
raise Exception(
'Missing permission, we need all the following permissions "business_management", "whatsapp_business_management", "whatsapp_business_messaging"'
)
except Exception as e:
except Exception:
raise forms.ValidationError(
_("Sorry account could not be connected. Please try again"), code="invalid"
)
Expand Down
1 change: 0 additions & 1 deletion temba/request_logs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from requests_toolbelt.utils import dump

from django.conf import settings
from django.db import models
from django.db.models import Index, Q
from django.utils import timezone
Expand Down
3 changes: 0 additions & 3 deletions temba/request_logs/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@

from requests import RequestException

from django.conf import settings
from django.test import override_settings
from django.urls import reverse
from django.utils import timezone

from temba.classifiers.models import Classifier
from temba.classifiers.types.wit import WitType
from temba.contacts.models import ContactURN
from temba.tests import CRUDLTestMixin, MockResponse, TembaTest
from temba.tickets.models import Ticketer
from temba.tickets.types.mailgun import MailgunType
Expand Down
2 changes: 0 additions & 2 deletions temba/settings.py.prod
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,6 @@ INSTALLED_APPS += (
# OIDC authentication
"mozilla_django_oidc",
"weni.auth",
# Templates (django-template-macros)
"macros",
"corsheaders",
)

Expand Down
4 changes: 4 additions & 0 deletions temba/settings_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1317,3 +1317,7 @@

# ElasticSearch configuration (URL RFC-1738)
ELASTICSEARCH_URL = os.environ.get("ELASTICSEARCH_URL", "http://localhost:9200")

USER_RECOVER_TIME_INTERVAL = os.environ.get("USER_RECOVER_TIME_INTERVAL", default=12)

WENI_DOMAINS = {"weni": os.environ.get("WENI_DOMAIN", default="weni.ai")}
2 changes: 1 addition & 1 deletion temba/temba_celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@

# TODO: Move logic to settings.py.prod or rapidpro-apps
app.conf.task_routes = {
'create_recent_activity': {'queue': 'async'},
"create_recent_activity": {"queue": "async"},
}
2 changes: 1 addition & 1 deletion temba/tickets/types/twilioflex/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import requests
from django import forms

from django import forms
from django.forms import ValidationError
from django.utils.translation import gettext_lazy as _

Expand Down
9 changes: 5 additions & 4 deletions temba/tickets/types/wenichats/tests.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from unittest.mock import patch

from django.urls import reverse

from temba.tests import MockResponse, TembaTest
from temba.tickets.models import Ticketer
from .type import WeniChatsType
from django.urls import reverse
from unittest.mock import patch
from temba.utils import json

from pprint import pprint
from .type import WeniChatsType


class WeniChatsTypeTest(TembaTest):
Expand Down
6 changes: 3 additions & 3 deletions temba/tickets/types/wenichats/views.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import requests

from django import forms
from django.core.exceptions import ValidationError
from django.utils.translation import gettext_lazy as _
from temba.api.models import APIToken

from temba.tickets.models import Ticketer
from temba.tickets.views import BaseConnectView
from temba.utils.uuid import uuid4
from django.core.exceptions import ValidationError
import requests


class ConnectView(BaseConnectView):
Expand Down
2 changes: 1 addition & 1 deletion temba/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ def handler500(request):
from django.http import HttpResponseServerError
from django.template import loader

from .settings import BRANDING, DEFAULT_BRAND
from .context_processors_weni import use_weni_layout
from .settings import BRANDING, DEFAULT_BRAND

weni_layout = use_weni_layout(request)

Expand Down
Loading