Skip to content

Commit

Permalink
This adds the initial pipeline (#1)
Browse files Browse the repository at this point in the history
* add initial pipeline

This adds the initial pipeline configs and sets up github.

* add github templates

* add test example code

* try doing things python 2.7 compatible

* need to run lint on both pythons

* try getting travis to deal with stages right

* need to make it an array
  • Loading branch information
dmlb2000 committed Jul 21, 2018
1 parent 42a8c02 commit 0e0357d
Show file tree
Hide file tree
Showing 14 changed files with 229 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
# 79 chars is too strict and we don't have 80-char terminals nowadays,
# 160 chars is too much since it doesn't let us use split view efficiently:
max-line-length = 120
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
### Pacifica REPLACE_ME version
[Version of the pacifica software where you are encountering the issue]

### Pacifica Core Software versions
[Versions of the pacifica core software components related to this issue]

### Platform Details
[Operating system distribution and release version. Cloud provider if running in the cloud]

### Scenario:
[What you are trying to achieve and you can't?]

### Steps to Reproduce:
[If you are filing an issue what are the things we need to do in order to reproduce your problem? How are you using this software or any resources it includes?]

### Expected Result:
[What are you expecting to happen as the consequence of above reproduction steps?]

### Actual Result:
[What actually happens after the reproduction steps? Include the error output or a link to a gist if possible.]
13 changes: 13 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
### Description

[Describe what this change achieves]

### Issues Resolved

[List any existing issues this PR resolves]

### Check List

- [ ] All tests pass. See <https://github.com/pacifica/pacifica-docs/blob/master/development/TESTING.md>
- [ ] New functionality includes testing.
- [ ] New functionality has been documented in the README if applicable
53 changes: 53 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
repos:
- repo: git://github.com/pre-commit/pre-commit-hooks
rev: v1.2.3
hooks:
- id: autopep8-wrapper
- id: fix-encoding-pragma
- id: trailing-whitespace
- id: flake8
args: [--max-line-length=120]
- id: check-merge-conflict
- id: double-quote-string-fixer
- id: end-of-file-fixer
- id: name-tests-test
- id: debug-statements
- id: check-added-large-files
- id: check-ast
- id: check-byte-order-marker
- id: check-case-conflict
- id: check-docstring-first
- id: check-executables-have-shebangs
types: [python]
- id: check-json
- id: check-vcs-permalinks
- id: mixed-line-ending
- id: name-tests-test
- id: pretty-format-json
args:
- --autofix
- --top-keys=_id
- id: sort-simple-yaml
files: '.yaml$'
- id: check-symlinks
- id: check-yaml
- id: detect-private-key
- id: requirements-txt-fixer
- id: trailing-whitespace
- repo: local
hooks:
- id: pep257
name: pep257
entry: python -m pep257
language: system
types: [python]
- id: pylint
name: pylint
entry: python -m pylint --rcfile=pylintrc
language: system
types: [python]
- repo: git://github.com/Lucas-C/pre-commit-hooks
rev: v1.1.5
hooks:
- id: remove-tabs
- id: remove-crlf
24 changes: 24 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
language: python
python:
- 2.7
- 3.6

stages:
- lint
- test

script:
- coverage run --include='pacifica/*' -m pytest -v
- coverage report -m --fail-under 100
- if [[ $CODECLIMATE_REPO_TOKEN ]] ; then codeclimate-test-reporter; fi

jobs:
include:
- stage: lint
python: 3.6
script: pre-commit run -a
- python: 2.7
script: pre-commit run -a

install:
- pip install -r requirements-dev.txt
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
# template-repository
Pacifica service template for building code in the pacifica way.
# Pacifica Template Repository
[![Build Status](https://travis-ci.org/pacifica/template-repository.svg?branch=master)](https://travis-ci.org/pacifica/template-repository)
[![Build status](https://ci.appveyor.com/api/projects/status/eg2r1y37yvxi0b5p?svg=true)](https://ci.appveyor.com/project/dmlb2000/template-repository)
[![Test Coverage](https://api.codeclimate.com/v1/badges/d6149dbe182a3c761089/test_coverage)](https://codeclimate.com/github/pacifica/template-repository/test_coverage)
[![Maintainability](https://api.codeclimate.com/v1/badges/f2dba248b1a7966e5a49/maintainability)](https://codeclimate.com/github/pacifica/template-repository/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/f2dba248b1a7966e5a49/test_coverage)](https://codeclimate.com/github/pacifica/template-repository/test_coverage)

This repository is to serve as a template for building new
services the Pacifica way. This repository has pipelines
for travis and appveyor to build your code and pre-commit
and pytest to fix your code.
24 changes: 24 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: 0.1.{build}
pull_requests:
do_not_increment_build_number: true

environment:
matrix:
- PYTHON: C:\Python27-x64
- PYTHON: C:\Python36-x64

install:
- ps: >
& "$env:PYTHON\python.exe" -m virtualenv C:\pacifica;
C:\pacifica\Scripts\activate.ps1;
python -m pip install --upgrade pip setuptools wheel;
python -m pip install -r requirements-dev.txt
build: off

test_script:
- ps: >
mkdir C:\tmp; C:\pacifica\Scripts\activate.ps1;
pre-commit run -a;
coverage run --include='pacifica/*' -m pytest -v;
coverage report -m --fail-under=100;
4 changes: 4 additions & 0 deletions pacifica/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""Pacifica Namespace."""
__import__('pkg_resources').declare_namespace(__name__)
17 changes: 17 additions & 0 deletions pacifica/example/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""Example Pacifica Module."""


class Example(object):
"""This is an example class in the example module."""

@staticmethod
def add(thing1, thing2):
"""Add thing one and thing two together."""
return thing1 + thing2

@staticmethod
def mul(thing1, thing2):
"""Multiply thing one and thing two together."""
return thing1 * thing2
23 changes: 23 additions & 0 deletions pacifica/example/test/example_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""Test the example module."""
from unittest import TestCase
from pacifica.example import Example


class TestExample(TestCase):
"""Test the example class."""

def test_add(self):
"""Test the add method in example class."""
self.assertEqual(Example().add('123', 'abc'),
'123abc', 'sum of strings should work')
self.assertEqual(Example().add(123, 456), 579,
'sum of integers should work')

def test_mul(self):
"""Test the mul method in example class."""
self.assertEqual(Example().mul('a', 4), 'aaaa',
'multiply of string and number should work')
self.assertEqual(Example().mul(2, 3), 6,
'multiply of two integers should work')
3 changes: 3 additions & 0 deletions pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[SIMILARITIES]
ignore-imports=yes
max-line-length=120
8 changes: 8 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
codeclimate-test-reporter
coverage>4.0,<4.4
pep257
pre-commit
pre-commit
pylint<2.0
pytest
setuptools
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
setuptools
six
23 changes: 23 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""Setup and install the pacifica service."""
try: # pip version 9
from pip.req import parse_requirements
except ImportError:
from pip._internal.req import parse_requirements
from setuptools import setup, find_packages

# parse_requirements() returns generator of pip.req.InstallRequirement objects
INSTALL_REQS = parse_requirements('requirements.txt', session='hack')

setup(
name='pacifica-service',
use_scm_version=True,
setup_requires=['setuptools_scm'],
description='Pacifica Configuration Parser',
author='David Brown',
author_email='david.brown@pnnl.gov',
packages=find_packages(),
namespace_packages=['pacifica'],
install_requires=[str(ir.req) for ir in INSTALL_REQS]
)

0 comments on commit 0e0357d

Please sign in to comment.