Skip to content

Commit

Permalink
Merge pull request #62 from USDA-ARS-NWRC/gh_actions
Browse files Browse the repository at this point in the history
Github actions
  • Loading branch information
Scott Havens committed May 5, 2021
2 parents de0a360 + acec1a4 commit 283c4cb
Show file tree
Hide file tree
Showing 20 changed files with 443 additions and 339 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/new_pypi_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Release to Pypi

# Run on a published release and push to Pypi
on:
release:
types: [published]

jobs:
build_dist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions/setup-python@v2
name: Install Python
with:
python-version: "3.8"

- name: Install dependencies
run: |
python3 -m pip install --upgrade pip wheel
python3 -m pip install -r requirements.txt
- name: Build dist
run: python setup.py sdist --formats=gztar

- name: Build wheel
run: python3 setup.py bdist_wheel

- uses: actions/upload-artifact@v2
with:
path: dist/*.tar.gz

upload_pypi:
needs: [build_dist]
runs-on: ubuntu-latest
# upload to PyPI on every tag starting with 'v'
# if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
# alternatively, to publish when a GitHub Release is created, use the following rule:
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v2
with:
name: artifact
path: dist

- uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.pypi_password }}
# To test: repository_url: https://test.pypi.org/legacy/
73 changes: 73 additions & 0 deletions .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Unittest, flake8

# Run action on pull requests
on:
pull_request:
branches: [master]

jobs:
flake8:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.7"

- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install flake8
- name: Lint with flake8
run: |
flake8 inicheck
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.7"

- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install coverage coveralls PyYAML
python3 -m pip install -r requirements.txt
- name: Run coverage
run: |
make coverage
coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

unittest:
needs: [flake8, coverage]
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: [3.6, 3.7, 3.8, 3.9]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements.txt
- name: Run unittests
run: python3 -m unittest -v
29 changes: 0 additions & 29 deletions .travis.yml

This file was deleted.

13 changes: 12 additions & 1 deletion CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,21 @@ Before you submit a pull request, check that it meets these guidelines:
2. If the pull request adds functionality, the docs should be updated. Put
your new functionality into a function with a docstring, and add the
feature to the list in README.rst.
3. The pull request should work for Python 3.5, 3.6, 3.7, 3.8 and for PyPy. Check
3. The pull request should work for Python >= 3.6. Check
https://github.com/USDA-ARS-NWRC/inicheck/pull_requests
and make sure that the tests pass for all supported Python versions.

Releasing to PyPI
-----------------
To create a new release on `Pypi.org <https://pypi.org/>`_, follow these steps:

#. Create a new release for inicheck
#. Name the tag and release the version number, for example `v0.9.1 <https://github.com/USDA-ARS-NWRC/inicheck/releases/tag/v0.9.1>`_
#. Add documentation about the release and why it's different from the previous.
Especially highlight any changes that will break existing integrations.
#. Publish new release which will trigger a build to release to PyPI


Tips
----

Expand Down
11 changes: 6 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@ lint: ## check style with isort and pep8
test: ## run tests quickly with the default Python
py.test

coverage: ## check code coverage quickly with the default Python
coverage run --source inicheck -m pytest
coverage report -m
coverage html
$(BROWSER) htmlcov/index.html
coverage: ## run coverage and submit
coverage run --source inicheck setup.py test
coverage report --fail-under=80

coveralls: coverage ## run coveralls
coveralls

docs: ## generate Sphinx HTML documentation, including API docs
rm -f docs/inicheck.rst
Expand Down
3 changes: 0 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ Welcome to inicheck
:target: https://inicheck.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status

.. image:: https://travis-ci.com/USDA-ARS-NWRC/inicheck.svg?branch=master
:target: https://travis-ci.com/USDA-ARS-NWRC/inicheck

.. image:: https://coveralls.io/repos/github/USDA-ARS-NWRC/inicheck/badge.svg?branch=master
:target: https://coveralls.io/github/USDA-ARS-NWRC/inicheck?branch=master

Expand Down
17 changes: 4 additions & 13 deletions inicheck/changes.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import importlib
from collections import OrderedDict
from os.path import abspath
from os.path import join as pjoin

from .entries import ConfigEntry
from .iniparse import parse_changes, parse_items, parse_sections
from .utilities import mk_lst, parse_date

Expand Down Expand Up @@ -72,10 +68,9 @@ def check_log_validity(self, mcfg):
are valid. Also confirms that removals are aligned with the master.
"""
action_kw = ["any", 'removed']
cfe = ConfigEntry()
invalids = []

for zz, c in enumerate(self.changes):
for c in self.changes:
# Check the new assignments match the names of current master items
current = c[1]
valids = []
Expand Down Expand Up @@ -116,9 +111,9 @@ def check_log_validity(self, mcfg):

# Form a coherent message about incorrect changlog stuff
if invalids:
msg = ("Changelog states a change that doesn't match the core config."
" For a change to be valid the new changes must be in the"
" Master Config file. Mismatches are:")
msg = ("Changelog states a change that doesn't match the core "
"config. For a change to be valid the new changes must "
"be in the Master Config file. Mismatches are:")

for n in invalids:
msg += "\n * "
Expand All @@ -139,8 +134,6 @@ def get_active_changes(self, ucfg):
required_changes = []
potential_changes = []

cfe = ConfigEntry()

cfg = ucfg.cfg

for change in self.changes:
Expand Down Expand Up @@ -228,8 +221,6 @@ def apply_changes(self, ucfg, potentials, changes):
s_n = c[1][0]
i_n = c[1][1]

#print(s_o, i_o, s_n, i_n)

# Confirm new section in the config
if not removal:
if s_n not in ucfg.cfg.keys():
Expand Down

0 comments on commit 283c4cb

Please sign in to comment.