Skip to content

Commit

Permalink
First set of tools (#1)
Browse files Browse the repository at this point in the history
* First set of tools
  • Loading branch information
nh13 authored Jun 4, 2020
1 parent 3c731f0 commit 60eabb8
Show file tree
Hide file tree
Showing 25 changed files with 2,230 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Python package

on: [push]
env:
POETRY_VERSION: 1.0

jobs:
testing:
runs-on: ubuntu-latest
strategy:
matrix:
PYTHON_VERSION: [3.8]
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 poetry
run: |
python -m pip install --upgrade pip
pip install poetry==${{env.POETRY_VERSION}}
- name: Install deps
run: |
poetry install
- name: Run pytest
run: |
poetry run python -m pytest --cov=pyfgaws --cov-branch
- name: Style checking
run: |
poetry run black --line-length 99 --check pyfgaws
- name: Run lint
run: |
poetry run flake8 --config=ci/flake8.cfg pyfgaws
- name: Run mypy
run: |
poetry run mypy -p pyfgaws --config=ci/mypy.ini
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# PyCharm
.idea

# Python compiled & optimized files
*.pyc
*.pyo

# MyPy Cache directory
.mypy_cache

# for develop installs
*.egg-info

# venv set up
.venv
dist/
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License

Copyright (c) 2020 Fulcrum Genomics LLC

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
51 changes: 51 additions & 0 deletions ci/check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash

function banner() {
echo
echo "================================================================================"
echo $*
echo "================================================================================"
echo
}

#####################################################################
# Takes two parameters, a "name" and a "command".
# Runs the command and prints out whether it succeeded or failed, and
# also tracks a list of failed steps in $failures.
#####################################################################
function run() {
local name=$1
local cmd=$2

banner "Running $name [$cmd]"
set +e
$cmd
exit_code=$?
set -e

if [[ $exit_code == 0 ]]; then
echo Passed $name: "[$cmd]"
else
echo Failed $name: "[$cmd]"
if [ -z "$failures" ]; then
failures="$failures $name"
else
failures="$failures, $name"
fi
fi
}

parent=$(cd $(dirname $0) && pwd -P)

banner "Executing in conda environment ${CONDA_DEFAULT_ENV} in directory ${root}"
run "Unit Tests" "python -m pytest -vv -r sx pyfgaws"
run "Style Checking" "black --line-length 99 --check pyfgaws"
run "Linting" "flake8 --config=$parent/flake8.cfg pyfgaws"
run "Type Checking" "mypy -p pyfgaws --config $parent/mypy.ini"

if [ -z "$failures" ]; then
banner "Checks Passed"
else
banner "Checks Failed with failures in: $failures"
exit 1
fi
6 changes: 6 additions & 0 deletions ci/flake8.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# flake8 config file

[flake8]
max_line_length = 100
show-source = true
ignore = E701 W504 W503
6 changes: 6 additions & 0 deletions ci/mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[mypy]
strict_optional = False
ignore_missing_imports = True
disallow_untyped_decorators = False
follow_imports = "silent"
disallow_untyped_defs = True
3 changes: 3 additions & 0 deletions conda-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Setup python version and poetry
python=3.8.2
poetry=1.0.5
Loading

0 comments on commit 60eabb8

Please sign in to comment.