Skip to content
This repository was archived by the owner on Mar 28, 2025. It is now read-only.
Merged
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
35 changes: 32 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,38 @@
name: Test Server Core
name: Lint & Test
on: [push, pull_request]

jobs:
test-core:
name: Run Core Tests
lint:
name: Lint
runs-on: ubuntu-latest

# We want to run on external PRs, but not on our own internal PRs as they'll be run
# by the push to the branch. This prevents duplicated runs on internal PRs.
# Some discussion of this here:
# https://github.community/t/duplicate-checks-on-push-and-pull-request-simultaneous-event/18012
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository

steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9

- name: Install Python Packages
run: |
pip install --upgrade pip
pip install tox

- name: Run isort
run: tox -e isort

- name: Run Black
run: tox -e black

test:
name: Test
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand Down
19 changes: 12 additions & 7 deletions analytics.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@

import importlib
import contextlib
import importlib
import os
from collections import defaultdict

from sqlalchemy.orm.session import Session

from .model import ExternalIntegration
from .config import CannotLoadConfiguration
from .model import ExternalIntegration
from .util.datetime_helpers import utc_now


class Analytics(object):

GLOBAL_ENABLED = None
Expand All @@ -22,15 +23,17 @@ def __init__(self, _db):
Analytics.LIBRARY_ENABLED = set()
# Find a list of all the ExternalIntegrations set up with a
# goal of analytics.
integrations = _db.query(ExternalIntegration).filter(ExternalIntegration.goal==ExternalIntegration.ANALYTICS_GOAL)
integrations = _db.query(ExternalIntegration).filter(
ExternalIntegration.goal == ExternalIntegration.ANALYTICS_GOAL
)
# Turn each integration into an analytics provider.
for integration in integrations:
kwargs = {}
module = integration.protocol
if module.startswith('.'):
if module.startswith("."):
# This is a relative import. Import it relative to
# this module. This should only happen during tests.
kwargs['package'] =__name__
kwargs["package"] = __name__
else:
# This is an absolute import. Trust sys.path to find it.
pass
Expand All @@ -48,7 +51,9 @@ def __init__(self, _db):
self.library_providers[library.id].append(provider)
Analytics.LIBRARY_ENABLED.add(library.id)
else:
self.initialization_exceptions[integration.id] = "Module %s does not have Provider defined." % module
self.initialization_exceptions[integration.id] = (
"Module %s does not have Provider defined." % module
)
except (ImportError, CannotLoadConfiguration) as e:
self.initialization_exceptions[integration.id] = e

Expand Down
Loading