From 041ee6d4af9eb920bc5ef8575dc9eeb065a6d8d5 Mon Sep 17 00:00:00 2001 From: Lova ANDRIARIMALALA <43842786+Xpirix@users.noreply.github.com> Date: Wed, 22 May 2024 11:12:12 +0300 Subject: [PATCH 1/4] Integrate sentry into the django project --- dockerize/.env.template | 5 ++++- dockerize/docker-compose.yml | 1 + dockerize/docker/REQUIREMENTS.txt | 4 +++- qgis-app/settings_docker.py | 15 ++++++++++++++- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/dockerize/.env.template b/dockerize/.env.template index 43f8d6bb..ae22847d 100644 --- a/dockerize/.env.template +++ b/dockerize/.env.template @@ -31,4 +31,7 @@ DEFAULT_PLUGINS_SITE='https://plugins.qgis.org/' QGISPLUGINS_ENV=debug # Ldap -ENABLE_LDAP=True \ No newline at end of file +ENABLE_LDAP=True + +# SENTRY +SENTRY_DSN='' \ No newline at end of file diff --git a/dockerize/docker-compose.yml b/dockerize/docker-compose.yml index 225f9784..e6a17637 100644 --- a/dockerize/docker-compose.yml +++ b/dockerize/docker-compose.yml @@ -53,6 +53,7 @@ services: - EMAIL_HOST_USER=${EMAIL_HOST_USER:-automation} - EMAIL_HOST_PASSWORD=${EMAIL_HOST_PASSWORD} - DEFAULT_PLUGINS_SITE=${DEFAULT_PLUGINS_SITE:-https://plugins.qgis.org/} + - SENTRY_DSN=${SENTRY_DSN} volumes: - ../qgis-app:/home/web/django_project - ./docker/uwsgi.conf:/uwsgi.conf diff --git a/dockerize/docker/REQUIREMENTS.txt b/dockerize/docker/REQUIREMENTS.txt index e9ff83f3..fa09ac7f 100644 --- a/dockerize/docker/REQUIREMENTS.txt +++ b/dockerize/docker/REQUIREMENTS.txt @@ -58,4 +58,6 @@ django-preferences==1.0.0 PyWavefront==1.3.3 django-matomo==0.1.6 uwsgi~=2.0 -freezegun~=1.4 \ No newline at end of file +freezegun~=1.4 + +sentry-sdk~=2.2 \ No newline at end of file diff --git a/qgis-app/settings_docker.py b/qgis-app/settings_docker.py index c0b7be1e..23290d50 100644 --- a/qgis-app/settings_docker.py +++ b/qgis-app/settings_docker.py @@ -159,4 +159,17 @@ MATOMO_URL="//matomo.qgis.org/" # Default primary key type -DEFAULT_AUTO_FIELD = 'django.db.models.AutoField' \ No newline at end of file +DEFAULT_AUTO_FIELD = 'django.db.models.AutoField' + + +# Sentry +SENTRY_DSN = os.environ.get("SENTRY_DSN", "") + +import sentry_sdk + +sentry_sdk.init( + dsn=SENTRY_DSN, + # Set traces_sample_rate to 1.0 to capture 100% + # of transactions for performance monitoring. + traces_sample_rate=1.0, +) From ecfc87638c4a906e2c82d2756e2bcbbfd8beca03 Mon Sep 17 00:00:00 2001 From: Lova ANDRIARIMALALA <43842786+Xpirix@users.noreply.github.com> Date: Thu, 23 May 2024 08:48:04 +0300 Subject: [PATCH 2/4] Init sentry when the dsn is specified --- qgis-app/settings_docker.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/qgis-app/settings_docker.py b/qgis-app/settings_docker.py index 23290d50..baa1bcd8 100644 --- a/qgis-app/settings_docker.py +++ b/qgis-app/settings_docker.py @@ -165,11 +165,12 @@ # Sentry SENTRY_DSN = os.environ.get("SENTRY_DSN", "") -import sentry_sdk - -sentry_sdk.init( - dsn=SENTRY_DSN, - # Set traces_sample_rate to 1.0 to capture 100% - # of transactions for performance monitoring. - traces_sample_rate=1.0, -) +if SENTRY_DSN and SENTRY_DSN != "": + import sentry_sdk + + sentry_sdk.init( + dsn=SENTRY_DSN, + # Set traces_sample_rate to 1.0 to capture 100% + # of transactions for performance monitoring. + traces_sample_rate=1.0, + ) From 0533ad5aef4d0c494bafa47fee851157bd62b6f5 Mon Sep 17 00:00:00 2001 From: Lova ANDRIARIMALALA <43842786+Xpirix@users.noreply.github.com> Date: Thu, 23 May 2024 09:30:00 +0300 Subject: [PATCH 3/4] Fix test in GH actions --- qgis-app/plugins/tests/test_plugin_update.py | 16 ++++++++++++---- qgis-app/plugins/tests/test_plugin_upload.py | 8 ++++++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/qgis-app/plugins/tests/test_plugin_update.py b/qgis-app/plugins/tests/test_plugin_update.py index d1e4c34b..118b12d8 100644 --- a/qgis-app/plugins/tests/test_plugin_update.py +++ b/qgis-app/plugins/tests/test_plugin_update.py @@ -92,9 +92,13 @@ def test_plugin_new_version(self): self.assertEqual(self.plugin.tracker, "https://github.com/") self.assertEqual(self.plugin.repository, "https://github.com/") - self.assertEqual( + self.assertIn( + 'admin@admin.it', mail.outbox[0].recipients(), - ['admin@admin.it', 'staff@staff.it'] + ) + self.assertIn( + 'staff@staff.it', + mail.outbox[0].recipients() ) # Should use the new email @@ -145,9 +149,13 @@ def test_plugin_version_update(self): self.assertEqual(self.plugin.tracker, "https://github.com/") self.assertEqual(self.plugin.repository, "https://github.com/") - self.assertEqual( + self.assertIn( + 'admin@admin.it', mail.outbox[0].recipients(), - ['admin@admin.it', 'staff@staff.it'] + ) + self.assertIn( + 'staff@staff.it', + mail.outbox[0].recipients() ) # Should use the new email diff --git a/qgis-app/plugins/tests/test_plugin_upload.py b/qgis-app/plugins/tests/test_plugin_upload.py index 9b3d2814..f2819ea9 100644 --- a/qgis-app/plugins/tests/test_plugin_upload.py +++ b/qgis-app/plugins/tests/test_plugin_upload.py @@ -69,9 +69,13 @@ def test_plugin_upload_form(self): 3) self.assertTrue(PluginVersion.objects.filter(plugin__name='Test Plugin', version='0.0.1').exists()) - self.assertEqual( + self.assertIn( + 'admin@admin.it', mail.outbox[0].recipients(), - ['admin@admin.it', 'staff@staff.it'] + ) + self.assertIn( + 'staff@staff.it', + mail.outbox[0].recipients() ) # Should use the new email From b62c572d7642a05972cb9ab81f5d0d175b6183e9 Mon Sep 17 00:00:00 2001 From: Lova ANDRIARIMALALA <43842786+Xpirix@users.noreply.github.com> Date: Thu, 23 May 2024 09:57:28 +0300 Subject: [PATCH 4/4] Update the url in valid_metadata_link --- .../tests/testfiles/valid_metadata_link.zip | Bin 45863 -> 45877 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/qgis-app/plugins/tests/testfiles/valid_metadata_link.zip b/qgis-app/plugins/tests/testfiles/valid_metadata_link.zip index 94ca6c67422f50a82f6095533a745fcf30fa740e..6c53b03958e43f8cf92f6da86e17b391aa5034f8 100644 GIT binary patch delta 1493 zcmZ9Mc~DbV6vp!&A&@{K3dR_aASfb52a6ygN|LfPpeTd1ARtRvM6hfL!3YH0TB#73 zqfiMBhAr#?A`!=>6lp(xbj-SNe0ZWX8MX+eRh9JmdHrEPHD17IkYkEASVGV)?YHlb#*jH2407 ztAju9$PbU;%ue4;VI5nXs$hhWJ{F!o>u{2)r25SL%~?X4y07HsMO%+}l1LOs@5JCZ zqUy|uS%)f}Q!@5h-jln|o+d_%Dz2C^;Pk80qO+i!S#_JUkZ~taMay*giEjJccvA0i z-Jc@3)Of4!GLBuv*5dT*WM`Qa!qVf6FtTb@pI4g*B+WoP}%pZu2_nbH71L zQqHc|8;puGGF4B~gfj8zeEN84Kw?K%nBAtR`J=@6VL3Stja%|IpX%I23R(Q;B@ZO^ z246e~>!|5I&9}e0bTdGNXc}76W`$Ho0mvz&zbKksywvu97 za5D+Zn~J_b!033waea&olZCpoolZ5;?N^#Mq|-9^y_g1Ufdn&*3xs5hB2KA)Ml+|1 zW#7agSTVtwQGJX;#4S3FToh@9<)xO{>Eksc3zwvu@!E0!p@yNDmhzDQO>%PO7A(HD z+8n;Gv_#}ETKOgN0bHtrP_M1Psx^c7t;>PeU=0teEYThpwX_yiR(qj>?OM!MqpO=1 zUsn67{f;$}NF)^1B%t?pY5gX$5VW18%{VLbLi5>LwUJGOB^eVD0<$(Ap+jwL6dLKL z4KeC=qci?m17j~4By~(=35M(9C zhwAN(#lgYY)nMAd)bmZiK}dq7`uI$==PMvpSi-{wUt|FojlrmADp)nHgu=%CXh@nC zv(ik#xQU6n@U@>I{1w1&V(O6vIIs|y!vi(9s<~4@1&3xPvI&kfA3y+ln}d)Mu#_J_ z-oa6M5Wu-Y9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