diff --git a/.github/workflows/check_jupyterbook.yml b/.github/workflows/check_jupyterbook.yml index 342314b8c..a0a0c781f 100644 --- a/.github/workflows/check_jupyterbook.yml +++ b/.github/workflows/check_jupyterbook.yml @@ -24,5 +24,6 @@ jobs: pip install jupyter-book conda install -c pslmodels behresp pip install -e . + python docs/guide/make/make_uguide.py cd docs jb build . \ No newline at end of file diff --git a/.github/workflows/deploy_parameters_docs.yml b/.github/workflows/deploy_parameters_docs.yml new file mode 100644 index 000000000..ee803f1ba --- /dev/null +++ b/.github/workflows/deploy_parameters_docs.yml @@ -0,0 +1,39 @@ +name: Build and Deploy Jupyter Book with Parameter Documentation +on: + release: + types: [published] + +jobs: + build-and-deploy: + if: github.repository == 'PSLmodels/Tax-Calculator' + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 # If you're using actions/checkout@v2 you must set persist-credentials to false in most cases for the deployment to work correctly. + with: + persist-credentials: false + + - name: Setup Miniconda + uses: goanpeca/setup-miniconda@v1 + with: + activate-environment: taxcalc-dev + environment-file: environment.yml + python-version: 3.7 + auto-activate-base: false + + - name: Build # Build Jupyter Book + shell: bash -l {0} + run: | + pip install jupyter-book + conda install -c pslmodels behresp + pip install -e . + python docs/guide/make/make_uguide.py + cd docs + jb build . + + - name: Deploy + uses: JamesIves/github-pages-deploy-action@releases/v3 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BRANCH: gh-pages # The branch the action should deploy to. + FOLDER: docs/_build/html # The folder the action should deploy. diff --git a/taxcalc/tests/test_docs.py b/taxcalc/tests/test_docs.py deleted file mode 100644 index e578891eb..000000000 --- a/taxcalc/tests/test_docs.py +++ /dev/null @@ -1,87 +0,0 @@ -""" -Tests for Tax-Calculator docs. -""" -# CODING-STYLE CHECKS: -# pycodestyle test_docs.py -# pylint --disable=locally-disabled test_docs.py - -import os -import glob -import pytest - - -@pytest.mark.pre_release -def test_docs_uguide_up_to_date(tests_path): - """ - Check that uguide.html timestamp is greater than the timestamp - of each of its dependencies, where a timestamp is the time a file - was last modified. - """ - code_path = os.path.join(tests_path, '..') - docs_path = os.path.join(code_path, '..', 'docs') - target = os.path.join(docs_path, 'uguide.html') - dependencies = [os.path.join(docs_path, 'uguide.htmx'), - os.path.join(docs_path, 'make_uguide.py'), - os.path.join(code_path, 'policy_current_law.json'), - os.path.join(code_path, 'consumption.json'), - os.path.join(code_path, 'growdiff.json'), - os.path.join(code_path, 'records_variables.json')] - target_timestamp = os.path.getmtime(target) - target_up_to_date = True - for dep in dependencies: - if os.path.getmtime(dep) > target_timestamp: - target_up_to_date = False - if not target_up_to_date: - msg = 'Tax-Calculator/docs/uguide.html IS NOT UP-TO-DATE\n' - msg += '### \n' - msg += '### If you see this when preparing a pull request,\n' - msg += '### you are misusing pytest. Please read the \n' - msg += '### testing instructions in the Contributor Guide \n' - msg += '### and ignore the following instructions. \n' - msg += '### \n' - msg += 'FIX BY DOING THIS: \n' - msg += ' $ cd Tax-Calculator/docs \n' - msg += ' $ python make_uguide.py \n' - msg += 'AND INCLUDE UPDATED uguide.html IN NEXT COMMIT \n' - msg += ' \n' - msg += 'IF NO SUBSTATIVE CHANGES IN uguide.html ARE REQUIRED, \n' - msg += 'TOUCH THE UNCHANGED FILE SO IT HAS A CURRENT TIMESTAMP.\n' - raise ValueError(msg) - - -@pytest.mark.pre_release -def test_docs_cookbook_up_to_date(tests_path): - """ - Check that cookbook.html timestamp is greater than the timestamp - of each of its dependencies, where a timestamp is the time a file - was last modified. - """ - docs_path = os.path.join(tests_path, '..', '..', 'docs') - target = os.path.join(docs_path, 'cookbook.html') - cookbook_path = os.path.join(docs_path, 'cookbook') - recipes = glob.glob(os.path.join(cookbook_path, '*py')) - ingredients = glob.glob(os.path.join(cookbook_path, '*json')) - results = glob.glob(os.path.join(cookbook_path, '*res')) - dependencies = recipes + ingredients + results - target_timestamp = os.path.getmtime(target) - target_up_to_date = True - for dep in dependencies: - if os.path.getmtime(dep) > target_timestamp: - target_up_to_date = False - if not target_up_to_date: - msg = 'Tax-Calculator/docs/cookbook.html IS NOT UP-TO-DATE: \n' - msg += '### \n' - msg += '### If you see this when preparing a pull request,\n' - msg += '### you are misusing pytest. Please read the \n' - msg += '### testing instructions in the Contributor Guide \n' - msg += '### and ignore the following instructions. \n' - msg += '### \n' - msg += 'EDIT cookbook.html SO THAT IT REFERENCES \n' - msg += '- ALL cookbook/recipe*py FILES, \n' - msg += '- ALL cookbook/recipe*res FILES, \n' - msg += '- ALL cookbook/*json FILES. \n' - msg += 'AND INCLUDE THE UPDATED cookbook.html IN NEXT COMMIT. \n' - msg += ' \n' - msg += 'IF NO SUBSTATIVE CHANGES IN cookbook.html ARE REQUIRED,\n' - msg += 'TOUCH THE UNCHANGED FILE SO IT HAS A CURRENT TIMESTAMP.\n' - raise ValueError(msg)