Skip to content

Commit

Permalink
Add working CI (#16)
Browse files Browse the repository at this point in the history
* Add initial CI for python3

Co-authored-by: Mathew Cleveland <[email protected]>
  • Loading branch information
clevelam and Mathew Cleveland authored Mar 2, 2021
1 parent 5e924be commit 252ea9b
Show file tree
Hide file tree
Showing 9 changed files with 110 additions and 88 deletions.
21 changes: 10 additions & 11 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: Python package

on: [push]
on: [push, pull_request]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: [2.7, 3.5, 3.6, 3.7, 3.8]
python-version: [3.6, 3.7, 3.8]

steps:
- uses: actions/checkout@v2
Expand All @@ -19,14 +19,13 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
pip install --user pytest-cov numpy matplotlib scipy argparse
## - name: flake
## run: |
## # stop the build if there are Python syntax errors or undefined names
## flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
## # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
## flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
python -m pytest --cov-report term-missing -cov=opppy
9 changes: 5 additions & 4 deletions tests/my_test_opppy_dump_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ def build_data_dictionary(self, filename, dump_keys=None):
data[key] = array(str_vector_to_float_vector(line.strip('\n').split(' ')[1:]))

# build xy_verts for 2d mesh plotting example
xy_verts = []
for x, y in zip(data['x'], data['y']):
xy_verts.append([[x-0.5,y-0.5],[x+0.5,y-0.5],[x+0.5,y+0.5],[x-0.5,y+0.5]])
data['xy_verts'] = xy_verts
if 'x' in data and 'y' in data:
xy_verts = []
for x, y in zip(data['x'], data['y']):
xy_verts.append([[x-0.5,y-0.5],[x+0.5,y-0.5],[x+0.5,y+0.5],[x-0.5,y+0.5]])
data['xy_verts'] = xy_verts

return data

Expand Down
5 changes: 4 additions & 1 deletion tests/test_dict_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

sys.path.append('..')

import os
dir_path = os.path.dirname(os.path.realpath(__file__))+"/"

import unittest
from test import support
import shlex
Expand All @@ -34,7 +37,7 @@ def test_plot_dictionary(self):
data['version'] = __version__

# Append the thrid output file
output_files = ["output_example1.txt","output_example2.txt","output_example3.txt"]
output_files = [dir_path+"output_example1.txt",dir_path+"output_example2.txt",dir_path+"output_example3.txt"]
# Build initial pickle
append_output_dictionary(data, output_files, opppy_parser)

Expand Down
31 changes: 17 additions & 14 deletions tests/test_dump_ploter.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

sys.path.append('..')

import os
dir_path = os.path.dirname(os.path.realpath(__file__))+"/"

import unittest
from test import support

Expand All @@ -27,7 +30,7 @@ def test_1d_dump_ploter(self):
# initialize my test dump parser
dump_parser = my_test_opppy_dump_parser()

filename = "example_dump.txt"
filename = dir_path+"example_dump.txt"
# extract all data from the example dump file
data = dump_parser.build_data_dictionary(filename)

Expand All @@ -45,10 +48,10 @@ def test_1d_dump_ploter(self):
dump_1d_ploter.plot_1d(args, my_dumps, names)

# extract all data from the other example dump file
filename = "example_dump2.txt"
filename = dir_path+"example_dump2.txt"
names.append(filename)
my_dumps.append(dump_parser.build_data_dictionary(filename))
filename = "example_dump3.txt"
filename = dir_path+"example_dump3.txt"
names.append(filename)
my_dumps.append(dump_parser.build_data_dictionary(filename))

Expand All @@ -64,7 +67,7 @@ def test_2d_dump_ploter(self):
# initialize my test dump parser
dump_parser = my_test_opppy_dump_parser()

filename = "example_dump.txt"
filename = dir_path+"example_dump.txt"
# extract all data from the example dump file
data = dump_parser.build_data_dictionary(filename)

Expand Down Expand Up @@ -140,7 +143,7 @@ def test_3d_dump_ploter(self):
# initialize my test dump parser
dump_parser = my_test_opppy_dump_parser()

filename = "example_dump.txt"
filename = dir_path+"example_dump.txt"
# extract all data from the example dump file
data = dump_parser.build_data_dictionary(filename)

Expand All @@ -162,14 +165,14 @@ def test_point_series_plot(self):

# initialize my test dump parser
dump_parser = my_test_opppy_dump_parser()
filename = "example_dump.txt"
filename = dir_path+"example_dump.txt"
names = [filename]
# extract all data from the example dump file
data = [dump_parser.build_data_dictionary(filename)]
filename = "example_dump2.txt"
filename = dir_path+"example_dump2.txt"
names.append(filename)
data.append(dump_parser.build_data_dictionary(filename))
filename = "example_dump3.txt"
filename = dir_path+"example_dump3.txt"
names.append(filename)
data.append(dump_parser.build_data_dictionary(filename))

Expand Down Expand Up @@ -210,14 +213,14 @@ def test_line_series_plot(self):

# initialize my test dump parser
dump_parser = my_test_opppy_dump_parser()
filename = "example_dump.txt"
filename = dir_path+"example_dump.txt"
names = [filename]
# extract all data from the example dump file
data = [dump_parser.build_data_dictionary(filename)]
filename = "example_dump2.txt"
filename = dir_path+"example_dump2.txt"
names.append(filename)
data.append(dump_parser.build_data_dictionary(filename))
filename = "example_dump3.txt"
filename = dir_path+"example_dump3.txt"
names.append(filename)
data.append(dump_parser.build_data_dictionary(filename))

Expand All @@ -243,14 +246,14 @@ def test_contour_series_plot(self):

# initialize my test dump parser
dump_parser = my_test_opppy_dump_parser()
filename = "example_dump.txt"
filename = dir_path+"example_dump.txt"
names = [filename]
# extract all data from the example dump file
data = [dump_parser.build_data_dictionary(filename)]
filename = "example_dump2.txt"
filename = dir_path+"example_dump2.txt"
names.append(filename)
data.append(dump_parser.build_data_dictionary(filename))
filename = "example_dump3.txt"
filename = dir_path+"example_dump3.txt"
names.append(filename)
data.append(dump_parser.build_data_dictionary(filename))

Expand Down
35 changes: 19 additions & 16 deletions tests/test_dump_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

sys.path.append('..')

import os
dir_path = os.path.dirname(os.path.realpath(__file__))+"/"

from opppy.dump_utils import *
import unittest
from test import support
Expand All @@ -25,7 +28,7 @@ def test_dump_parser(self):
# initialize my test dump parser
dump_parser = my_test_opppy_dump_parser()

filename = "example_dump.txt"
filename = dir_path + "example_dump.txt"
# extract all data from the example dump file
data = dump_parser.build_data_dictionary(filename)

Expand All @@ -45,7 +48,7 @@ def test_point_value(self):
# initialize my test dump parser
dump_parser = my_test_opppy_dump_parser()

filename = "example_dump.txt"
filename = dir_path + "example_dump.txt"
# extract all data from the example dump file
data = dump_parser.build_data_dictionary(filename)

Expand Down Expand Up @@ -73,12 +76,12 @@ def test_point_series(self):
dump_parser = my_test_opppy_dump_parser()

data = []
filename = "example_dump.txt"
filename = dir_path + "example_dump.txt"
# extract all data from the example dump file
data.append(dump_parser.build_data_dictionary(filename))
filename = "example_dump2.txt"
filename = dir_path + "example_dump2.txt"
data.append(dump_parser.build_data_dictionary(filename))
filename = "example_dump3.txt"
filename = dir_path + "example_dump3.txt"
data.append(dump_parser.build_data_dictionary(filename))

# extract a 1D data value
Expand All @@ -100,7 +103,7 @@ def test_grid_data(self):
# initialize my test dump parser
dump_parser = my_test_opppy_dump_parser()

filename = "example_dump.txt"
filename = dir_path + "example_dump.txt"
# extract all data from the example dump file
data = dump_parser.build_data_dictionary(filename)

Expand Down Expand Up @@ -134,12 +137,12 @@ def test_2D_series(self):
dump_parser = my_test_opppy_dump_parser()

data = []
filename = "example_dump.txt"
filename = dir_path + "example_dump.txt"
# extract all data from the example dump file
data.append(dump_parser.build_data_dictionary(filename))
filename = "example_dump2.txt"
filename = dir_path + "example_dump2.txt"
data.append(dump_parser.build_data_dictionary(filename))
filename = "example_dump3.txt"
filename = dir_path + "example_dump3.txt"
data.append(dump_parser.build_data_dictionary(filename))

# extract a 1D data value
Expand All @@ -158,12 +161,12 @@ def test_2D_slice_series(self):
dump_parser = my_test_opppy_dump_parser()

data = []
filename = "example_dump.txt"
filename = dir_path + "example_dump.txt"
# extract all data from the example dump file
data.append(dump_parser.build_data_dictionary(filename))
filename = "example_dump2.txt"
filename = dir_path + "example_dump2.txt"
data.append(dump_parser.build_data_dictionary(filename))
filename = "example_dump3.txt"
filename = dir_path + "example_dump3.txt"
data.append(dump_parser.build_data_dictionary(filename))

# extract 2d plane data value
Expand All @@ -181,7 +184,7 @@ def test_data_2_line(self):
# initialize my test dump parser
dump_parser = my_test_opppy_dump_parser()

filename = "example_dump.txt"
filename = dir_path + "example_dump.txt"
# extract all data from the example dump file
data = dump_parser.build_data_dictionary(filename)

Expand All @@ -208,12 +211,12 @@ def test_line_series(self):
dump_parser = my_test_opppy_dump_parser()

data = []
filename = "example_dump.txt"
filename = dir_path + "example_dump.txt"
# extract all data from the example dump file
data.append(dump_parser.build_data_dictionary(filename))
filename = "example_dump2.txt"
filename = dir_path + "example_dump2.txt"
data.append(dump_parser.build_data_dictionary(filename))
filename = "example_dump3.txt"
filename = dir_path + "example_dump3.txt"
data.append(dump_parser.build_data_dictionary(filename))

# extract a 1D data value
Expand Down
Loading

0 comments on commit 252ea9b

Please sign in to comment.