-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from AgPipeline/develop
Merging Develop to main branch - no review
- Loading branch information
Showing
4 changed files
with
159 additions
and
76 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
name: Enforcing testing checks | ||
on: | ||
push: | ||
branches: | ||
- master | ||
- develop | ||
pull_request: | ||
branches: | ||
- master | ||
- develop | ||
tags: | ||
- v* | ||
workflow_dispatch: | ||
|
||
jobs: | ||
update_python: | ||
runs-on: ubuntu-latest | ||
name: Running test checks | ||
strategy: | ||
matrix: | ||
app: [pylint, pytest] | ||
include: | ||
- app: pylint | ||
pip_installs: pylint pytest | ||
test_command: cat action_test_files.txt | xargs python3 -m pylint --rcfile ./pylint.rc | ||
- app: pytest | ||
pip_installs: pytest pytest-cov | ||
test_command: python3 -m pytest --cov=. -rpP --cov-report=xml > coverage.txt | ||
artifacts: coverage.txt | ||
steps: | ||
- name: Current python version | ||
run: python3 --version || echo python3 not installed | ||
- name: Install Python 3.7 | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.7' | ||
- name: Updated python version | ||
run: python3 --version | ||
- name: PYTHONPATH environment variable | ||
run: echo "PYTHONPATH is ${PYTHONPATH}" | ||
- name: Update pip | ||
run: python3 -m pip install --upgrade --no-cache-dir pip | ||
- name: Fetch/update setuptools | ||
run: python3 -m pip install --upgrade --no-cache-dir setuptools | ||
- name: Install python-apt | ||
run: sudo apt-get install -y python-apt | ||
- name: HACK to fix apt-get update problem w/ different python versions | ||
run: 'cd /usr/lib/python3/dist-packages && sudo cp apt_pkg.cpython-36m-x86_64-linux-gnu.so apt_pkg.so' | ||
- name: Update apt-get | ||
run: sudo apt-get update | ||
- name: Fetch/update testing pip installations | ||
run: python3 -m pip install --upgrade --no-cache-dir ${{ matrix.pip_installs }} | ||
- name: Fetch source code | ||
uses: actions/checkout@v2 | ||
- name: Finding files to process | ||
run: find . -type f -name "*.py" > action_test_files.txt | ||
- name: Install system requirements | ||
shell: bash | ||
run: 'sudo apt-get install -y python3-gdal gdal-bin libgdal-dev gcc g++ python3.7-dev' | ||
- name: Install Python numpy | ||
shell: bash | ||
run: 'python3 -m pip install --upgrade --no-cache-dir numpy wheel' | ||
- name: Install Python pygdal | ||
shell: bash | ||
run: 'python3 -m pip install --no-cache-dir pygdal==2.2.3.5' | ||
- name: Install system requirements from source | ||
shell: bash | ||
run: '[ -s "packages.txt" ] && (cat packages.txt | sudo xargs apt-get install -y --no-install-recommends) || (echo "No additional packages to install")' | ||
- name: Install Python requirements from source | ||
shell: bash | ||
run: '[ -s "requirements.txt" ] && (python3 -m pip install --no-cache-dir -r requirements.txt) || (echo "No Python requirements to install")' | ||
- name: Run action pylint script | ||
shell: bash | ||
run: '[ -s ".github/workflows/action_pylint.sh" ] && (chmod +x ".github/workflows/action_pylint.sh" && ./.github/workflows/action_pylint.sh) || (echo "No action shell script found to run")' | ||
- name: Fetching pylint.rc file | ||
run: wget https://raw.githubusercontent.com/AgPipeline/Organization-info/master/pylint.rc | ||
if: ${{ matrix.name }} == "pylint" | ||
- name: Set execution permission for testing | ||
run: chmod +x transformer.py | ||
- name: Listing | ||
run: ls -la | ||
- name: Files to be tested | ||
run: cat action_test_files.txt | ||
- name: Running test | ||
run: ${{ matrix.test_command }} | ||
- name: Upload testing artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: testing_artifacts | ||
path: ${{ matrix.artifacts }} | ||
if: ${{ matrix.artifacts }} | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v1 | ||
if: ${{ matrix.app == 'pytest' }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/usr/bin/env python3 | ||
"""Tests plotclip.py | ||
""" | ||
import argparse | ||
import os | ||
import re | ||
from subprocess import getstatusoutput | ||
|
||
from agpypeline.environment import Environment | ||
|
||
from configuration import ConfigurationInfo | ||
|
||
# The name of the source file to test and it's path | ||
SOURCE_FILE = 'transformer.py' | ||
SOURCE_PATH = os.path.abspath(os.path.join('.', SOURCE_FILE)) | ||
|
||
# Path relative to the current folder where the testing data files are | ||
TESTING_JSON_FILE_PATH = './test_data' | ||
|
||
|
||
def test_exists(): | ||
"""Asserts that the source file is available""" | ||
assert os.path.isfile(SOURCE_PATH) | ||
|
||
|
||
def test_usage(): | ||
"""Program prints a "usage" statement when requested""" | ||
for flag in ['-h', '--help']: | ||
ret_val, out = getstatusoutput(f'{SOURCE_PATH} {flag}') | ||
assert re.match('usage', out, re.IGNORECASE) | ||
assert ret_val == 0 | ||
|
||
|
||
def test_add_parameters(): | ||
"""Checks that the add_parameters function is callable without error""" | ||
# pylint: disable=import-outside-toplevel | ||
from transformer import TemplateTransformer as tt | ||
|
||
new_tt = tt() | ||
arg_parser = argparse.ArgumentParser() | ||
new_tt.add_parameters(arg_parser) | ||
|
||
|
||
def test_check_continue(): | ||
"""Checks that the check_continue function is callable without error""" | ||
# pylint: disable=import-outside-toplevel | ||
from transformer import TemplateTransformer as tt | ||
|
||
new_tt = tt() | ||
ret_val = new_tt.check_continue(Environment(ConfigurationInfo()), {}, {}, []) | ||
|
||
assert ret_val == 0 | ||
|
||
|
||
def test_perform_process(): | ||
"""Checks that the perform_process function is callable without error""" | ||
# pylint: disable=import-outside-toplevel | ||
from transformer import TemplateTransformer as tt | ||
|
||
new_tt = tt() | ||
ret_val = new_tt.perform_process(Environment(ConfigurationInfo()), {}, {}, []) | ||
|
||
assert 'code' in ret_val | ||
assert ret_val['code'] == 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#!/usr/bin/env python3 | ||
"""My nifty transformer | ||
""" | ||
|
||
|