Skip to content

Commit

Permalink
Merge pull request #922 from rickecon/tests
Browse files Browse the repository at this point in the history
Update GH Actions and CodeCov
  • Loading branch information
jdebacker committed Apr 13, 2024
2 parents 8f25b15 + dd1f3f7 commit 95987b7
Show file tree
Hide file tree
Showing 14 changed files with 96 additions and 52 deletions.
47 changes: 28 additions & 19 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
name: Build and test [Python 3.9, 3.10, 3.11]

on: [push, pull_request]
# paths:
# - '*.py'
# - 'environment.yml'
# - 'requirements.txt'
# - '*.pkl'
# - '*.csv'
# - '*.json'

name: Build and test
on:
push:
paths:
- '**.yml'
- '**.toml'
- '**.ini'
- '**.py'
- '**.json'
- '**.csv'
- '**.pkl'
- '**.pbz2'
pull_request:
paths:
- '**.yml'
- '**.toml'
- '**.ini'
- '**.py'
- '**.json'
- '**.csv'
- '**.pkl'
- '**.pbz2'
jobs:
build:
runs-on: ${{ matrix.os }}
Expand All @@ -19,36 +30,34 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Setup Miniconda using Python ${{ matrix.python-version }}
uses: conda-incubator/setup-miniconda@v2
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Mambaforge
auto-update-conda: true
activate-environment: ogcore-dev
environment-file: environment.yml
python-version: ${{ matrix.python-version }}
auto-activate-base: false

- name: Build
shell: bash -l {0}
run: |
pip install -e .
pip install pytest-cov
pip install pytest-pycodestyle
- name: Test
shell: bash -l {0}
working-directory: ./
run: |
pytest -m 'not local' --cov=./ --cov-report=xml
python -m pytest -m "not local" --cov=./ --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
if: matrix.os == 'ubuntu-latest'
uses: codecov/codecov-action@v4
with:
files: ./coverage.xml
flags: unittests
name: codecov-umbrella
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
verbose: true
17 changes: 12 additions & 5 deletions .github/workflows/deploy_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ on:
push:
branches:
- master
paths:
- './docs/**.png'
- './docs/book/content/theory/images/**.png'
- './docs/book/**.yml'
- './docs/book/**.bib'
- '**.md'
- './docs/book/content/api/**.rst'
- './ogcore/**.py'
jobs:
build-and-deploy:
if: github.repository == 'PSLmodels/OG-Core'
Expand All @@ -14,21 +22,20 @@ jobs:
persist-credentials: false

- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@v2
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Mambaforge
activate-environment: ogusa-dev
activate-environment: ogcore-dev
environment-file: environment.yml
python-version: "3.10"
python-version: "3.11"
auto-activate-base: false

- name: Build # Build Jupyter Book
shell: bash -l {0}
run: |
pip install -e .
python -m ipykernel install --user --name=ogcore-dev
cd docs
jb build ./book
jb build ./docs/book
- name: Deploy
uses: JamesIves/github-pages-deploy-action@v4
Expand Down
22 changes: 15 additions & 7 deletions .github/workflows/docs_check.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,36 @@
name: Check that docs build
on: [push, pull_request]
on:
pull_request:
paths:
- './docs/**.png'
- './docs/book/content/theory/images/**.png'
- './docs/book/**.yml'
- './docs/book/**.bib'
- '**.md'
- './docs/book/content/api/**.rst'
- './ogcore/**.py'

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4 # If you're using actions/checkout@v2 you must set persist-credentials to false in most cases for the deployment to work correctly.
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@v2
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Mambaforge
activate-environment: ogusa-dev
activate-environment: ogcore-dev
environment-file: environment.yml
python-version: "3.10"
python-version: "3.11"
auto-activate-base: false

- name: Build # Build Jupyter Book
shell: bash -l {0}
run: |
pip install -e .
python -m ipykernel install --user --name=ogcore-dev
cd docs
jb build ./book
jb build ./docs/book
8 changes: 4 additions & 4 deletions .github/workflows/publish_to_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: 3.9
python-version: "3.11"
- name: Build package
run: make pip-package
- name: Publish a Python distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI }}
skip_existing: true
skip_existing: true
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## [0.11.5] - 2024-04-11 12:00:00

### Added

- Adds a list of file change event triggers to `build_and_test.yml` so that those tests only run when one of those files is changed.
- Updates the codecov GH Action to version 4 and adds a secret token.
- Adds a list of file change event triggers to `deploy_docs.yml` and `docs_check.yml`, and limits `docs_check.yml` to only run on pull requests.


## [0.11.4] - 2024-04-03 22:00:00

### Added
Expand Down Expand Up @@ -210,6 +219,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Any earlier versions of OG-USA can be found in the [`OG-Core`](https://github.com/PSLmodels/OG-Core) repository [release history](https://github.com/PSLmodels/OG-Core/releases) from [v.0.6.4](https://github.com/PSLmodels/OG-Core/releases/tag/v0.6.4) (Jul. 20, 2021) or earlier.


[0.11.5]: https://github.com/PSLmodels/OG-Core/compare/v0.11.4...v0.11.5
[0.11.4]: https://github.com/PSLmodels/OG-Core/compare/v0.11.3...v0.11.4
[0.11.3]: https://github.com/PSLmodels/OG-Core/compare/v0.11.2...v0.11.3
[0.11.2]: https://github.com/PSLmodels/OG-Core/compare/v0.11.1...v0.11.2
Expand Down
3 changes: 0 additions & 3 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,4 @@ comment:
ignore:
- "setup.py"
- "./ogcore/_version.py"
- "./cs-config/**/*" # ignore folders and all its contents
- "./tests/" # ignore folders and all its contents
- "./ogcore/tests/" # ignore folders and all its contents
- "./regression/**/*" # ignore folders and all its contents
5 changes: 3 additions & 2 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,20 @@ dependencies:
- dask-core>=2.30.0
- distributed>=2.30.1
- paramtools>=0.15.0
- sphinx
- sphinx>=3.5.4
- sphinx-argparse
- sphinxcontrib-bibtex>=2.0.0
- sphinx-math-dollar
- pydata-sphinx-theme
- jupyter-book>=0.11.3
- jupyter
- pytest>=6.0
- pytest-cov
- pytest-xdist
- pylint
- coverage
- requests
- openpyxl
- openpyxl>=3.1.2
- black>=24.1.1
- pip
- pip:
Expand Down
2 changes: 1 addition & 1 deletion ogcore/SS.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def inner_loop(outer_loop_vars, p, client):
results = results = compute(
*lazy_values,
scheduler=dask.multiprocessing.get,
num_workers=p.num_workers
num_workers=p.num_workers,
)

for j, result in enumerate(results):
Expand Down
2 changes: 1 addition & 1 deletion ogcore/TPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ def run_TPI(p, client=None):
results = results = compute(
*lazy_values,
scheduler=dask.multiprocessing.get,
num_workers=p.num_workers
num_workers=p.num_workers,
)

for j, result in enumerate(results):
Expand Down
2 changes: 1 addition & 1 deletion ogcore/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
from ogcore.txfunc import *
from ogcore.utils import *

__version__ = "0.11.4"
__version__ = "0.11.5"
12 changes: 6 additions & 6 deletions ogcore/demographics.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,17 +165,17 @@ def get_fert(
if graph:
if plot_path:
pp.plot_fert_rates(
fert_rates_2D,
start_year,
[start_year, end_year],
[fert_rates_2D],
start_year=start_year,
years_to_plot=[start_year, end_year],
path=plot_path,
)
return fert_rates_2D
else:
fig = pp.plot_fert_rates(
fert_rates_2D,
start_year,
[start_year, end_year],
[fert_rates_2D],
start_year=start_year,
years_to_plot=[start_year, end_year],
)
return fert_rates_2D, fig
else:
Expand Down
14 changes: 13 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
[build-system]
requires = ["setuptools>=42"]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

# Configuration for Black.

# NOTE: you have to use single-quoted strings in TOML for regular expressions.
# It's the equivalent of r-strings in Python. Multiline strings are treated as
# verbose regular expressions by Black. Use [ ] to denote a significant space
# character.

[tool.black]
line-length = 79
target-version = ["py39", "py310", "py311"]
include = '\.pyi?$'
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="ogcore",
version="0.11.4",
version="0.11.5",
author="Jason DeBacker and Richard W. Evans",
license="CC0 1.0 Universal (CC0 1.0) Public Domain Dedication",
description="A general equilibribum overlapping generations model for fiscal policy analysis",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_demographics.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def test_infant_mort():
mort_rates, infmort_rate = demographics.get_mort(100, 0, 99, graph=False)
# check that infant mortality equals rate hardcoded into
# demographics.py
assert infmort_rate == 0.00491958
assert infmort_rate == 0.00477758


def test_pop_rebin():
Expand Down

0 comments on commit 95987b7

Please sign in to comment.