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

Refresh stack #6

Merged
merged 7 commits into from Oct 3, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
125 changes: 125 additions & 0 deletions .circleci/config.yml
@@ -0,0 +1,125 @@
---
version: 2

jobs:
build:
docker:
- image: python:2.7
- image: mongo:3.2
- image: udata/elasticsearch:2.4.5
steps:
- checkout
- run:
name: Compute Python dependencies key
command: cat requirements/*.pip > python.deps
- run:
name: Get the base reference branch
command: export BASE_BRANCH=$(base_branch)
- restore_cache:
keys:
- py-cache-v0-{{ arch }}-{{ checksum "python.deps" }}
- py-cache-v0-{{ arch }}-{{ .Branch }}
- py-cache-v0-{{ arch }}-master
- run:
name: Install python dependencies
command: |
virtualenv venv
source venv/bin/activate
pip install -e .[test,report]
- save_cache:
key: py-cache-v0-{{ arch }}-{{ checksum "python.deps" }}
paths:
- venv
- save_cache:
key: py-cache-v0-{{ arch }}-{{ .Branch }}
paths:
- venv
- run:
name: Run tests
command: |
mkdir -p reports/python
source venv/bin/activate
pytest --junitxml=reports/python/tests.xml
flake8 cada
- store_test_results:
path: reports/python
- store_artifacts:
path: reports/
destination: reports
- run:
name: Build a distributable package
command: |
source venv/bin/activate
# Build a wheel release
if [[ $CIRCLE_TAG ]]; then
# This is a tagged release
python setup.py bdist_wheel
else
# This is a simple development build
python setup.py egg_info -b $CIRCLE_BUILD_NUM bdist_wheel
fi
- store_artifacts:
path: dist
- persist_to_workspace:
root: .
paths:
- dist

publish:
docker:
- image: python:2.7
steps:
- attach_workspace:
at: .
- run:
name: Install Twine
command: pip install twine
- deploy:
name: Publish on PyPI
command: twine upload --username "${PYPI_USERNAME}" --password "${PYPI_PASSWORD}" dist/*.whl

github:
docker:
- image: apihackers/ghr
steps:
- attach_workspace:
at: .
- run:
name: Upload github release
command: -t ${GITHUB_OAUTH_TOKEN} ${CIRCLE_TAG} dist

workflows:
version: 2
build:
jobs:
- build:
filters:
branches:
only:
- master
- /[0-9]+(\.[0-9]+)+/
- /pull/[0-9]+/
- /pyup-update-.+/
- l10n_master
tags:
only: /v[0-9]+(\.[0-9]+)+/
- publish:
requires:
- build
filters:
branches:
only:
- master
- /[0-9]+(\.[0-9]+)+/
tags:
only: /v[0-9]+(\.[0-9]+)+/
context: org-global
- github:
requires:
- build
filters:
branches:
ignore: /.*/
tags:
only: /v[0-9]+(\.[0-9]+)+/
context: org-global
7 changes: 7 additions & 0 deletions CHANGELOG.md
@@ -0,0 +1,7 @@
## Current (in progress)

- Upgrade stack to latest dependencies (Flask 1.0 with `flask.cli`, pytest...)

## 0.1.0 (2014-04-14)

- Initial release
98 changes: 98 additions & 0 deletions README.md
@@ -0,0 +1,98 @@
# CADA

[![Build status][circleci-badge]][circleci-url]
[![Join the chat at https://gitter.im/etalab/cada][gitter-badge]][gitter-url]


A simplistic interface to search and consult CADA advices.

This is the engine behind https://cada.data.gouv.fr.

## Compatibility

CADA has been tested on Python 2.7, MongoDB 3.2 and ElasticSearch 2.4.

The [ElasticSearch ICU Analysis plugin](https://www.elastic.co/guide/en/elasticsearch/plugins/2.4/analysis-icu.html) is required.

You can install it with:

```console
bin/plugin install analysis-icu
```

## Installation

You can install Cada with pip:

```bash
$ pip install cada
```

You need to create the cada working directory, designed by ``$HOME`` in this documentation:

```bash
$ mkdir -p $HOME && cd $HOME
$ vim cada.cfg # See configuration
$ wget https://cada.data.gouv.fr/export -O data.csv
$ cada load data.csv # Load initial data
$ cada static # Optional: collect static assets for proper caching
$ cada runserver
```


## Configuration
All configuration is done through the ``cada.cfg`` file in ``$HOME``.
It's basically a Python file with constants defined in it:

* ``SERVER_NAME``: the public server name. Mainly used in emails.
* ``SECRET_KEY``: the common crypto hash.Used for session by exemple.
* ``ELASTICSEARCH_URL``: the ElasticSearch server URL in ``host:port`` format. Default to ``localhost:9200`` if not set
* ``MONGODB_SETTINGS``: a dictionary to configure MongoDB. Default to ``{'DB': 'cada'}``. See [the official flask-mongoengine documentation](https://flask-mongoengine.readthedocs.org/en/latest/) for more details.

### Mails

Mail server configuration is done through the following variables:

* ``MAIL_SERVER``: SMTP server hostname. Default to ``localhost``.
* ``MAIL_PORT``: SMTP server port. Default to ``25``.
* ``MAIL_USE_TLS``: activate TLS. Default to ``False``.
* ``MAIL_USE_SSL``: activate SSL. Default to ``False``.
* ``MAIL_USERNAME``: optional SMTP server username.
* ``MAIL_PASSWORD``: optional SMTP server password.
* ``MAIL_DEFAULT_SENDER``: Sender email used for mailings. Default to ``cada@localhost``.
* ``ANON_ALERT_MAIL``: destination mail for anonymisation alerts. Default to ``cada.alert@localhost``.

See the [official Flask-Mail documentation](http://pythonhosted.org/flask-mail/#configuring-flask-mail) for more details.

### Sentry

There is an optional support for Sentry.
You need to install the required dependencies:

```bash
$ pip install raven[flask]
# Or to install it with cada
$ pip install cada[sentry]
```

You need to add your Sentry DSN to the configuration

```python
SENTRY_DSN = 'https://xxxxx:xxxxxx@sentry.mydomain.com/id'
```


### Piwik

There is an optional Piwik support.
You simply need to add your Piwik server URL and your Piwik project ID to the configuration:

```python
PIWIK_URL = 'piwik.mydomain.com'
PIWIK_ID = X
```

[circleci-url]: https://circleci.com/gh/etalab/cada
[circleci-badge]: https://circleci.com/gh/etalab/cada.svg?style=shield
[gitter-badge]: https://badges.gitter.im/Join%20Chat.svg
[gitter-url]: https://gitter.im/etalab/cada
108 changes: 0 additions & 108 deletions README.rst

This file was deleted.

25 changes: 25 additions & 0 deletions bumpr.rc
@@ -0,0 +1,25 @@
[bumpr]
file = setup.py
regex = \s{4}version='(?P<version>.+?)',
vcs = git
commit = true
tag = true
tag_format = v{version}
push = true
tests = pytest
publish = pytest setup.py bdist_wheel
files =
README.md

[bump]
unsuffix = true

[prepare]
part = patch
suffix = dev

[changelog]
file = CHANGELOG.md
bump = ## {version} ({date:%Y-%m-%d})
prepare = ## Current (in progress)
separator =
1 change: 1 addition & 0 deletions cada/__init__.py
Expand Up @@ -8,6 +8,7 @@


class DefaultConfig(object):
MONGODB_HOST = 'localhost'
MONGODB_DB = 'cada'
SECRET_KEY = 'no-secret-this-is-open'
MAIL_DEFAULT_SENDER = 'cada@locahost'
Expand Down