From c2e7491aaada4626727b3ee10e418eafe73e7e8b Mon Sep 17 00:00:00 2001 From: Richard Evans Date: Thu, 13 Jun 2024 11:11:29 -0600 Subject: [PATCH 01/18] Added changelog_entry.yaml --- changelog_entry.yaml | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 changelog_entry.yaml diff --git a/changelog_entry.yaml b/changelog_entry.yaml new file mode 100644 index 000000000..e69de29bb From ebfadcccd30237eebff2ef4cf772e942c2605bef Mon Sep 17 00:00:00 2001 From: Richard Evans Date: Thu, 13 Jun 2024 15:43:56 -0600 Subject: [PATCH 02/18] Updated Makefile --- Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Makefile b/Makefile index 303a3a0d6..df2b6e945 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,12 @@ # to work in that environment (and not on Windows). # USAGE: OG-Core$ make [TARGET] +changelog: + build-changelog changelog.yaml --output changelog.yaml --update-last-date --start-from 0.11.9 --append-file changelog_entry.yaml + build-changelog changelog.yaml --org PSLmodels --repo OG-Core --output CHANGELOG.md --template .github/changelog_template.md + bump-version changelog.yaml setup.py + rm changelog_entry.yaml || true + touch changelog_entry.yaml .PHONY=help help: @echo "USAGE: make [TARGET]" From 3d39b0e99904c3ba218f397996a0e69abd82a4ac Mon Sep 17 00:00:00 2001 From: Richard Evans Date: Thu, 13 Jun 2024 15:44:31 -0600 Subject: [PATCH 03/18] Updated changelog_template.md --- .github/changelog_template.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .github/changelog_template.md diff --git a/.github/changelog_template.md b/.github/changelog_template.md new file mode 100644 index 000000000..2672536df --- /dev/null +++ b/.github/changelog_template.md @@ -0,0 +1,8 @@ +# Changelog + +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). + +{{changelog}} From af9963df5fc4d76652415b85f3f787f3f20530a6 Mon Sep 17 00:00:00 2001 From: Richard Evans Date: Thu, 13 Jun 2024 15:45:55 -0600 Subject: [PATCH 04/18] Added version reference variable to __init__.py --- ogcore/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ogcore/__init__.py b/ogcore/__init__.py index 867703ee1..362b51d61 100644 --- a/ogcore/__init__.py +++ b/ogcore/__init__.py @@ -2,6 +2,7 @@ Specify what is available to import from the ogcore package. """ +import ogcore.__version__ as ogc_version from ogcore.SS import * from ogcore.TPI import * from ogcore.aggregates import * @@ -20,4 +21,4 @@ from ogcore.txfunc import * from ogcore.utils import * -__version__ = "0.11.9" +__version__ = ogc_version From 45a076a30966c3678b5e9de02e821063b6f039a7 Mon Sep 17 00:00:00 2001 From: Richard Evans Date: Thu, 13 Jun 2024 15:47:00 -0600 Subject: [PATCH 05/18] Added changelog.yaml file --- changelog.yaml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 changelog.yaml diff --git a/changelog.yaml b/changelog.yaml new file mode 100644 index 000000000..1f1391091 --- /dev/null +++ b/changelog.yaml @@ -0,0 +1,7 @@ +- changes: + added: + - The first release of the OG-Core model was version 0.7.0 on 2021-08-30 (see CHANGELOG.md) + - Many releases were tagged between 2021-08-30 and 2024-06-12 (see CHANGELOG.md) + - The most recent release is 0.11.9 (see CHANGELOG.md) + date: 2024-06-12 01:00:00 + version: 0.11.9 From b38c88705144c28d0f27778767a354b342dc578e Mon Sep 17 00:00:00 2001 From: Richard Evans Date: Thu, 13 Jun 2024 15:51:46 -0600 Subject: [PATCH 06/18] Updated __init__.py --- ogcore/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ogcore/__init__.py b/ogcore/__init__.py index 362b51d61..0fef5319e 100644 --- a/ogcore/__init__.py +++ b/ogcore/__init__.py @@ -2,7 +2,7 @@ Specify what is available to import from the ogcore package. """ -import ogcore.__version__ as ogc_version +import ogcore from ogcore.SS import * from ogcore.TPI import * from ogcore.aggregates import * @@ -21,4 +21,4 @@ from ogcore.txfunc import * from ogcore.utils import * -__version__ = ogc_version +__version__ = ogcore.__version__ From 62bd31feb9ab159f555db411d787cbe11391410c Mon Sep 17 00:00:00 2001 From: Richard Evans Date: Thu, 13 Jun 2024 15:59:40 -0600 Subject: [PATCH 07/18] Added get-changelog-diff.sh, has-functional-changes.sh, is-version-number-acceptable.sh --- .github/get-changelog-diff.sh | 4 +++ .github/has-functional-changes.sh | 12 +++++++++ .github/is-version-number-acceptable.sh | 33 +++++++++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100755 .github/get-changelog-diff.sh create mode 100755 .github/has-functional-changes.sh create mode 100755 .github/is-version-number-acceptable.sh diff --git a/.github/get-changelog-diff.sh b/.github/get-changelog-diff.sh new file mode 100755 index 000000000..1c2185346 --- /dev/null +++ b/.github/get-changelog-diff.sh @@ -0,0 +1,4 @@ +git remote add upstream https://github.com/PSLmodels/OG-Core.git +git fetch --tags upstream +last_tagged_commit=`git describe --tags --abbrev=0 --first-parent` +git --no-pager diff $last_tagged_commit -- CHANGELOG.md diff --git a/.github/has-functional-changes.sh b/.github/has-functional-changes.sh new file mode 100755 index 000000000..d3b47ca99 --- /dev/null +++ b/.github/has-functional-changes.sh @@ -0,0 +1,12 @@ +#! /usr/bin/env bash + +IGNORE_DIFF_ON="README.md CONTRIBUTING.md Makefile .gitignore LICENSE* .github/* environment.yml" + +last_tagged_commit=$(git describe --tags --abbrev=0 --first-parent) # --first-parent ensures we don't follow tags not published in master through an unlikely intermediary merge commit + +if git diff-index --name-only --exit-code $last_tagged_commit -- . $(echo " $IGNORE_DIFF_ON" | sed 's/ / :(exclude)/g'); then # Check if any file that has not be listed in IGNORE_DIFF_ON has changed since the last tag was published. + echo "No functional changes detected." + exit 1 +else + echo "The functional files above were changed." +fi diff --git a/.github/is-version-number-acceptable.sh b/.github/is-version-number-acceptable.sh new file mode 100755 index 000000000..0f704a93f --- /dev/null +++ b/.github/is-version-number-acceptable.sh @@ -0,0 +1,33 @@ +#! /usr/bin/env bash + +if [[ ${GITHUB_REF#refs/heads/} == master ]] +then + echo "No need for a version check on master." + exit 0 +fi + +if ! $(dirname "$BASH_SOURCE")/has-functional-changes.sh +then + echo "No need for a version update." + exit 0 +fi + +current_version=`python setup.py --version` + +if git rev-parse --verify --quiet $current_version +then + echo "Version $current_version already exists in commit:" + git --no-pager log -1 $current_version + echo + echo "Update the version number in setup.py before merging this branch into master." + echo "Look at the CONTRIBUTING.md file to learn how the version number should be updated." + exit 1 +fi + +if ! $(dirname "$BASH_SOURCE")/has-functional-changes.sh | grep --quiet CHANGELOG.md +then + echo "CHANGELOG.md has not been modified, while functional changes were made." + echo "Explain what you changed before merging this branch into master." + echo "Look at the CONTRIBUTING.md file to learn how to write the changelog." + exit 2 +fi From cbb6212fd7bd2cd5cdeaec97a9ac5594ea3c47d6 Mon Sep 17 00:00:00 2001 From: Richard Evans Date: Thu, 13 Jun 2024 16:00:20 -0600 Subject: [PATCH 08/18] Updated build_and_test.yml --- .github/workflows/build_and_test.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index fd3b19549..0d569d091 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -21,6 +21,25 @@ on: - '**.pkl' - '**.pbz2' jobs: + check-version: + name: Check version + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + repository: ${{ github.event.pull_request.head.repo.full_name }} + ref: ${{ github.event.pull_request.head.ref }} + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + - name: Build changelog + run: pip install yaml-changelog>=0.1.7 && make changelog + - name: Preview changelog update + run: ".github/get-changelog-diff.sh" + - name: Check version number has been properly updated + run: .github/is-version-number-acceptable.sh build: runs-on: ${{ matrix.os }} strategy: From 9da5f1103cc58f1e030c3b575933b1d128e154cc Mon Sep 17 00:00:00 2001 From: Richard Evans Date: Thu, 13 Jun 2024 19:12:16 -0600 Subject: [PATCH 09/18] Updated README.md --- README.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ae96b2ae1..d001a34bb 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ | | | | --- | --- | | Org | [![PSL cataloged](https://img.shields.io/badge/PSL-cataloged-a0a0a0.svg)](https://www.PSLmodels.org) [![OS License: CCO-1.0](https://img.shields.io/badge/OS%20License-CCO%201.0-yellow)](https://github.com/PSLmodels/OG-Core/blob/master/LICENSE) [![Jupyter Book Badge](https://jupyterbook.org/badge.svg)](https://pslmodels.github.io/OG-Core/) | -| Package | [![Python 3.9](https://img.shields.io/badge/python-3.9-blue.svg)](https://www.python.org/downloads/release/python-3916/) [![Python 3.10](https://img.shields.io/badge/python-3.10-blue.svg)](https://www.python.org/downloads/release/python-3108/) [![Python 3.11](https://img.shields.io/badge/python-3.10-blue.svg)](https://www.python.org/downloads/release/python-3118/) [![PyPI Latest Release](https://img.shields.io/pypi/v/ogcore.svg)](https://pypi.org/project/ogcore/) [![PyPI Downloads](https://img.shields.io/pypi/dm/ogcore.svg?label=PyPI%20downloads)](https://pypi.org/project/ogcore/) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) | +| Package | [![Python 3.10](https://img.shields.io/badge/python-3.10-blue.svg)](https://www.python.org/downloads/release/python-3108/) [![Python 3.11](https://img.shields.io/badge/python-3.11-blue.svg)](https://www.python.org/downloads/release/python-3118/) [![PyPI Latest Release](https://img.shields.io/pypi/v/ogcore.svg)](https://pypi.org/project/ogcore/) [![PyPI Downloads](https://img.shields.io/pypi/dm/ogcore.svg?label=PyPI%20downloads)](https://pypi.org/project/ogcore/) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) | | Testing | ![example event parameter](https://github.com/PSLmodels/OG-Core/actions/workflows/build_and_test.yml/badge.svg?branch=master) ![example event parameter](https://github.com/PSLmodels/OG-Core/actions/workflows/deploy_docs.yml/badge.svg?branch=master) ![example event parameter](https://github.com/PSLmodels/OG-Core/actions/workflows/check_black.yml/badge.svg?branch=master) [![Codecov](https://codecov.io/gh/PSLmodels/OG-Core/branch/master/graph/badge.svg)](https://codecov.io/gh/PSLmodels/OG-Core) | @@ -15,9 +15,9 @@ OG-Core is an overlapping-generations (OG) model core theory, logic, and solutio The model is constantly under development, and model components could change significantly. The package will have released versions, which will be checked against existing code prior to release. Stay tuned for an upcoming release! -## Using/contributing to OG-Core +## Using OG-Core -There are two primary methods for installing and running OG-Core on your computer locally. The first and simplest method is to download the most recent `ogcore` Python package from the Python Package Index ([PyPI.org]()). A second option is to fork and clone the most recent version of OG-Core from its GitHub repository and create the conda environment for the `ogcore` package. We detail both of these methods below. +There are two primary methods for installing and running OG-Core on your computer locally. The first and simplest method is to download the most recent `ogcore` Python package from the Python Package Index ([PyPI.org](https://pypi.org/)). A second option is to fork and clone the most recent version of OG-Core from its GitHub repository and create the conda environment for the `ogcore` package. We detail both of these methods below. ### Installing and Running OG-Core from Python Package Index (PyPI.org) @@ -84,12 +84,17 @@ If you run into errors running the example script, please open a new issue in th The CSV output file `./run_examples/ogcore_example_output.csv` can be compared to the `./run_examples/expected_ogcore_example_output.csv` file that is checked into the repository to confirm that you are generating the expected output. The easiest way to do this is to use the `sh example-diffs` command (or `example-diffs` on Windows) from the `run_examples` directory. If you run into errors running the example script, please open a new issue in the OG-Core repo with a description of the issue and any relevant tracebacks you receive. +## Contributing to OG-Core + +Instructions for how to submit changes to the OG-Core repository can be found in the "[Contributor Guide](https://pslmodels.github.io/OG-Core/content/contributing/contributor_guide.html)" chapter in the online Jupyter Book documentation (https://pslmodels.github.io/OG-Core/content/contributing/contributor_guide.html). This open source project follows a standard fork/branch/pull request workflow described here (https://guides.github.com/introduction/flow/), and we use semantic versioning 2.0.0 (http://semver.org/). Please follow the approach described in the [Contributor Guide](https://pslmodels.github.io/OG-Core/content/contributing/contributor_guide.html) to submit changes to the model. + + ## Core Maintainers The core maintainers of the OG-Core repository are: * [Jason DeBacker](https://www.jasondebacker.com/) (GitHub handle: [jdebacker](https://github.com/jdebacker)), Associate Professor, Department of Economics, Darla Moore School of Business, University of South Carolina; President, PSL Foundation; Vice President of Research and Co-founder, Open Research Group, Inc. -* [Richard W. Evans](https://sites.google.com/site/rickecon/) (GitHub handle: [rickecon](https://github.com/rickecon)), Advisory Board Visiting Fellow, Center for Public Finance, Baker Institute for Public Policy at Rice University; President, Open Research Group, Inc.; Director, Open Source Economics Laboratory +* [Richard W. Evans](https://sites.google.com/site/rickecon/) (GitHub handle: [rickecon](https://github.com/rickecon)), Senior Economist, Abundance Institute; President, Open Research Group, Inc.; Director, Open Source Economics Laboratory ## Citing OG-Core From 2f8e2b1727be6936db49819f6f22f45b45dc5176 Mon Sep 17 00:00:00 2001 From: Richard Evans Date: Thu, 13 Jun 2024 19:12:41 -0600 Subject: [PATCH 10/18] Updated contributor_guide.md --- .../content/contributing/contributor_guide.md | 81 ++++++++++--------- 1 file changed, 45 insertions(+), 36 deletions(-) diff --git a/docs/book/content/contributing/contributor_guide.md b/docs/book/content/contributing/contributor_guide.md index 2cff18654..e61050f6c 100644 --- a/docs/book/content/contributing/contributor_guide.md +++ b/docs/book/content/contributing/contributor_guide.md @@ -46,7 +46,7 @@ If you have already completed the {ref}`Sec_SetupPython` and {ref}`Sec_SetupGit` execute the source code: ``` - OG-Core$ conda env create + OG-Core$ conda env create -f environment.yml ``` 10. The prior command will create a conda environment called `ogcore-dev`. @@ -62,18 +62,9 @@ If you have already completed the {ref}`Sec_SetupPython` and {ref}`Sec_SetupGit` OG-Core$ pip install -e . ``` -If you have made it this far, you've successfully made a remote copy (a -fork) of the central `OG-Core` repo. That remote repo is hosted on GitHub.com at [https://github.com/PSLmodels/OG-Core](https://github.com/PSLmodels/OG-Core). You have also created a local repo (a [clone](https://help.github.com/articles/github-glossary/#clone)) that lives -on your machine and only you can see; you will make your changes to -the OG-Core model by editing the files in the `OG-Core` -directory on your machine and then submitting those changes to your -local repo. As a new contributor, you will push your changes from your -local repo to your remote repo when you're ready to share that work -with the team. +If you have made it this far, you've successfully made a remote copy (a fork) of the central `OG-Core` repo. The main repository is hosted in the cloud at https://github.com/PSLmodels/OG-Core. Your fork of that repository is hosted in the cloud on your GitHub account at https://github.com/[YourGitHubHandle]/OG-Core. For example, Richard Evans' fork of OG-Core is at https://github.com/rickecon/OG-Core. You have also created a local repository (a [clone](https://help.github.com/articles/github-glossary/#clone)) of your fork that exists in the memory of your local machine that only you can see. You will make your changes to the OG-Core model by editing the files in the `OG-Core` directory on your machine and then submitting those changes to your local repo. As a new contributor, you will push your changes from your local repo to your remote repo when you're ready to share that work with the team. -Don't be alarmed if the above paragraph is confusing. The following -section introduces some standard Git practices and guides you through -the contribution process. +Don't be alarmed if the above paragraph is confusing. The following section introduces some standard Git practices and guides you through the contribution process. (Sec_Workflow)= @@ -88,17 +79,11 @@ GitHub "issues" are an excellent way to ask questions, include code examples, an (Sec_GitHubPR)= ### Submitting a GitHub Pull Request -The following text describes a typical workflow for changing -`OG-Core`. Different workflows may be necessary in some -situations, in which case other contributors are here to help. +The following text describes a typical workflow for changing `OG-Core`. Different workflows may be necessary in some situations, in which case other contributors are here to help. -1. Before you edit the `OG-Core` source code on your machine, - make sure you have the latest version of the central OG-Core - repository by executing the following **four** Git commands: +1. Before you edit the `OG-Core` source code on your machine, make sure you have the latest version of the central OG-Core repository by executing the following **four** Git commands: - a. Tell Git to switch to the master branch in your local repo. - Navigate to your local `OG-Core` directory and enter the - following text at the command line: + a. Tell Git to switch to the master branch in your local repo. Navigate to your local `OG-Core` directory and enter the following text at the command line: ``` OG-Core$ git checkout master @@ -108,28 +93,23 @@ situations, in which case other contributors are here to help. ``` OG-Core$ git fetch upstream ``` - c. Update your local master branch to contain the latest content of - the central master branch using [merge](https://help.github.com/articles/github-glossary/#merge). This step ensures that - you are working with the latest version of `OG-Core`: + + c. Update your local master branch to contain the latest content of the central master branch using [merge](https://help.github.com/articles/github-glossary/#merge). This step ensures that you are working with the latest version of `OG-Core`: ``` OG-Core$ git merge upstream/master ``` + d. Push the updated master branch in your local repo to your GitHub repo: ``` OG-Core$ git push origin master ``` -2. Create a new [branch](https://help.github.com/articles/github-glossary/#branch) on your local machine. Think of your - branches as a way to organize your projects. If you want to work on - this documentation, for example, create a separate branch for that - work. If you want to change an element of the `OG-Core` model, create - a different branch for that project: + +2. Create a new [branch](https://help.github.com/articles/github-glossary/#branch) on your local machine. Think of your branches as a way to organize your projects. If you want to work on this documentation, for example, create a separate branch for that work. If you want to change an element of the `OG-Core` model, create a different branch for that project: ``` OG-Core$ git checkout -b [new-branch-name] ``` -3. As you make changes, frequently check that your changes do not - introduce bugs or degrade the accuracy of the `OG-Core`. To do - this, run the following command from the command line from inside - the `OG-Core/ogcore` directory: + +3. As you make changes, frequently check that your changes do not introduce bugs or degrade the accuracy of the `OG-Core`. To do this, run the following command from the command line from inside the `OG-Core/ogcore` directory: ``` OG-Core/ogcore$ pytest ``` @@ -150,13 +130,42 @@ situations, in which case other contributors are here to help. ``` You may need to resolve conflicts that arise when another contributor changed the same section of code that you are changing. Feel free to ask other contributors for guidance if this happens to you. If you do need to fix a merge conflict, re-run the test suite afterwards (step 4.) -6. When you are ready for other team members to review your code, make your final commit and push your local branch to your remote repo: +6. Make sure your changes conform to the formatting requirements of the OG-Core repository. We use the [`black`](https://pypi.org/project/black/) formatting package. You can automatically check the formatting of your changes by making sure your `ogcore-dev` conda environment is activated and typing the following commands. If you are on a Mac or Linux operating system, type the following commands in your terminal. + ``` + [Mac or Linux]OG-Core$ make format or [Windows]OG-Core$ black . -l 79 and [Windows]OG-Core$ linecheck . --fix + OG-Core$ git status + OG-Core$ git add -A + OG-Core$ git commit -m "Black formatted files" + OG-Core$ git push origin [BranchName] + ``` + +7. Update the empty [`changelog_entry.yaml`](https://github.com/PSLmodels/OG-Core/blob/master/changelog_entry.yaml) file. Our versioning process requires an updated to the version number for every pull request. This file describes the changes you have made in your pull request. It has the following format: + ```yaml + - bump: {major, minor, patch} + changes: + {added, removed, changed, fixed}: + - Updates these files and functions + - Removes these files and functions + - Solved this error or Issue + - Fixed this error or issue introduced in this PR + ``` + A `major` bump moves the first digit of the version number up by one and would be used for a major update, refactor, or campatibility change. A `minor` bump moves the second digit of the version number up by one and would be used for adding a new significant feature or module. And a `patch` bump moves the third digit of the version number up by one and would be used for a minor addition, fix, or change to already existing calculation. Here is an example of an fictional `changelog_entry.yaml` file that could be submitted with a PR. + ```yaml + - bump: patch + changes: + added: + - Adds automatic versioning workflow by updating `build_and_test.yml`, adding ` + - Updates `README.md` + ``` + + +8. When you are ready for other team members to review your code, make your final commit and push your local branch to your remote repo: ``` OG-Core$ git push origin [new-branch-name] ``` -7. From the GitHub.com user interface, [open a pull request](https://help.github.com/articles/creating-a-pull-request/#creating-the-pull-request). +9. From the GitHub.com user interface, [open a pull request](https://help.github.com/articles/creating-a-pull-request/#creating-the-pull-request). -8. When you open a GitHub pull request, a code coverage report will be automatically generated. If your branch adds new code that is not tested, the code coverage percent will decline and the number of untested statements ("misses" in the report) will increase. If this happens, you need to add to your branch one or more tests of your newly added code. Add tests so that the number of untested statements is the same as it is on the master branch. +10. When you open a GitHub pull request, a code coverage report will be automatically generated. If your branch adds new code that is not tested, the code coverage percent will decline and the number of untested statements ("misses" in the report) will increase. If this happens, you need to add to your branch one or more tests of your newly added code. Add tests so that the number of untested statements is the same as it is on the master branch. (Sec_SimpleUsage)= From 7811462a5081efec6e0ed1f8636147facfe555c1 Mon Sep 17 00:00:00 2001 From: Richard Evans Date: Thu, 13 Jun 2024 19:15:22 -0600 Subject: [PATCH 11/18] Updated Makefile --- Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Makefile b/Makefile index df2b6e945..0abed0dd7 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,12 @@ changelog: bump-version changelog.yaml setup.py rm changelog_entry.yaml || true touch changelog_entry.yaml +format: + black . -l 79 + linecheck . --fix +documentation: + jb clean ./docs/book + jb build ./docs/book .PHONY=help help: @echo "USAGE: make [TARGET]" From 7ff833ea76819d2da31e039ed968297788740dee Mon Sep 17 00:00:00 2001 From: Richard Evans Date: Thu, 13 Jun 2024 19:19:19 -0600 Subject: [PATCH 12/18] Updated changelog_entry.yaml --- changelog_entry.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/changelog_entry.yaml b/changelog_entry.yaml index e69de29bb..ea1c6fe1d 100644 --- a/changelog_entry.yaml +++ b/changelog_entry.yaml @@ -0,0 +1,5 @@ +- bump: patch + changes: + added: + - Adds automatic versioning workflow by updating `build_and_test.yml`, adding ` + - Updates `README.md` From 9a6eb119f5659c19779f5ecbded32425a43e9dcf Mon Sep 17 00:00:00 2001 From: Richard Evans Date: Thu, 13 Jun 2024 19:19:56 -0600 Subject: [PATCH 13/18] Added update_version.yml --- .github/workflows/update_version.yml | 63 ++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .github/workflows/update_version.yml diff --git a/.github/workflows/update_version.yml b/.github/workflows/update_version.yml new file mode 100644 index 000000000..fd3b19549 --- /dev/null +++ b/.github/workflows/update_version.yml @@ -0,0 +1,63 @@ +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 }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + python-version: ["3.10", "3.11"] + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Setup Miniconda using Python ${{ matrix.python-version }} + 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 . + - name: Test + shell: bash -l {0} + working-directory: ./ + run: | + python -m pytest -m "not local" --cov=./ --cov-report=xml + - name: Upload coverage to Codecov + if: matrix.os == 'ubuntu-latest' && contains(github.repository, 'PSLmodels/OG-Core') + 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 From cadf9bce4e1b2d76c743b0e3edef923e29b0611e Mon Sep 17 00:00:00 2001 From: Richard Evans Date: Thu, 13 Jun 2024 19:27:19 -0600 Subject: [PATCH 14/18] Change name to tag_version.yml --- .github/workflows/{update_version.yml => tag_version.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{update_version.yml => tag_version.yml} (100%) diff --git a/.github/workflows/update_version.yml b/.github/workflows/tag_version.yml similarity index 100% rename from .github/workflows/update_version.yml rename to .github/workflows/tag_version.yml From ad06957f0fe4b8b11b026655030f28692b76b0ad Mon Sep 17 00:00:00 2001 From: Richard Evans Date: Thu, 13 Jun 2024 19:43:19 -0600 Subject: [PATCH 15/18] Renamed code formatting action to check_format.yml --- .../workflows/{check_black.yml => check_format.yml} | 8 ++++---- README.md | 2 +- changelog_entry.yaml | 11 +++++++++-- 3 files changed, 14 insertions(+), 7 deletions(-) rename .github/workflows/{check_black.yml => check_format.yml} (57%) diff --git a/.github/workflows/check_black.yml b/.github/workflows/check_format.yml similarity index 57% rename from .github/workflows/check_black.yml rename to .github/workflows/check_format.yml index ca27c0693..1176d48c7 100644 --- a/.github/workflows/check_black.yml +++ b/.github/workflows/check_format.yml @@ -1,5 +1,5 @@ -name: Check Black formatting +name: Check code formatting on: [push, pull_request] @@ -7,9 +7,9 @@ jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 - uses: psf/black@stable with: options: "-l 79 --check" - src: "." \ No newline at end of file + src: "." diff --git a/README.md b/README.md index d001a34bb..e506ec173 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ | --- | --- | | Org | [![PSL cataloged](https://img.shields.io/badge/PSL-cataloged-a0a0a0.svg)](https://www.PSLmodels.org) [![OS License: CCO-1.0](https://img.shields.io/badge/OS%20License-CCO%201.0-yellow)](https://github.com/PSLmodels/OG-Core/blob/master/LICENSE) [![Jupyter Book Badge](https://jupyterbook.org/badge.svg)](https://pslmodels.github.io/OG-Core/) | | Package | [![Python 3.10](https://img.shields.io/badge/python-3.10-blue.svg)](https://www.python.org/downloads/release/python-3108/) [![Python 3.11](https://img.shields.io/badge/python-3.11-blue.svg)](https://www.python.org/downloads/release/python-3118/) [![PyPI Latest Release](https://img.shields.io/pypi/v/ogcore.svg)](https://pypi.org/project/ogcore/) [![PyPI Downloads](https://img.shields.io/pypi/dm/ogcore.svg?label=PyPI%20downloads)](https://pypi.org/project/ogcore/) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) | -| Testing | ![example event parameter](https://github.com/PSLmodels/OG-Core/actions/workflows/build_and_test.yml/badge.svg?branch=master) ![example event parameter](https://github.com/PSLmodels/OG-Core/actions/workflows/deploy_docs.yml/badge.svg?branch=master) ![example event parameter](https://github.com/PSLmodels/OG-Core/actions/workflows/check_black.yml/badge.svg?branch=master) [![Codecov](https://codecov.io/gh/PSLmodels/OG-Core/branch/master/graph/badge.svg)](https://codecov.io/gh/PSLmodels/OG-Core) | +| Testing | ![example event parameter](https://github.com/PSLmodels/OG-Core/actions/workflows/build_and_test.yml/badge.svg?branch=master) ![example event parameter](https://github.com/PSLmodels/OG-Core/actions/workflows/deploy_docs.yml/badge.svg?branch=master) ![example event parameter](https://github.com/PSLmodels/OG-Core/actions/workflows/check_format.yml/badge.svg?branch=master) [![Codecov](https://codecov.io/gh/PSLmodels/OG-Core/branch/master/graph/badge.svg)](https://codecov.io/gh/PSLmodels/OG-Core) | OG-Core is an overlapping-generations (OG) model core theory, logic, and solution method algorithms that allow for dynamic general equilibrium analysis of fiscal policy. OG-Core provides a general framework and is a dependency of several country-specific OG models, such as [OG-USA](https://github.com/PSLmodels/OG-USA) and [OG-UK](https://github.com/PSLmodels/OG-UK). The model output includes changes in macroeconomic aggregates (GDP, investment, consumption), wages, interest rates, and the stream of tax revenues over time. Regularly updated documentation of the model theory--its output, and solution method--and the Python API is available [here](https://pslmodels.github.io/OG-Core). diff --git a/changelog_entry.yaml b/changelog_entry.yaml index ea1c6fe1d..91716a94f 100644 --- a/changelog_entry.yaml +++ b/changelog_entry.yaml @@ -1,5 +1,12 @@ - bump: patch changes: added: - - Adds automatic versioning workflow by updating `build_and_test.yml`, adding ` - - Updates `README.md` + - Adds the following files for automatic versioning, `.github/changelog_template.md`, `.github/get-changelog-diff.sh`, `.github/has-functional-changes.sh`, `.github/is-version-number-acceptable.sh` + - Adds "Check version" job to `build_and_test.yml` GH Action. + - Adds `tag_version.yml` GH Action on push to master branch. + - Adds three new functions to `Makefile` + - Adds starting `changelog.yaml`. + - Updates `contributor_guide.md`. + - Updates `README.md`. + - Renamed code formatting GH Action from `check_black.yml` to `check_format.yml` and updated the actions within. + - Removes hard reference to version number in `./ogcore/__init__.py` so that the version reference automatically updates. From 925881932251279fb32bd85930ab907c694a61d4 Mon Sep 17 00:00:00 2001 From: Richard Evans Date: Thu, 13 Jun 2024 22:27:44 -0600 Subject: [PATCH 16/18] Added publish-git-tag.sh --- .github/publish-git-tag.sh | 4 ++++ 1 file changed, 4 insertions(+) create mode 100755 .github/publish-git-tag.sh diff --git a/.github/publish-git-tag.sh b/.github/publish-git-tag.sh new file mode 100755 index 000000000..8c6fd46ec --- /dev/null +++ b/.github/publish-git-tag.sh @@ -0,0 +1,4 @@ +#! /usr/bin/env bash + +git tag -a v`python setup.py --version` +git push --tags || true # update the repository version From fe452557f4bbcfa046c191cb4b5ddaa9b8479a21 Mon Sep 17 00:00:00 2001 From: Richard Evans Date: Thu, 13 Jun 2024 22:28:30 -0600 Subject: [PATCH 17/18] Updated github actions --- .github/is-version-number-acceptable.sh | 4 +- .github/workflows/publish_to_pypi.yml | 42 ++++++++++++++++- .github/workflows/tag_version.yml | 63 ------------------------- 3 files changed, 42 insertions(+), 67 deletions(-) delete mode 100644 .github/workflows/tag_version.yml diff --git a/.github/is-version-number-acceptable.sh b/.github/is-version-number-acceptable.sh index 0f704a93f..d49defebe 100755 --- a/.github/is-version-number-acceptable.sh +++ b/.github/is-version-number-acceptable.sh @@ -20,7 +20,7 @@ then git --no-pager log -1 $current_version echo echo "Update the version number in setup.py before merging this branch into master." - echo "Look at the CONTRIBUTING.md file to learn how the version number should be updated." + echo "Look at the changelog_entry.yaml documentation file to learn how the version number should be updated." exit 1 fi @@ -28,6 +28,6 @@ if ! $(dirname "$BASH_SOURCE")/has-functional-changes.sh | grep --quiet CHANGELO then echo "CHANGELOG.md has not been modified, while functional changes were made." echo "Explain what you changed before merging this branch into master." - echo "Look at the CONTRIBUTING.md file to learn how to write the changelog." + echo "Look at the contributor_guide.md documentation file to learn how to write the changelog_entry.yaml." exit 2 fi diff --git a/.github/workflows/publish_to_pypi.yml b/.github/workflows/publish_to_pypi.yml index 8f54f3093..7a190fe2d 100644 --- a/.github/workflows/publish_to_pypi.yml +++ b/.github/workflows/publish_to_pypi.yml @@ -1,4 +1,4 @@ -name: Publish package to PyPI +name: Tag, release, and publish package to PyPI on: push: @@ -6,8 +6,37 @@ on: - master jobs: + versioning: + name: Update versioning + if: | + (github.repository == 'PSLmodels/OG-Core') + && !(github.event.head_commit.message == 'Update OG-Core') + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v4 + with: + repository: ${{ github.event.pull_request.head.repo.full_name }} + ref: ${{ github.event.pull_request.head.ref }} + token: ${{ secrets.OGCORE_GITHUB }} + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + - name: Build changelog + run: pip install yaml-changelog && make changelog + - name: Preview changelog update + run: ".github/get-changelog-diff.sh" + - name: Update changelog + uses: EndBug/add-and-commit@v9 + with: + add: "." + committer_name: Github Actions[bot] + author_name: Github Actions[bot] + message: Update OG-Core + github_token: ${{ secrets.OGCORE_GITHUB }} deploy: - name: Publish to PyPI + name: Tag, release, Publish to PyPI if: github.repository == 'PSLmodels/OG-Core' runs-on: ubuntu-latest steps: @@ -17,6 +46,15 @@ jobs: uses: actions/setup-python@v5 with: python-version: "3.11" + - name: Publish new git tag + run: ".github/publish-tag.sh || true" + - name: Publish new release + uses: softprops/action-gh-release@v2 + if: startsWith(github.ref, 'refs/tags/') + with: + body: | + ${{ steps.preview.outputs.changelog }} + name: ${{ github.ref[1:] }} - name: Build package run: make pip-package - name: Publish a Python distribution to PyPI diff --git a/.github/workflows/tag_version.yml b/.github/workflows/tag_version.yml deleted file mode 100644 index fd3b19549..000000000 --- a/.github/workflows/tag_version.yml +++ /dev/null @@ -1,63 +0,0 @@ -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 }} - strategy: - matrix: - os: [ubuntu-latest, macos-latest, windows-latest] - python-version: ["3.10", "3.11"] - - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - persist-credentials: false - - name: Setup Miniconda using Python ${{ matrix.python-version }} - 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 . - - name: Test - shell: bash -l {0} - working-directory: ./ - run: | - python -m pytest -m "not local" --cov=./ --cov-report=xml - - name: Upload coverage to Codecov - if: matrix.os == 'ubuntu-latest' && contains(github.repository, 'PSLmodels/OG-Core') - 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 From 50a76c4ff5302e9e54fefcf098672e16e7ece048 Mon Sep 17 00:00:00 2001 From: Richard Evans Date: Tue, 18 Jun 2024 01:53:33 -0600 Subject: [PATCH 18/18] Restore __init__.py --- ogcore/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ogcore/__init__.py b/ogcore/__init__.py index 0fef5319e..ed7c9a52a 100644 --- a/ogcore/__init__.py +++ b/ogcore/__init__.py @@ -21,4 +21,4 @@ from ogcore.txfunc import * from ogcore.utils import * -__version__ = ogcore.__version__ +__version__ = "0.11.9"