From 267b946958bc3126accc64613c0154f41076bfc1 Mon Sep 17 00:00:00 2001 From: "Felt, Nicholas" Date: Mon, 5 Aug 2024 09:00:23 -0700 Subject: [PATCH 1/7] ci: Convert the test-docs.yml file into a reusable workflow --- .github/workflows/test-docs.yml | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-docs.yml b/.github/workflows/test-docs.yml index 4ea312b9..50c7b2e4 100644 --- a/.github/workflows/test-docs.yml +++ b/.github/workflows/test-docs.yml @@ -5,24 +5,37 @@ on: branches: [main] pull_request: branches: [main] + workflow_call: # In order to use this workflow, the caller must have a tox configuration that includes both a "docs" and "doctests" environment. + inputs: + node-version: + description: The version of Node.js to install. This workflow also installs + mermaid-cli via npm and graphviz via apt. + required: true + type: number + python-version: + description: The version of Python to use for this workflow. + required: true + type: string # Cancel running jobs for the same workflow and branch. concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} # IMPORTANT: Any new jobs need to be added to the check-docs-passed job to ensure they correctly gate code changes jobs: - # Test building the docs (html, linkcheck, doctest, coverage) test-docs: runs-on: ubuntu-latest strategy: fail-fast: false matrix: tox_env: [docs, doctests] + env: + NODE_VERSION: ${{ inputs.node-version || 20 }} # The node version needs to stay in sync with .readthedocs.yml + PYTHON_VERSION: ${{ inputs.node-version || '3.11' }} # This needs to stay in sync with .readthedocs.yml and pyproject.toml steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: 20 # The node version needs to stay in sync with .readthedocs.yml + node-version: env.NODE_VERSION - name: Install non-python documentation dependencies run: | npm install --global @mermaid-js/mermaid-cli @@ -30,7 +43,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.11' # This needs to stay in sync with .readthedocs.yml and pyproject.toml + python-version: env.PYTHON_VERSION - name: Install tox run: python -m pip install tox - name: Test From a14e996aaeb5c6ac8edcb3037c82fe36c805b73d Mon Sep 17 00:00:00 2001 From: "Felt, Nicholas" Date: Mon, 5 Aug 2024 09:02:43 -0700 Subject: [PATCH 2/7] ci: Update comments --- .github/workflows/test-docs.yml | 2 +- .readthedocs.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-docs.yml b/.github/workflows/test-docs.yml index 50c7b2e4..c87ef2dc 100644 --- a/.github/workflows/test-docs.yml +++ b/.github/workflows/test-docs.yml @@ -30,7 +30,7 @@ jobs: tox_env: [docs, doctests] env: NODE_VERSION: ${{ inputs.node-version || 20 }} # The node version needs to stay in sync with .readthedocs.yml - PYTHON_VERSION: ${{ inputs.node-version || '3.11' }} # This needs to stay in sync with .readthedocs.yml and pyproject.toml + PYTHON_VERSION: ${{ inputs.node-version || '3.11' }} # This needs to stay in sync with .readthedocs.yml and the tox config in pyproject.toml steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 diff --git a/.readthedocs.yml b/.readthedocs.yml index 2e3693c8..14947713 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -3,7 +3,7 @@ version: 2 build: os: ubuntu-22.04 tools: - python: '3.11' # This needs to stay in sync with pyproject.toml and any CI scripts + python: '3.11' # This needs to stay in sync with the tox config in pyproject.toml and any CI scripts nodejs: '20' # This needs to stay in sync with any CI scripts python: install: From f023dbdfb1bf5592e7445ff62e3240387e8bd576 Mon Sep 17 00:00:00 2001 From: "Felt, Nicholas" Date: Mon, 5 Aug 2024 09:06:02 -0700 Subject: [PATCH 3/7] ci: Fix workflow syntax issue --- .github/workflows/test-docs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-docs.yml b/.github/workflows/test-docs.yml index c87ef2dc..038e5ba2 100644 --- a/.github/workflows/test-docs.yml +++ b/.github/workflows/test-docs.yml @@ -35,7 +35,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: env.NODE_VERSION + node-version: ${{ env.NODE_VERSION }} - name: Install non-python documentation dependencies run: | npm install --global @mermaid-js/mermaid-cli @@ -43,7 +43,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: env.PYTHON_VERSION + python-version: ${{ env.PYTHON_VERSION }} - name: Install tox run: python -m pip install tox - name: Test From ec11c9c78f0062fa0003f17bca682803beeb3130 Mon Sep 17 00:00:00 2001 From: "Felt, Nicholas" Date: Mon, 5 Aug 2024 09:19:24 -0700 Subject: [PATCH 4/7] ci: Simplify tox config to avoid duplicating pre-commit config --- pyproject.toml | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f3ad30bf..2d79bb6c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -440,24 +440,16 @@ deps = poetry setenv = DOC_PYTHON_VERSION = python3.11 # Keep this in sync with .readthedocs.yml and any CI scripts - # Skip pre-commit checks that are explicitly performed by tox or not needed - SKIP = ruff-format,docformatter,ruff,pylint,pyright,pyright-verifytypes,pyroma,poetry-audit,file-contents-sorter + # Skip pre-commit checks that are not needed + SKIP = file-contents-sorter PYRIGHT_PYTHON_GLOBAL_NODE = False # This will cause python-pyright to use nodeenv to install node rather than use the system node commands_pre = poetry install --no-root --without=main commands = !tests: safety check --ignore=70612 - !tests: ruff format --check --diff . - !tests: docformatter --check --diff . - !tests: ruff check . - !tests: pylint . - !tests: pyright . - !tests: pyright --verifytypes tm_devices --ignoreexternal - !tests: pyroma . - !tests: poetry audit --ignore-code=CVE-2019-8341 !tests: poetry build --output=dist_{envname} !tests: twine check --strict dist_{envname}/* - !tests: pre-commit run --all-files --show-diff-on-failure + !tests: pre-commit run --all-files !tests: pytest -vv --doctest-modules --doctest-report=ndiff --showlocals --junitxml={tox_root}/.results_{envname}/results_doctests.xml --self-contained-html --html={tox_root}/.results_{envname}/results_doctests.html src pytest -vv -k "not test_docs" --showlocals --cov --junitxml={tox_root}/.results_{envname}/results.xml --cov-report=term --cov-report=xml:{tox_root}/.coverage_{envname}.xml --cov-report=html:{tox_root}/.results_{envname}/html --self-contained-html --html={tox_root}/.results_{envname}/results.html From 99fc683c792e89e36920ed6887da037603ff875e Mon Sep 17 00:00:00 2001 From: "Felt, Nicholas" Date: Mon, 5 Aug 2024 09:25:48 -0700 Subject: [PATCH 5/7] ci: Remove safety check since it is duplicating poetry audit --- pyproject.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 2d79bb6c..c4630c15 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -116,7 +116,6 @@ pyright = "1.1.374" pyroma = "^4.2" python-semantic-release = "^9.6.0" ruff = "0.5.6" -safety = "^3.2.0" toml-sort = "^0.23.0" tox = "^4.0" tox-gh-actions = "^3.1.0" @@ -446,7 +445,6 @@ setenv = commands_pre = poetry install --no-root --without=main commands = - !tests: safety check --ignore=70612 !tests: poetry build --output=dist_{envname} !tests: twine check --strict dist_{envname}/* !tests: pre-commit run --all-files From ecf092aa81e0ec3419933264bf66ebb099f90033 Mon Sep 17 00:00:00 2001 From: "Felt, Nicholas" Date: Mon, 5 Aug 2024 10:25:02 -0700 Subject: [PATCH 6/7] ci: Set up node for standard testing workflow to prevent false failures from pyright failing to install node --- .github/workflows/test-code.yml | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test-code.yml b/.github/workflows/test-code.yml index eb2ade33..c12fbf96 100644 --- a/.github/workflows/test-code.yml +++ b/.github/workflows/test-code.yml @@ -11,11 +11,6 @@ on: description: The name of the repository to use to gate Codecov uploads. required: true type: string - node-version: # The node version needs to stay in sync with .readthedocs.yml - description: The version of Node.js to install; if set, mermaid-cli will be - installed via npm and graphviz will be installed via apt. - required: false - type: number # Cancel running jobs for the same workflow and branch. concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -32,15 +27,10 @@ jobs: python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] # when updating this, make sure to update all workflows that use this strategy steps: - uses: actions/checkout@v4 - - if: ${{ inputs.node-version }} - uses: actions/setup-node@v4 + - uses: actions/setup-node@v4 with: - node-version: ${{ inputs.node-version }} - - if: ${{ inputs.node-version }} - name: Install non-python documentation dependencies - run: | - npm install --global @mermaid-js/mermaid-cli - sudo apt install --no-install-recommends --assume-yes graphviz + node-version: lts + check-latest: true - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: From abef5b58d97732177bd84958c5f46dd4976dff89 Mon Sep 17 00:00:00 2001 From: "Felt, Nicholas" Date: Mon, 5 Aug 2024 10:42:44 -0700 Subject: [PATCH 7/7] ci: Set up node for standard testing workflow to prevent false failures from pyright failing to install node --- .github/workflows/test-code.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-code.yml b/.github/workflows/test-code.yml index c12fbf96..fd3a28d5 100644 --- a/.github/workflows/test-code.yml +++ b/.github/workflows/test-code.yml @@ -29,7 +29,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: lts + node-version: latest check-latest: true - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5