diff --git a/.github/workflows/test-code.yml b/.github/workflows/test-code.yml index eb2ade33..fd3a28d5 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: latest + check-latest: true - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: diff --git a/.github/workflows/test-docs.yml b/.github/workflows/test-docs.yml index 4ea312b9..038e5ba2 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 the tox config in 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 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: diff --git a/pyproject.toml b/pyproject.toml index f3ad30bf..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" @@ -440,24 +439,15 @@ 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