Commit 9e55e24c authored by dmanik's avatar dmanik
Browse files

shortened gitlab-ci snippet for unittests

parent b086d55b
# This file is a template, and might need editing before it works on your project.
# Official language image. Look for the different tagged releases at:
# https://hub.docker.com/r/library/python/tags/
# specify a docker image
image: debsankhamanik/ecoptimizer_testenv:latest
# Change pip's cache directory to be inside the project directory since we can
# only cache local items.
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
# Pip's cache doesn't store the python packages
# https://pip.pypa.io/en/stable/reference/pip_install/#caching
#
# If you want to also cache the installed packages, you have to install
# them in a virtualenv and cache it as well.
cache:
paths:
- .cache/pip
- venv/
# Run necessary steps before pipeline can be run
before_script:
# we create SSL certs for server tests
- oldpwd=$(pwd)
- mkdir $HOME/ssl
- cd $HOME/ssl
# CA (certificate authority) key
- openssl genrsa -des3 -passout pass:'abcd' -out ecoptimizerCA.key 2048
# CA cert
- openssl req -x509 -new -nodes -key ecoptimizerCA.key -sha256 -days 1825 -passin pass:'abcd' -out ecoptimizerCA.pem -subj "/C=XY/ST=test/L=Test/O=IT/CN=www.example.com"
# client key
- openssl genrsa -out ecoptimizer_production.key 2048
- openssl req -new -key ecoptimizer_production.key -out ecoptimizer_production.csr -subj "/C=XY/ST=test/L=Test/O=IT/CN=www.example.com"
- |
cat >> ecoptimize.ext << EOF
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
subjectAltName = @alt_names
[alt_names]
DNS.1 = 127.0.0.1
DNS.2 = localhost
EOF
# client cert
- openssl x509 -req -in ecoptimizer_production.csr -CA ecoptimizerCA.pem -CAkey ecoptimizerCA.key -CAcreateserial -passin pass:"abcd" -out ecoptimizer_production.crt -days 1825 -sha256 -extfile ecoptimize.ext
- pwd && ls
- cd $oldpwd
- pwd
- python -V # Print out python version for debugging
# create virtualenv if not existing
- if [ ! -d "venv" ]; then pip install -U pip && pip install virtualenv && virtualenv venv; fi
- source venv/bin/activate
# install itself using pip
- pip install -e .[dev]
# create badges directory
- mkdir badges/
# define two stages: unittest and integration_test
stages:
- unittest
- integration_test
- deploy
# job unittests, belongs to stage unittests
unittests:
stage: unittest
# here goes the command that is actually run
script:
- python ecoptimizer/testing/testsuite_runner.py run_unittests
artifacts:
paths:
- public
expire_in: 6 mos
when: always # ensure badges are uploaded even when jobs fail
# job integration tests, belongs to stage integration tests
integration_tests:
stage: integration_test
# do not run this for commits to non-master branches
only:
- schedules
- master
script:
- python ecoptimizer/testing/testsuite_runner.py run_integration_tests
artifacts:
paths:
- public
expire_in: 6 mos
when: always
pages:
stage: deploy
before_script:
- echo "no need to set up python environment just for deploying badges" # Without this,
# time consuming global before_script will be run
script:
- echo "deploying badges to gitlab pages"
- ls public/badges/
artifacts:
paths:
- public
expire_in: 6 mos
when: always # without this, pages job won't be run unless both unittests and
# integration tests succeed
only:
- master
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment