Skip to content

Commit

Permalink
first try
Browse files Browse the repository at this point in the history
  • Loading branch information
yakutovicha committed Nov 8, 2019
1 parent e5201d3 commit 90dd17e
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 13 deletions.
26 changes: 26 additions & 0 deletions .ci/check_travis_tag.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
# pylint: disable=invalid-name
###############################################################################
# Copyright (c), The AiiDA-CP2K authors. #
# SPDX-License-Identifier: MIT #
# AiiDA-CP2K is hosted on GitHub at https://github.com/aiidateam/aiida-cp2k #
# For further information on the license, see the LICENSE.txt file. #
###############################################################################
"""Check travis tag"""
from __future__ import print_function
from __future__ import absolute_import

import os
import sys
import json

a = os.getenv("TRAVIS_TAG")
with open("setup.json") as fhandle:
b = "v{version}".format(**json.load(fhandle))

if not a:
print("TRAVIS_TAG not set")

elif a != b:
print("ERROR: TRAVIS_TAG and version are inconsistent: '%s' vs '%s'" % (a, b))
sys.exit(3)
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ services:
- docker

before_install:
- python .ci/check_travis_tag.py
- docker build -t aiida_raspa_test .
- docker run -d aiida_raspa_test
- sleep 30 # wait untill the container is launched

script:
- sleep 30 # wait untill the container is launched
- "export DOCKERID=`docker ps -qf 'ancestor=aiida_raspa_test'`"
- "echo \"Docker ID: $DOCKERID\""
- "docker exec -it --user aiida \"$DOCKERID\" /bin/bash -l -c 'cd code/aiida-raspa/ && ./run_tests.sh'"
- "docker exec -it --user aiida \"$DOCKERID\" /bin/bash -l -c 'cd code/aiida-cp2k/ && pre-commit run --all-files || ( git status --short ; git diff ; exit 1 ) '"
- "docker exec -it --user aiida \"$DOCKERID\" /bin/bash -l -c 'cd code/aiida-cp2k/ && py.test --cov aiida_cp2k --cov-append .'"

git:
depth: 3
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ RUN ./configure --prefix=${RASPA2_DIR}
RUN make
RUN make install

ENV PATH="/home/aiida/code/RASPA2_installed/bin/:${PATH}"

# Populate reentry cache for aiida user https://pypi.python.org/pypi/reentry/
RUN reentry scan

Expand Down
11 changes: 11 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""
For pytest initialise a test database and profile
"""
from __future__ import absolute_import
import pytest
pytest_plugins = ['aiida.manage.tests.pytest_fixtures'] # pylint: disable=invalid-name


@pytest.fixture(scope='function')
def raspa_code(aiida_local_code_factory): # pylint: disable=unused-argument
return aiida_local_code_factory("simulate", "raspa")
26 changes: 15 additions & 11 deletions examples/simple_calculations/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,8 @@
CifData = DataFactory('cif') # pylint: disable=invalid-name


@click.command('cli')
@click.argument('codelabel')
@click.option('--submit', is_flag=True, help='Actually submit calculation')
def main(codelabel, submit):
def example_base(raspa_code, submit=True):
"""Prepare and submit simple RASPA calculation."""
try:
code = Code.get_from_string(codelabel)
except NotExistent:
print("The code '{}' does not exist".format(codelabel))
sys.exit(1)

# parameters
parameters = Dict(
Expand Down Expand Up @@ -64,7 +56,7 @@ def main(codelabel, submit):
framework = CifData(file=os.path.join(os.path.dirname(os.path.realpath(__file__)), 'files', 'TCC1RS.cif'))

# Contructing builder
builder = code.get_builder()
builder = raspa_code.get_builder()
builder.framework = {
"tcc1rs": framework,
}
Expand Down Expand Up @@ -96,7 +88,19 @@ def main(codelabel, submit):
print("-----")


@click.command('cli')
@click.argument('codelabel')
def cli(codelabel):
"""Click interface"""
try:
code = Code.get_from_string(codelabel)
except NotExistent:
print("The code '{}' does not exist".format(codelabel))
sys.exit(1)
example_base(code)


if __name__ == '__main__':
main() # pylint: disable=no-value-for-parameter
cli() # pylint: disable=no-value-for-parameter

# EOF
9 changes: 9 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[pytest]
python_files = test_*.py example_*.py
python_functions = example_* test_*
filterwarnings =
ignore::DeprecationWarning:aiida:
ignore::DeprecationWarning:plumpy:
ignore::DeprecationWarning:django:
ignore::DeprecationWarning:yaml:
ignore::DeprecationWarning:pymatgen:

0 comments on commit 90dd17e

Please sign in to comment.