Skip to content

Commit

Permalink
Merge pull request PSLmodels#99 from rickecon/tests
Browse files Browse the repository at this point in the history
Update GH Action tests and CodeCov
  • Loading branch information
jdebacker authored Apr 12, 2024
2 parents 9f1d02f + 415df86 commit 4c0e3d8
Show file tree
Hide file tree
Showing 15 changed files with 124,550 additions and 124,465 deletions.
40 changes: 29 additions & 11 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
name: Build and test [Python 3.9, 3.10]

on: [push, pull_request]

name: Build and test
on:
push:
paths:
- '**.yml'
- '**.toml'
- '**.ini'
- '**.py'
- '**.json'
- '**.R'
- '**.RData'
- '**.csv'
- '**.pkl'
pull_request:
paths:
- '**.yml'
- '**.toml'
- '**.ini'
- '**.py'
- '**.json'
- '**.R'
- '**.RData'
- '**.csv'
- '**.pkl'
jobs:
build:
runs-on: ${{ matrix.os }}
Expand All @@ -15,33 +35,31 @@ jobs:
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: ogusa-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 and not regression' --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
11 changes: 10 additions & 1 deletion .github/workflows/deploy_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ on:
push:
branches:
- master
paths:
- './docs/**.png'
- './docs/book/content/calibration/images/**.png'
- './docs/README.md'
- './docs/book/**.yml'
- './docs/book/**.bib'
- '**.md'
- './docs/book/content/api/**.rst'
- './ogusa/**.py'
jobs:
build-and-deploy:
if: github.repository == 'PSLmodels/OG-USA'
Expand All @@ -14,7 +23,7 @@ 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
Expand Down
14 changes: 12 additions & 2 deletions .github/workflows/docs_check.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
name: Check that docs build
on: [push, pull_request]
on:
pull_request:
paths:
- './docs/**.png'
- './docs/book/content/calibration/images/**.png'
- './docs/README.md'
- './docs/book/**.yml'
- './docs/book/**.bib'
- '**.md'
- './docs/book/content/api/**.rst'
- './ogusa/**.py'

jobs:
build:
Expand All @@ -11,7 +21,7 @@ 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
Expand Down
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ envs/
*/__pycache__/*
docs/book/_build/*
docs/build*
*micro_data_*.pkl
examples/OG-USA_example_plots/*
examples/ogusa_example_output.csv
examples/OG-USA-Example/*
cs-config/cs_config/OUTPUT_BASELINE/*
data/csv_output_files/*
data/images/*
ogusa/csv_output_files/*
ogusa/images/*
.vscode/
*default.profraw
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file.
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.1.5] - 2024-04-12 10: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.
- Fixes a small typo in `tax_functions.md` in order to test if the event triggers worked properly (yes, they worked)
- Updated some dependencies in `environment.yml`.
- Updated three data files in the `/tests/test_io_data/` file that used output from the taxcalc package. This package was recently updated. I also changed the `test_get_data()` test in the `test_get_micro_data.py` file because the new taxcalc data included four years instead of two years. In order to conserve repo memory footprint, we deleted the last two years of the output.

## [0.1.4] - 2024-04-03 15:00:00

### Added
Expand Down Expand Up @@ -68,6 +79,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0



[0.1.5]: https://github.com/PSLmodels/OG-USA/compare/v0.1.4...v0.1.5
[0.1.4]: https://github.com/PSLmodels/OG-USA/compare/v0.1.3...v0.1.4
[0.1.3]: https://github.com/PSLmodels/OG-USA/compare/v0.1.2...v0.1.3
[0.1.2]: https://github.com/PSLmodels/OG-USA/compare/v0.1.1...v0.1.2
[0.1.1]: https://github.com/PSLmodels/OG-USA/compare/v0.1.0...v0.1.1
25 changes: 25 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
codecov:
require_ci_to_pass: yes

coverage:
precision: 2
round: down
range: "70...100"

parsers:
gcov:
branch_detection:
conditional: yes
loop: yes
method: no
macro: no

comment:
layout: "reach, diff, flags, files"
behavior: default
require_changes: false

ignore:
- "setup.py"
- "./cs-config/**/*" # ignore folders and all its contents
- "./tests/" # ignore folders and all its contents
2 changes: 1 addition & 1 deletion docs/book/content/calibration/tax_functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ The second difficulty in modeling realistic tax and incentive detail is the need
\tau^{mtry} \equiv \frac{\partial T_{s,t}}{\partial r_{hh,t}b_{j,s,t}} = \frac{\partial T_{s,t}}{\partial y_{j,s,t}} \qquad\quad\forall j,t \quad\text{and}\quad E+1\leq s\leq E+S
```

As we show in Section [Optimality Conditions](https://pslmodels.github.io/OG-Core/content/theory/households.html#optimality-conditions) of the Households chapter of the `OG-Core` repository documentation, the derivative of total tax liability with respect to labor supply $\frac{\partial T_{s,t}}{n_{j,s,t}}$ and the derivative of total tax liability next period with respect to savings $\frac{\partial T_{s+1,t+1}}{b_{j,s+1,t+1}}$ show up in the household Euler equations for labor supply and savings , respectively, in the `OG-Core` documentation. It is valuable to be able to express those marginal tax rates, for which we have no data, as marginal tax rates for which we do have data. The following two expressions show how the marginal tax rates of labor supply can be expressed as the marginal tax rate on labor income times the household-specific wage and how the marginal tax rate of savings can be expressed as the marginal tax rate of capital income times the interest rate.
As we show in Section [Optimality Conditions](https://pslmodels.github.io/OG-Core/content/theory/households.html#optimality-conditions) of the Households chapter of the `OG-Core` repository documentation, the derivative of total tax liability with respect to labor supply $\frac{\partial T_{s,t}}{n_{j,s,t}}$ and the derivative of total tax liability next period with respect to savings $\frac{\partial T_{s+1,t+1}}{b_{j,s+1,t+1}}$ show up in the household Euler equations for labor supply and savings, respectively, in the `OG-Core` documentation. It is valuable to be able to express those marginal tax rates, for which we have no data, as marginal tax rates for which we do have data. The following two expressions show how the marginal tax rates of labor supply can be expressed as the marginal tax rate on labor income times the household-specific wage and how the marginal tax rate of savings can be expressed as the marginal tax rate of capital income times the interest rate.

```{math}
:label: EqMTRx_derive
Expand Down
11 changes: 6 additions & 5 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,22 @@ channels:
dependencies:
- python>=3.7.7,<3.12
- numpy
- setuptools
- numba>=0.54
- scipy>=1.5.0
- scipy>=1.7.1
- pandas>=1.2.5
- matplotlib
- dask>=2.30.0
- dask-core>=2.30.0
- distributed>=2.30.1
- paramtools>=0.15.0
- taxcalc>=3.0.0
- sphinx>=3.5.4
- sphinx-book-theme>=0.1.3
- pip
- jupyter-book>=0.11.3
- pytest>=6.0
- pytest-pep8
- pytest-cov
- pytest-xdist
- pycodestyle
- pylint
- coverage
- requests
Expand All @@ -27,8 +28,8 @@ dependencies:
- linearmodels
- rpy2<=3.5.11
- black>=24.1.1
- pip
- pip:
- jupyter-book>=0.9.1
- openpyxl>=3.1.2
- cs-kit
- cs2tc
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ build-backend = "setuptools.build_meta"

[tool.black]
line-length = 79
target-version = ["py39", "py310", "py311"]
target-version = ["py39", "py310"]
include = '\.pyi?$'
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
[pytest]
minversion = 6.0
testpaths =
ogusa/tests
./tests
markers =
local: marks tests that are run locally only and not on GH Actions
Loading

0 comments on commit 4c0e3d8

Please sign in to comment.