Skip to content

Commit

Permalink
Merge pull request ECP-WarpX#4 from ModernElectron/pscherpelz/circlec…
Browse files Browse the repository at this point in the history
…i_setup

Enable CircleCI testing in mewarpx
  • Loading branch information
peterscherpelz committed Jun 28, 2021
2 parents dee7674 + 0b637b5 commit e38d3e8
Show file tree
Hide file tree
Showing 7 changed files with 163 additions and 1 deletion.
86 changes: 86 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Python CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-python/ for more details

version: 2.1

orbs:
codecov: codecov/codecov@1.2.3

jobs:

build_and_test_job:
docker:
# specify the version you desire here
# This is a CircleCI convenience image with CI & python packages
# pre-installed.
- image: cimg/python:3.9

working_directory: ~/WarpX

steps:
- checkout

# Download and cache dependencies
- restore_cache:
keys:
- v3-dependencies-{{ checksum "mewarpx/setup.py" }}-{{ checksum ".circleci/config.yml" }}

- run:
name: install dependencies
command: |
.github/workflows/dependencies/pyfull.sh
python3 -m venv venv
. venv/bin/activate
python3 -m pip install --upgrade pip setuptools wheel
- save_cache:
paths:
- ./venv
key: v3-dependencies-{{ checksum "mewarpx/setup.py" }}-{{ checksum ".circleci/config.yml" }}

- run:
name: build WarpX install mewarpx
command: |
echo 'activate venv; cd'
. venv/bin/activate
# WarpX + PyWarpX compile & install
export WarpX_MPI=ON
export WarpX_OPENPMD=ON
export WarpX_PSATD=ON
export WarpX_QED_TABLE_GEN=ON
export CC=$(which clang)
export CXX=$(which clang++)
python3 -m pip install -v .
# Install development mode of mewarpx
cd mewarpx
pip install -e .[complete]
# run tests!
- run:
name: run tests
command: |
. venv/bin/activate
cd mewarpx
mkdir test-reports
pytest --junitxml=test-reports/junit.xml --cov=mewarpx --cov-report=xml
- store_test_results:
path: mewarpx/test-reports

- store_artifacts:
path: mewarpx/test-reports
destination: test-reports

- codecov/upload

# https://circleci.com/docs/2.0/workflows/
workflows:
version: 2
build_and_test:
jobs:
- build_and_test_job
2 changes: 2 additions & 0 deletions mewarpx/.coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[run]
source=mewarpx
23 changes: 23 additions & 0 deletions mewarpx/changelog.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Version, Date, List of changes
0.1.0, In progress, "

**Physics changes**:

- Initial release

**Features**:

- Initial release

**API Changes**:

- Initial release

**Other changes**:

- Initial release

**Bugfixes**:

- Initial release
"
7 changes: 7 additions & 0 deletions mewarpx/mewarpx/util.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
"""
Utility functions for mewarpx.
"""
import inspect
import os

from pywarpx import geometry

# http://stackoverflow.com/questions/50499/in-python-how-do-i-get-the-path-and-name-of-the-file-t
mewarpx_dir = os.path.dirname(os.path.abspath(
inspect.getfile(inspect.currentframe())))


def init_libwarpx(ndim, rz):
"""_libwarpx requires the geometry be set before importing.
Expand Down
25 changes: 25 additions & 0 deletions mewarpx/pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[pytest]
# Trying new xunit2 format for junit test metadata
junit_family=xunit2
# Add command line options to force each test to run in a separate process.
# Note that this requires pytest-xdist! But tests will break if this is not
# used, because MEWarpX is not designed to reset gracefully between tests.
# Finally, note that conftest.py can dynamically change command line arguments,
# but this seems to break with pytest-xdist so cannot be used here.
addopts = --boxed -n2

# Warnings: In the past -Werror was used in addopts above. Recent changes to
# pytest cause harmless import warnings to make pytest fail on import. In order
# to filter these, we use filterwarnings instead. Hopefully this still works
# well with pytest-xdist; I'm pretty sure it will.
# The necessary warnings to filter will likely vary rapidly with the version
# of other packages.
# Note also that the 'message' field in these filters is a regular expression.
# Among other things, that means that parentheses need to be escaped.

# The numpy dtype/ufunc size changed come when scipy was compiled against a
# different version of numpy than used here, but it's harmless and common.
filterwarnings =
error
ignore:numpy.dtype size changed:RuntimeWarning
ignore:numpy.ufunc size changed:RuntimeWarning
2 changes: 1 addition & 1 deletion mewarpx/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
]

extras = {
# "tests": ["pytest", "pytest-cov", "pytest-xdist"],
"tests": ["pytest", "pytest-cov", "pytest-xdist"],
# "docs": ["sphinx", "mock", "sphinx_rtd_theme"],
# "aws": ["awscli", "boto3", "s3fs"]
}
Expand Down
19 changes: 19 additions & 0 deletions mewarpx/tests/test_package.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""Test basic package aspects"""
# Native python imports
from builtins import next
import csv
import os

# 3rd-party library imports

# Local imports
import mewarpx
from mewarpx import util


def test_version():
with open(os.path.join(util.mewarpx_dir, '../changelog.csv'), 'r') as f:
reader = csv.reader(f)
next(reader)
row = next(reader)
assert row[0] == mewarpx.__version__

0 comments on commit e38d3e8

Please sign in to comment.