Skip to content

Commit

Permalink
feat: Add project skeleton layout (#2)
Browse files Browse the repository at this point in the history
* Add a project skeleton layout
* Add basic CI framework
* Add developer configuration files
  • Loading branch information
matthewfeickert authored Mar 4, 2020
1 parent 4b708da commit a75fe22
Show file tree
Hide file tree
Showing 19 changed files with 324 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[bumpversion]
current_version = 0.0.1
commit = True
tag = True

[bumpversion:file:setup.py]

[bumpversion:file:src/pyhf-validation/version.py]
16 changes: 16 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[run]
branch = True
source = src/hfval

[report]
exclude_lines =
if self.debug:
pragma: no cover
raise NotImplementedError
if __name__ == .__main__.:
ignore_errors = True
omit =
binder/*
docker/*
tests/*
validation/*
12 changes: 12 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Ignore everything
**

# Except the following
!.git/**
!docker/**
!src/**
!LICENSE
!pyproject.toml
!README.md
!setup.cfg
!setup.py
65 changes: 65 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: CI/CD

on:
push:
pull_request:
# Run daily at 0:01 UTC
schedule:
- cron: '1 0 * * *'

jobs:
test:

runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest]
python-version: [3.6, 3.7, 3.8]

steps:
- uses: actions/checkout@master
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install -q --no-cache-dir -e .[complete]
python -m pip list
- name: Lint with Pyflakes
if: matrix.python-version == 3.7 && matrix.os == 'ubuntu-latest'
run: |
pyflakes src
- name: Lint with Black
if: matrix.python-version == 3.7 && matrix.os == 'ubuntu-latest'
run: |
black --check --diff --verbose .
- name: Check MANIFEST
if: matrix.python-version == 3.7 && matrix.os == 'ubuntu-latest'
run: |
check-manifest
- name: Test with pytest
run: |
python -m pytest -r sx
- name: Report coverage with Codecov
if: github.event_name == 'push' && matrix.python-version == 3.7 && matrix.os == 'ubuntu-latest'
uses: codecov/codecov-action@master
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
flags: unittests

docker:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1.2.0
- name: Build Docker image
run: |
docker build . \
--file docker/Dockerfile \
--tag pyhf-validation:$GITHUB_SHA \
--compress
docker images
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
repos:
- repo: https://github.com/psf/black
rev: stable
hooks:
- id: black
language_version: python3.7
46 changes: 46 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at matthew.feickert@cern.ch. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
5 changes: 5 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
graft src

include LICENSE

global-exclude __pycache__ *.py[cod]
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
# pyhf-validation
# pyhf Validation

Validation utilities for HistFactory workspaces

[![GitHub Project](https://img.shields.io/badge/GitHub--blue?style=social&logo=GitHub)](https://github.com/pyhf/pyhf-validation)
[![GitHub Actions Status: CI](https://github.com/pyhf/pyhf-validation/workflows/CI/CD/badge.svg)](https://github.com/pyhf/pyhf-validation/actions?query=workflow%3ACI%2FCD+branch%3Amaster)
[![Code Coverage](https://codecov.io/gh/pyhf/pyhf-validation/graph/badge.svg?branch=master)](https://codecov.io/gh/pyhf/pyhf-validation?branch=master)

## Installation

To install `pyhf-validation` from GitHub (PyPI coming soon) run
```bash
python -m pip install --ignore-installed --upgrade "git+https://github.com/pyhf/pyhf-validation.git#egg=hfval"
```

## Authors

Please check the [contribution statistics for a list of contributors](https://github.com/pyhf/pyhf-validation/graphs/contributors)
5 changes: 5 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
coverage:
status:
project:
default:
threshold: 0.2%
18 changes: 18 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM python:3.7-slim as base

FROM base as builder
COPY . /code
RUN cd /code && \
apt-get -qq -y update && \
apt-get -qq -y install \
git && \
apt-get -y autoclean && \
apt-get -y autoremove && \
rm -rf /var/lib/apt-get/lists/* && \
python -m pip install --upgrade --no-cache-dir pip setuptools wheel && \
python -m pip install --no-cache-dir . && \
python -m pip list

FROM base
COPY --from=builder /usr/local /usr/local
ENTRYPOINT ["/usr/local/bin/pyhf-validation"]
28 changes: 28 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[build-system]
# Minimum requirements for the build system to execute.
requires = ["wheel", "setuptools>=30.3.0", "attrs>=17.1", "setuptools_scm"]
build-backend = "setuptools.build_meta"

[tool.black]
line-length = 88
include = '\.pyi?$'
exclude = '''
/(
\.git
| .eggs
| build
)/
'''

[tool.check-manifest]
ignore = [
'tests*',
'docker*',
'binder*',
'.*',
'pyproject.toml',
'pytest.ini',
'codecov.yml',
'CODE_OF_CONDUCT.md',
'CONTRIBUTING.md',
]
2 changes: 2 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[pytest]
addopts = --ignore=setup.py --ignore=binder/ --cov=hfval --cov-report=term-missing --cov-config=.coveragerc --cov-report xml --doctest-modules --doctest-glob='*.rst'
5 changes: 5 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[bdist_wheel]
universal = 1

[metadata]
license_file = LICENSE
49 changes: 49 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
from setuptools import setup, find_packages
from os import path

this_directory = path.abspath(path.dirname(__file__))
with open(path.join(this_directory, "README.md"), encoding="utf-8") as readme_md:
long_description = readme_md.read()

extras_require = {
"develop": [
"check-manifest",
"pytest~=5.2",
"pytest-cov~=2.8",
"pytest-console-scripts~=0.2",
"bumpversion~=0.5",
"pyflakes",
"pre-commit",
"black",
"twine",
],
}
extras_require["complete"] = sorted(set(sum(extras_require.values(), [])))

setup(
name="hfval",
version="0.0.1",
description="Validation utilities for HistFactory workspaces",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/pyhf/pyhf-validation",
author="Lukas Heinrich, Matthew Feickert, Giordon Stark",
author_email="lukas.heinrich@cern.ch, matthew.feickert@cern.ch, gstark@cern.ch",
license="Apache",
keywords="pyhf validation",
classifiers=[
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
],
package_dir={"": "src"},
packages=find_packages(where="src"),
include_package_data=True,
install_requires=["pyhf[xmlio]>0.4.0", "click>=6.0"],
python_requires=">=3.6",
extras_require=extras_require,
entry_points={"console_scripts": ["pyhf-validation=hfval.commandline:hfval"]},
dependency_links=[],
use_scm_version=lambda: {"local_scheme": lambda version: ""},
)
3 changes: 3 additions & 0 deletions src/hfval/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .version import __version__

__all__ = ["__version__"]
13 changes: 13 additions & 0 deletions src/hfval/commandline.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import logging
import click

from .version import __version__

logging.basicConfig()
log = logging.getLogger(__name__)


@click.group(context_settings=dict(help_option_names=["-h", "--help"]))
@click.version_option(version=__version__)
def hfval():
pass
5 changes: 5 additions & 0 deletions src/hfval/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""Define pyhf-validation version information."""

# Use semantic versioning (https://semver.org/)
# The version number is controlled through bumpversion.cfg
__version__ = "0.0.1"
16 changes: 16 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import shlex
import hfval
import time


def test_version(script_runner):
command = "pyhf-validation --version"
start = time.time()
ret = script_runner.run(*shlex.split(command))
end = time.time()
elapsed = end - start
assert ret.success
assert hfval.__version__ in ret.stdout
assert ret.stderr == ""
# make sure it took less than a second
assert elapsed < 1.0
5 changes: 5 additions & 0 deletions tests/test_import.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import hfval


def test_import():
assert hfval

0 comments on commit a75fe22

Please sign in to comment.