Skip to content

Commit

Permalink
switch to aiida-testing
Browse files Browse the repository at this point in the history
run yapf for all and remove py2 compatibility

fix tests but qeq still failing

fix examples

put back output parsing
  • Loading branch information
danieleongari authored and ltalirz committed Dec 10, 2020
1 parent 9d10f69 commit 3e1cc19
Show file tree
Hide file tree
Showing 41 changed files with 455 additions and 665 deletions.
33 changes: 33 additions & 0 deletions .github/check_version.py
@@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
"""Check that version numbers match.
Check version number in setup.json and aiida_qeq/__init__.py and make sure
they match.
"""
import os
import json
import sys

THIS_PATH = os.path.split(os.path.realpath(__file__))[0]

# Get content of setup.json
SETUP_FNAME = 'setup.json'
SETUP_PATH = os.path.join(THIS_PATH, os.pardir, SETUP_FNAME)
with open(SETUP_PATH) as f:
SETUP_CONTENT = json.load(f)

# Get version from python package
sys.path.insert(0, os.path.join(THIS_PATH, os.pardir))
import aiida_qeq # pylint: disable=wrong-import-position
VERSION = aiida_qeq.__version__

if VERSION != SETUP_CONTENT['version']:
print('version number mismatch detected:')
print("version number in '{}': {}".format(SETUP_FNAME, SETUP_CONTENT['version']))
print("version number in '{}/__init__.py': {}".format('aiida_qeq', VERSION))
sys.exit(1)

# Overwrite version in setup.json
#SETUP_CONTENT['version'] = VERSION
#with open(SETUP_PATH, 'w') as f:
# json.dump(SETUP_CONTENT, f, indent=4, sort_keys=True)
85 changes: 85 additions & 0 deletions .github/workflows/ci.yml
@@ -0,0 +1,85 @@
name: ci

on: [push, pull_request]

jobs:

tests:
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
matrix:
python-version: [3.7]
backend: ['django']
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}

- name: Install system dependencies
run: |
wget -O - "https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc" | sudo apt-key add -
echo 'deb https://dl.bintray.com/rabbitmq-erlang/debian bionic erlang' | sudo tee -a /etc/apt/sources.list.d/bintray.rabbitmq.list
echo 'deb https://dl.bintray.com/rabbitmq/debian bionic main' | sudo tee -a /etc/apt/sources.list.d/bintray.rabbitmq.list
sudo rm -f /etc/apt/sources.list.d/dotnetdev.list /etc/apt/sources.list.d/microsoft-prod.list
sudo apt update
sudo apt install postgresql-10 rabbitmq-server graphviz
sudo systemctl status rabbitmq-server.service
- name: Install python dependencies
run: |
pip install --upgrade pip
pip install -e .[testing,cp2k]
reentry scan -r aiida
- name: Run test suite
env:
AIIDA_TEST_BACKEND: ${{ matrix.backend }}
PYTEST_ADDOPTS: "--cov-report xml --cov-append"
run: py.test

- name: Upload coverage report
if: github.repository == 'lsmo-epfl/aiida-qeq'
uses: codecov/codecov-action@v1
with:
name: aiida-ddec
file: ./coverage.xml
fail_ci_if_error: true

# docs:
# runs-on: ubuntu-latest
# timeout-minutes: 15
# steps:
# - uses: actions/checkout@v1
# - name: Set up Python 3.7
# uses: actions/setup-python@v1
# with:
# python-version: 3.7
# - name: Install python dependencies
# run: |
# pip install --upgrade pip
# pip install -e .[docs]
# reentry scan -r aiida
# - name: Build docs
# run: cd docs && make

pre-commit:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Install python dependencies
run: |
pip install --upgrade pip
pip install -e .[pre-commit,testing]
reentry scan -r aiida
- name: Run pre-commit
run: |
pre-commit install
pre-commit run --all-files || ( git status --short ; git diff ; exit 1 )
40 changes: 40 additions & 0 deletions .github/workflows/publish-on-pypi.yml
@@ -0,0 +1,40 @@
name: Publish on PyPI

on:
push:
tags:
# After vMajor.Minor.Patch _anything_ is allowed (without "/") !
- v[0-9]+.[0-9]+.[0-9]+*

jobs:
publish:
runs-on: ubuntu-latest
if: github.repository == 'lsmo-epfl/aiida-qeq' && startsWith(github.ref, 'refs/tags/v')

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7

- name: Upgrade setuptools and install package
run: |
python -m pip install --upgrade pip setuptools
python -m pip install -e .
- name: Assert package version
env:
TAG_VERSION: ${{ github.ref }}
run: python ./.github/check_version.py

- name: Build source distribution
run: python ./setup.py sdist

- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.pypi_token }}
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -11,3 +11,4 @@ dist/
build/
.vscode
.pytest_cache/
pip-wheel-metadata/
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Expand Up @@ -51,3 +51,9 @@
entry: pylint
types: [python]
language: system

- id: version-number
name: Check version numbers
entry: python ./.github/check_version.py
language: system
files: '^(setup.json)|(aiida_qeq/__init__.py)'
36 changes: 0 additions & 36 deletions .travis-data/check_version.py

This file was deleted.

7 changes: 0 additions & 7 deletions .travis-data/install_aiida_github.sh

This file was deleted.

90 changes: 0 additions & 90 deletions .travis.yml

This file was deleted.

17 changes: 13 additions & 4 deletions README.md
Expand Up @@ -95,11 +95,20 @@ verdi process list -a # check status of calculation
## Development

```shell
git clone https://github.com/ltalirz/aiida-qeq .
git clone https://github.com/lsmo-epfl/aiida-qeq
cd aiida-qeq
pip install -e .[pre-commit,testing]
pre-commit install # enable pre-commit hooks
pytest # run unit tests
pip install -e .['pre-commit','testing']
pytest
```

If you are changing the inputs of existing tests or need to regenerate test data, place an `.aiida-testing-config.yml`
file in your repository that points to the required simulation codes:
```yaml
---
mock_code:
# code-label: absolute path
egulp-fc4d7b7: /path/to/cp2k.sopt
eqeq-6490320: /path/to/Chargemol_09_02_2017_linux_serial
```

## License
Expand Down
3 changes: 2 additions & 1 deletion aiida_qeq/__init__.py
@@ -1,7 +1,8 @@
# -*- coding: utf-8 -*-
"""
aiida_qeq
AiiDA plugin for computing electronic charges on atoms using equilibration-type models (QEq, EQEq, ...).
"""

__version__ = "1.0.0a1"
__version__ = '1.0.0a1'
2 changes: 1 addition & 1 deletion aiida_qeq/calculations/__init__.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
"""
Calculations provided by aiida_qeq.
Register calculations via the "aiida.calculations" entry point in setup.json.
"""
from __future__ import absolute_import

0 comments on commit 3e1cc19

Please sign in to comment.