datarevenue-berlin / project-template

A logical, reasonably standardized, but flexible tasks as containers project structure for doing, sharing and deploying data science work. Based on:
http://drivendata.github.io/cookiecutter-data-science/
MIT License
0 stars 1 forks source link

Add script to streamline image building and testing #12

Open kayibal opened 5 years ago

kayibal commented 5 years ago

I think it is a good idea to have the following practice before pushing any docker image:

  1. Build image with minimal requirements
  2. Based on previous image install test_requirements
  3. Run all tests in a container
  4. if all tests pass push image built in 1.)

I think we should enforce this with a bashscript that automates the process. We should then also use this in CI env to build and push images.

What do you think @mdank @vitords ?

Here is a starting point for such a script:

#!/usr/bin/env bash
set -e
IMAGE=drtools/project:$TAG
docker build --pull -t $IMAGE -f Dockerfile ..
docker run \
    -e DRTOOLS_SETTINGS_MODULE=project.settings.tests \
    -e AWS_ACCESS_KEY_ID=dummy-access-key \
    -e AWS_SECRET_ACCESS_KEY=dummy-access-key-secret \
    -e AWS_DEFAULT_REGION=eu-west-1 \
    --user root \
    $IMAGE \
        py.test \
        -W ignore \
        -x \
        --ignore project/tests/integration \
        project/tests
docker push $IMAGE
michcio1234 commented 5 years ago

Would you swear for your MacBook that you'll run integration tests after every build and before every push? :P

kayibal commented 5 years ago

Hahaha no that's why they are ignored right ;) but unittests at least.