Skip to content
This repository has been archived by the owner on Nov 21, 2019. It is now read-only.

Commit

Permalink
Implement empty response (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
giorgiosironi authored and GiancarloFusiello committed Feb 4, 2019
1 parent b89d8b6 commit 0eae6bd
Show file tree
Hide file tree
Showing 17 changed files with 848 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.mypy_cache/
.pytest_cache/
15 changes: 15 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
language: minimal

services: docker

install:
- travis_retry make build

script:
- make all-tests

if: |
branch = master OR \
branch =~ /^[0-9\.]+$/ OR \
tag IS present OR \
type = pull_request
3 changes: 1 addition & 2 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
Code of conduct
===============
# Code of conduct

The Libero community follows a [code of conduct](https://libero.pub/code-of-conduct).
87 changes: 87 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
PROJECT_CODEBASE_DIR = "search/"
TESTS_DIR = "tests/"
FILES_TO_CHECK = $(PROJECT_CODEBASE_DIR) $(TESTS_DIR)
DOCKER_COMPOSE = docker-compose -f docker/docker-compose.dev.yml

help:
@echo "start - builds and/or starts all services"
@echo "stop - stops all running containers belonging to the project"
@echo "checks - runs static checks such as linting without running unit tests"
@echo "tests - runs unit tests in debug mode (able to use pdb breakpoints)"
@echo "all-tests - runs static checks and unit tests"
@echo "fix-imports - silently modifies imports on all project files that do not"
@echo " adhere to project coding standards regarding imports"
@echo "run - only runs the application service (able to use pdb breakpoints)"
@echo "shell - enter the shell of the application service"
@echo "build - builds the application service"
@echo "---------------------------------------------------------------"
@echo "make build should be run after adding and removing dependencies"
@echo "---------------------------------------------------------------"
@echo "dependency-tree - show dependency tree"
@echo "d-tree - alias for \"dependency-tree\""
@echo "add-dependency - add or update a python dependency by specifying a package"
@echo " e.g. make dependency package=flask"
@echo " e.g. make dependency package=flask==1.0.2"
@echo "add-dev-dependency - same as \"dependency\" except the package will be installed"
@echo " during development only"
@echo "remove-dependency - remove a python dependency by specifying a package"
@echo " e.g. make remove-dependency package=flask"
@echo "remove-dev-dependency - same as \"remove-dependency\" regarding development dependencies"

start:
$(DOCKER_COMPOSE) up

stop:
$(DOCKER_COMPOSE) down -v

checks:
$(DOCKER_COMPOSE) run --rm web /bin/bash -c "\
echo \"Running checks...\" && \
echo \"- check for breakpoints\" && \
source scripts/find-breakpoints.sh && \
echo \"- mypy\" && \
mypy $(FILES_TO_CHECK) && \
echo \"- flake8\" && \
flake8 $(FILES_TO_CHECK) && \
echo \"- pylint\" && \
pylint --rcfile=setup.cfg $(FILES_TO_CHECK) && \
echo \"All checks completed\" \
"

.PHONY: tests
tests:
$(DOCKER_COMPOSE) run --rm --service-ports web /bin/bash -c \
"pytest -s --pdbcls=IPython.terminal.debugger:Pdb -vv"

all-tests: checks tests

fix-imports:
$(DOCKER_COMPOSE) run --rm web /bin/bash -c "isort -y"

.PHONY: run
run:
$(DOCKER_COMPOSE) run --rm --service-ports web

shell:
$(DOCKER_COMPOSE) run --rm --service-ports web /bin/bash

build:
$(DOCKER_COMPOSE) build web

dependency-tree:
$(DOCKER_COMPOSE) run --rm web /bin/bash -c "poetry show --tree"

d-tree: dependency-tree # alias for dependency-tree

add-dependency:
$(DOCKER_COMPOSE) run --rm web /bin/bash -c "poetry add $(package)"

add-dev-dependency:
$(DOCKER_COMPOSE) run --rm web /bin/bash -c "poetry add $(package) --dev"

remove-dependency:
$(DOCKER_COMPOSE) run --rm web /bin/bash -c "poetry remove $(package)"

remove-dev-dependency:
$(DOCKER_COMPOSE) run --rm web /bin/bash -c "poetry remove $(package) --dev"

84 changes: 80 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,84 @@
Libero search
=============
# Libero Search
This project is an implementation of Libero search API

Getting help
------------
## Dependencies

* [Docker](https://www.docker.com/)

## Getting started
This project provides a `Makefile` with short commands to run common tasks.
Typically, MacOS and most Linux distributions come with [gnu make](https://www.gnu.org/software/make/)
installed. If are unable to run the commands below because your system doesn't
have `gnu make` installed, you can try to install it or copy and paste commands
found in the `Makefile` into your command line interface.

* `make help` for a full list of commands.
* `make start` builds and/or runs the site locally configured for development purposes.
* `make stop` stops containers and cleans up any anonymous volumes.

## Running the tests

* `make tests` runs unit tests.
* `make checks` runs static checks such as: mypy, flake8, pylint.
* `make all-tests` combines the two commands above by running all checks followed
by unit tests

## Adding and removing dependencies

The following commands update files that keep track of project dependencies.

```bash
make add-dependency package=<package name>
make add-dev-dependency package=<package name>

# examples:
make add-dependency package=flask
make add-dependency package=flask==1.0.2
make add-dev-dependency package=pytest
```
These commands add a python package as a project dependency or
development dependency alike. You can specify just the package name to get the
latest version or specify a specific version number.

```bash
make remove-dependency package=<package name>
make remove-dev-dependency package=<package name>
```
These commands remove dependencies accordingly.

```bash
make build
```
Will rebuild the python container and persist changes made to dependency files.

## Other useful commands
```bash
make run
```
Use this command to only run the python service.
It is possible to use pdb breakpoints with this configuration.

```bash
make shell
```
Use this to run the python container that would run the application and enter a
bash prompt.

```bash
make dependency-tree
# or
make d-tree
```
Use this to display a dependency tree

```bash
make fix-imports
```
When checks are run warnings are displayed because imports do not follow the
project conventions as specified in `setup.cfg` under `[isort]`.
Use this command to automatically fix imports for all project python files.

## Getting help

- Report a bug or request a feature on [GitHub](https://github.com/libero/libero/issues/new/choose).
- Ask a question on the [Libero Community Slack](https://libero.pub/join-slack).
Expand Down
26 changes: 26 additions & 0 deletions docker/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM python:3.7.2-alpine3.8

ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV PATH "/root/.poetry/bin:$PATH"

WORKDIR /srv/app

RUN apk add --no-cache \
bash \
grep \
libxslt-dev

RUN apk add --no-cache --virtual .build-dependencies curl && \
curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python && \
poetry config settings.virtualenvs.create false && \
apk del .build-dependencies

COPY ./pyproject.toml ./poetry.lock ./

RUN apk add --no-cache --virtual .build-dependencies \
gcc \
musl-dev \
&& \
poetry install && \
apk del .build-dependencies
2 changes: 2 additions & 0 deletions docker/dev.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FLASK_APP=search
FLASK_ENV=development
15 changes: 15 additions & 0 deletions docker/docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: '3'

services:
web:
build:
context: ..
dockerfile: docker/Dockerfile.dev
working_dir: /srv/app
volumes:
- ..:/srv/app
command: "flask run --host=0.0.0.0"
ports:
- "5000:5000"
env_file:
- dev.env
Loading

0 comments on commit 0eae6bd

Please sign in to comment.