Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert test-docs.yml to a reusable workflow #264

Merged
merged 7 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions .github/workflows/test-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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:
Expand Down
19 changes: 16 additions & 3 deletions .github/workflows/test-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,45 @@ 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
sudo apt install --no-install-recommends --assume-yes graphviz
- 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
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
16 changes: 3 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
nfelt14 marked this conversation as resolved.
Show resolved Hide resolved
!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

Expand Down
Loading