This commit is contained in:
Jannis Leidel 2019-02-26 11:56:11 +01:00
Родитель f78f66ad91
Коммит 51180c2a79
27 изменённых файлов: 207 добавлений и 142 удалений

72
.circleci/config.yml Normal file
Просмотреть файл

@ -0,0 +1,72 @@
version: 2.0
# Jobs: see https://circleci.com/docs/2.0/jobs-steps/
jobs:
tests:
machine:
image: circleci/classic:edge
environment:
COMPOSE_FILE: .circleci/docker-compose.circle.yml
COMPOSE_PROJECT_NAME: redash
steps:
- checkout
- run:
name: Install Docker Compose
command: |
curl -L https://github.com/docker/compose/releases/download/1.23.2/docker-compose-`uname -s`-`uname -m` > ~/docker-compose
chmod +x ~/docker-compose
sudo mv ~/docker-compose /usr/local/bin/docker-compose
- run:
name: Build Docker Images
command: |
set -x
make build
- run:
name: Run Tests
command: |
set -x
export CI_ENV=`bash <(curl -s https://codecov.io/env)`
docker-compose up -d
sleep 10
docker-compose run --rm postgres psql -U postgres -h postgres -c "create database tests;" || echo "Error while creating tests database"
docker-compose run --name tests --rm $(CI_ENV) server ci
# Runs when the repository is tagged for release; see the workflows section
# below for trigger logic.
deploy:
docker:
- image: python:3.6
steps:
- checkout
- run:
name: Install deployment tools
command: |
pip install --upgrade setuptools flit wheel twine
- run:
name: Create the distribution files
command: |
flit build
- run:
name: Check Readme rendering
command: |
twine check dist/*
- run:
name: Upload to PyPI
command: |
flit publish
# Workflows: see https://circleci.com/docs/2.0/workflows/
workflows:
version: 2
build:
jobs:
- tests
deploy:
jobs:
- deploy:
filters:
tags:
only: /[0-9]{2}.[0-9]{1,2}.[0-9]+/ # Calver: YY.M.PATCH
branches:
# Ignore all branches; this workflow should only run for tags.
ignore: /.*/

Просмотреть файл

@ -0,0 +1,26 @@
version: '3'
services:
server:
build: ../
working_dir: /extension
command: manage version
depends_on:
- postgres
- redis
ports:
- "5000:5000"
volumes:
- $PWD:/extension
environment:
PYTHONPATH: /app
PYTHONUNBUFFERED: 0
REDASH_LOG_LEVEL: "INFO"
REDASH_REDIS_URL: "redis://redis:6379/0"
REDASH_DATABASE_URL: "postgresql://postgres@postgres/postgres"
redis:
image: redis:3.0-alpine
restart: unless-stopped
postgres:
image: postgres:9.5.6-alpine
command: "postgres -c fsync=off -c full_page_writes=off -c synchronous_commit=OFF"
restart: unless-stopped

Просмотреть файл

@ -1,21 +0,0 @@
sudo: false
dist: xenial
language: python
python:
- '2.7'
services:
- docker
install:
- pip install --upgrade pip setuptools wheel
script:
- export CI_ENV=`bash <(curl -s https://codecov.io/env)`
- make test
deploy:
provider: pypi
user: emtwo
distributions: sdist bdist_wheel
password:
secure: t+gT1RLpn7k4yVD+uU4QRVXOssjh7kih6VAgpj/WPi/uWAEJ2CEj6SwXQhAKzuvtbGglkAiCL7wsWqUNFzmRmTRMnxZwrVESXpuqGjc44jBV/JHGbuFlzY+ycJl7xW3rt/JXydw4O50F/0IuIf+1M6VmosLd0HZw5Sny92DTZm7AHyJbS8vtJEFoewP2J4XmGT6h1Ldq0l/tXyGdzJWo3xKltxewwYnGuksyTOR9c4fmg6TiA1EVXNA6QdJGIZR8SbO0y6ZJ+Y1+RVYzmFSCDPku5SD8cQDGs3xcFu048DqEuWITP2wGmSfsHX9U1LqCkRDPFjNM2JGpOOiEx7mGe8Vyx72RPS4sfpKgkvLZxBFZWlqj8miPkaqPNCAgaOOeMw6fgOa28jGLkU/svFSQdv4RB1dFrrvwoDPBlNKvmzOtJX4Pc3vJ14rFa8KhxF3aBzdTGFQU7KoPhIOA5qRmZwbdHbdWN5NSODJOVcXkR0GBe86PcL6g9SHPM7pENOvVns/nXbmBtChuYRFJ5s8hCWLTiUKfHgqN6l4c8Tueg+0yrLzz+vzkj9e5s/FxxFpjuU9VNbes0uvZPEKc4lSAi6awZBmjfZhppnyhFEeYYfgacqIIt/cme4LpamyU3ck9zmJZnKC+/r4qVAaLRUWPfSAk9a+U/QAMSJeumiW0E0U=
on:
tags: true
repo: mozilla/redash-stmo

Просмотреть файл

@ -1,13 +1,9 @@
FROM mozilla/redash:latest
ENV PYTHONUNBUFFERED=0 \
PYTHONPATH=/redash-stmo:/redash-stmo/src:/app \
REDASH_LOG_LEVEL="INFO" \
REDASH_REDIS_URL=redis://redis:6379/0 \
REDASH_DATABASE_URL=postgresql://postgres@postgres/postgres
USER root
RUN pip uninstall -y redash-stmo
RUN apt-get update && apt-get install -y python3 python3-pip
RUN pip uninstall -qy redash-stmo \
&& pip3 install flit
USER redash
ENTRYPOINT ["/redash-stmo/bin/docker-entrypoint"]
ENTRYPOINT ["/extension/bin/docker-entrypoint"]

Просмотреть файл

@ -1,4 +1,4 @@
.PHONY: bash build clean package release sdist test wheel
.PHONY: bash build clean tables test_database package release sdist test wheel
bash:
docker-compose run --rm server bash
@ -20,10 +20,12 @@ package: clean sdist wheel
release: package
twine upload -s dist/*
test:
docker-compose build --pull
docker-compose up -d
docker-compose run --rm server sh -c "/redash-stmo/bin/wait-for-it.sh postgres:5432 -- python /app/manage.py database create_tables"
docker-compose run --rm postgres psql -h postgres -U postgres -c "create database tests;" || echo "Test database exists already."
docker-compose run --rm $(CI_ENV) server tests
docker-compose down
test_database:
docker-compose up --no-start
docker-compose start postgres
docker-compose run --rm server /extension/bin/wait-for-it.sh postgres:5432 -- echo "Postgres started"
docker-compose run --rm postgres psql -U postgres -h postgres -c "create database tests;" || echo "Error while creating tests database"
test: build test_database
docker-compose run --rm server tests
docker-compose stop

Просмотреть файл

@ -1,24 +1,21 @@
Redash-STMO
===========
.. image:: https://travis-ci.org/mozilla/redash-stmo.svg?branch=master
:target: https://travis-ci.org/mozilla/redash-stmo
.. image:: https://codecov.io/gh/mozilla/redash-stmo/branch/master/graph/badge.svg
:target: https://codecov.io/gh/mozilla/redash-stmo
Or as it should have been called: St. Moredash ;)
.. image:: https://travis-ci.org/mozilla/redash-stmo.svg?branch=master
:target: https://travis-ci.org/mozilla/redash-stmo
.. image:: https://codecov.io/gh/mozilla/redash-stmo/branch/master/graph/badge.svg
:target: https://codecov.io/gh/mozilla/redash-stmo
`Redash <https://redash.io>`_ extensions for
`sql.telemetry.mozilla.org <https://sql.telemetry.mozilla.org/>`_.
Or as it should have been called: *St. Moredash* ;)
.. image:: https://circleci.com/gh/mozilla/redash-stmo.svg?style=svg
:target: https://circleci.com/gh/mozilla/redash-stmo
.. image:: https://codecov.io/gh/mozilla/redash-stmo/branch/master/graph/badge.svg
:target: https://codecov.io/gh/mozilla/redash-stmo
.. image:: https://img.shields.io/badge/calver-YY.M.PATCH-22bfda.svg
:target: https://calver.org/
:alt: CalVer - Timely Software Versioning
Installation
------------

Просмотреть файл

@ -1,42 +1,46 @@
#!/bin/bash
set -e
pushd /extension
# always install inside the running container
flit install --user --python=/usr/bin/python --symlink --extras=test
popd
server() {
pip install --user -e /redash-stmo
exec /usr/local/bin/gunicorn -b 0.0.0.0:5000 --name redash -w${REDASH_WEB_WORKERS:-4} redash.wsgi:app
}
create_db() {
exec /app/manage.py database create_tables
create_tables() {
pushd /app
/extension/bin/wait-for-it.sh postgres:5432 -- /app/manage.py database create_tables
popd
}
tests() {
pip install --user /redash-stmo
pip install --user pytest mock pytest-cov pytest-flake8
export REDASH_DATABASE_URL="postgresql://postgres@postgres/tests"
create_tables
if [ $# -eq 0 ]; then
TEST_ARGS=/redash-stmo
TEST_ARGS=/extension
else
TEST_ARGS=$@
fi
pytest $TEST_ARGS
# only run this if the CI env var is set:
if [[ ! -z ${CI+check} ]]; then
bash <(curl -s https://codecov.io/bash) -s /tmp
fi
}
# always install inside the running container
case "$1" in
tests)
shift
tests $@
;;
create_db)
ci)
shift
create_db
tests $@
bash <(curl -s https://codecov.io/bash) -s /tmp
;;
create_tables)
shift
create_tables
;;
manage)
shift

Просмотреть файл

@ -6,16 +6,20 @@ services:
depends_on:
- postgres
- redis
volumes:
- $PWD:/redash-stmo
ports:
- "5000:5000"
volumes:
- $PWD:/extension
environment:
PYTHONPATH: /app
PYTHONUNBUFFERED: 0
REDASH_LOG_LEVEL: "INFO"
REDASH_REDIS_URL: "redis://redis:6379/0"
REDASH_DATABASE_URL: "postgresql://postgres@postgres/postgres"
REDASH_GOOGLE_CLIENT_ID: "dummy"
REDASH_GOOGLE_CLIENT_SECRET: "dummy"
restart: always
worker:
image: redash/redash:latest
image: mozilla/redash:latest
command: scheduler
depends_on:
- server
@ -23,12 +27,11 @@ services:
QUEUES: "queries,scheduled_queries,celery"
WORKERS_COUNT: 2
REDASH_REDIS_URL: "redis://redis:6379/0"
REDASH_DATABASE_URL: "postgresql://postgres@postgres/postgres"
redis:
image: redis:3.0-alpine
restart: unless-stopped
postgres:
image: postgres:9.5.6-alpine
image: postgres:9.5.6
command: "postgres -c fsync=off -c full_page_writes=off -c synchronous_commit=OFF"
restart: unless-stopped
volumes:
server:

51
pyproject.toml Normal file
Просмотреть файл

@ -0,0 +1,51 @@
[build-system]
requires = ["flit"]
build-backend = "flit.buildapi"
[tool.flit.metadata]
dist-name = "redash-stmo"
module = "redash_stmo"
author = "Mozilla Foundation"
author-email = "dev-webdev@lists.mozilla.org"
home-page = "https://github.com/mozilla/redash-stmo"
requires = [
"dockerflow>=2018.4.0",
"requests",
"sqlparse",
"six",
"pyhive",
]
description-file = "README.rst"
classifiers=[
"Development Status :: 5 - Production/Stable",
"Environment :: Web Environment :: Mozilla",
"Framework :: Django",
"Intended Audience :: Developers",
"License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Topic :: Internet :: WWW/HTTP",
]
license = "MPL 2.0"
[tool.flit.metadata.requires-extra]
test = [
"pytest",
"mock",
"pytest-cov",
"pytest-flake8",
]
[tool.flit.entrypoints."redash.extensions"]
dockerflow = "redash_stmo.dockerflow:extension"
datasource_health = "redash_stmo.data_sources.health:extension"
datasource_link = "redash_stmo.data_sources.link:extension"
datasource_version = "redash_stmo.data_sources.version:extension"
handler_queryresults = "redash_stmo.handlers.query_results:extension"
queryrunner_presto = "redash_stmo.query_runner.presto:extension"

Просмотреть файл

@ -1,3 +1,3 @@
[pytest]
norecursedirs = .git .*
addopts = --flake8 -rsxX --showlocals --tb=native --cov=redash_stmo --cov-report xml --cov-report term --cov-config .coveragerc --cov-config /redash-stmo/.coveragerc
norecursedirs = .git .* build
addopts = --flake8 -rsxX --showlocals --tb=native --cov=redash_stmo --cov-report xml --cov-report term --cov-config .coveragerc --cov-config /extension/.coveragerc

Просмотреть файл

@ -1,10 +1,6 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, you can obtain one at http://mozilla.org/MPL/2.0/.
from pkg_resources import get_distribution, DistributionNotFound
"""Extensions to Redash by Mozilla"""
try:
__version__ = get_distribution(__name__).version
except DistributionNotFound:
# package is not installed
pass
__version__ = "2019.2.1"

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -1,61 +0,0 @@
import os
import codecs
from setuptools import setup, find_packages
def read(*parts):
filename = os.path.join(os.path.dirname(__file__), *parts)
with codecs.open(filename, encoding='utf-8') as fp:
return fp.read()
setup(
name='redash-stmo',
use_scm_version={
'version_scheme': 'post-release',
'local_scheme': 'dirty-tag'
},
setup_requires=['setuptools_scm'],
install_requires=[
'dockerflow>=2018.4.0',
'requests',
'sqlparse',
'six',
'pyhive',
],
packages=find_packages(where='src'),
package_dir={'': 'src'},
include_package_data=True,
description="Extensions to Redash by Mozilla",
long_description=read('README.rst'),
author='Mozilla Foundation',
author_email='dev-webdev@lists.mozilla.org',
url='https://github.com/mozilla/redash-stmo',
license='MPL 2.0',
entry_points={
'redash.extensions': [
'dockerflow = redash_stmo.dockerflow:extension',
'datasource_health = redash_stmo.data_sources.health:extension',
'datasource_link = redash_stmo.data_sources.link:extension',
'datasource_version = redash_stmo.data_sources.version:extension',
'handler_queryresults = redash_stmo.handlers.query_results:extension',
'queryrunner_presto = redash_stmo.query_runner.presto:extension',
],
},
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment :: Mozilla',
'Framework :: Django',
'Intended Audience :: Developers',
'License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Topic :: Internet :: WWW/HTTP',
],
zip_safe=False,
)