From bf7e685ec518a4331f2c2bb727081e3e1620a2fa Mon Sep 17 00:00:00 2001 From: "Felt, Nicholas" Date: Wed, 13 Nov 2024 12:25:05 -0800 Subject: [PATCH 1/3] feat: Add the ability for calling workflows to specify to use the Python version stored in the pyproject.toml file instead of hard-coding the Python version in the workflows as well --- .github/workflows/_reusable-test-code.yml | 13 +++++++++++-- .github/workflows/_reusable-test-docs.yml | 12 ++++++++++-- .github/workflows/test-code.yml | 2 +- .github/workflows/test-docs.yml | 2 +- workflows/test-code.md | 12 ++++++------ workflows/test-docs.md | 10 +++++----- 6 files changed, 34 insertions(+), 17 deletions(-) diff --git a/.github/workflows/_reusable-test-code.yml b/.github/workflows/_reusable-test-code.yml index 242787a3..2f04d10c 100644 --- a/.github/workflows/_reusable-test-code.yml +++ b/.github/workflows/_reusable-test-code.yml @@ -9,7 +9,9 @@ on: required: true type: string python-versions-array: - description: A valid JSON array of Python versions to test against. + description: A valid JSON array of Python versions to test against. A valid + option is also the string 'pyproject.toml', indicating to use the defined + Python version from the pyproject.toml file. required: true type: string operating-systems-array: @@ -46,11 +48,18 @@ jobs: with: node-version: lts/* check-latest: true - - name: Set up Python ${{ matrix.python-version }} + - name: Set up Python (version) + if: ${{ matrix.python-version != 'pyproject.toml' }} uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 with: python-version: ${{ matrix.python-version }} check-latest: true + - name: Set up Python (pyproject.toml) + if: ${{ matrix.python-version == 'pyproject.toml' }} + uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 + with: + python-version-file: ${{ matrix.python-version }} + check-latest: true - name: Install dependencies run: python -m pip install tox tox-gh-actions - name: Set up pre-commit cache diff --git a/.github/workflows/_reusable-test-docs.yml b/.github/workflows/_reusable-test-docs.yml index 2c29727e..072e0fa9 100644 --- a/.github/workflows/_reusable-test-docs.yml +++ b/.github/workflows/_reusable-test-docs.yml @@ -8,7 +8,8 @@ on: required: true type: number python-version: - description: The version of Python to install. + description: The version of Python to install. It can also be the string 'pyproject.toml', + indicating to use the defined Python version from the pyproject.toml file. required: true type: string tox-env-array: @@ -35,11 +36,18 @@ jobs: run: | npm install --global @mermaid-js/mermaid-cli sudo apt install --no-install-recommends --assume-yes graphviz - - name: Set up Python + - name: Set up Python (version) + if: ${{ inputs.python-version != 'pyproject.toml' }} uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 with: python-version: ${{ inputs.python-version }} check-latest: true + - name: Set up Python (pyproject.toml) + if: ${{ inputs.python-version == 'pyproject.toml' }} + uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 + with: + python-version-file: ${{ inputs.python-version }} + check-latest: true - name: Install tox run: python -m pip install tox - name: Test diff --git a/.github/workflows/test-code.yml b/.github/workflows/test-code.yml index 61cfdd28..d8f6101b 100644 --- a/.github/workflows/test-code.yml +++ b/.github/workflows/test-code.yml @@ -16,7 +16,7 @@ jobs: with: repo-name: tektronix/python-package-ci-cd operating-systems-array: '["ubuntu", "windows", "macos"]' # this needs to match the operating-systems-array in the publish-test-results.yml file - python-versions-array: '["3.12"]' # this needs to match the [tool.poetry.dependencies.python] version in the pyproject.toml file + python-versions-array: '["pyproject.toml"]' upload-to-codecov: true secrets: codecov-token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/test-docs.yml b/.github/workflows/test-docs.yml index 23a4902b..6f6ac7c3 100644 --- a/.github/workflows/test-docs.yml +++ b/.github/workflows/test-docs.yml @@ -14,5 +14,5 @@ jobs: uses: ./.github/workflows/_reusable-test-docs.yml with: node-version: 20 # The node version needs to stay in sync with .readthedocs.yml - python-version: '3.12' # this needs to match the [tool.poetry.dependencies.python] version in the pyproject.toml file and stay in sync with .readthedocs.yml + python-version: pyproject.toml tox-env-array: '["docs", "doctests"]' diff --git a/workflows/test-code.md b/workflows/test-code.md index 1b4c63e6..4f1450e9 100644 --- a/workflows/test-code.md +++ b/workflows/test-code.md @@ -106,12 +106,12 @@ commands_pre = ## Inputs -| Input variable | Necessity | Description | Default | -| ------------------------- | --------- | ------------------------------------------------------------------------------------------- | ---------------------------------- | -| `repo-name` | required | The full name of the repository to use to gate Codecov uploads, in the format `owner/repo`. | | -| `python-versions-array` | required | A valid JSON array of Python versions to test against. | | -| `operating-systems-array` | optional | A valid JSON array of operating system names to run tests on. | `'["ubuntu", "windows", "macos"]'` | -| `upload-to-codecov` | optional | A boolean indicating if coverage results should be uploaded to Codecov. | `false` | +| Input variable | Necessity | Description | Default | +| ------------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------- | +| `repo-name` | required | The full name of the repository to use to gate Codecov uploads, in the format `owner/repo`. | | +| `python-versions-array` | required | A valid JSON array of Python versions to test against. A valid option is also the string 'pyproject.toml', indicating to use the defined Python version from the pyproject.toml file. | | +| `operating-systems-array` | optional | A valid JSON array of operating system names to run tests on. | `'["ubuntu", "windows", "macos"]'` | +| `upload-to-codecov` | optional | A boolean indicating if coverage results should be uploaded to Codecov. | `false` | ## Secrets diff --git a/workflows/test-docs.md b/workflows/test-docs.md index eba1d858..21f60f00 100644 --- a/workflows/test-docs.md +++ b/workflows/test-docs.md @@ -68,11 +68,11 @@ commands = ## Inputs -| Input variable | Necessity | Description | Default | -| ---------------- | --------- | ---------------------------------------------- | ------------------------ | -| `node-version` | required | The version of Node.js to install. | | -| `python-version` | required | The version of Python to install. | | -| `tox-env-array` | optional | A valid JSON array of tox environments to run. | `'["docs", "doctests"]'` | +| Input variable | Necessity | Description | Default | +| ---------------- | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------ | +| `node-version` | required | The version of Node.js to install. | | +| `python-version` | required | The version of Python to install. It can also be the string 'pyproject.toml', indicating to use the defined Python version from the pyproject.toml file. | | +| `tox-env-array` | optional | A valid JSON array of tox environments to run. | `'["docs", "doctests"]'` | ## Example From 84bf4466f915bc5ccff968f61a659fb2a8056ec2 Mon Sep 17 00:00:00 2001 From: "Felt, Nicholas" Date: Wed, 13 Nov 2024 12:29:09 -0800 Subject: [PATCH 2/3] docs: Updated the changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 51ccea0f..9ee3cae4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,10 @@ Valid subsections within a version are: Things to be included in the next release go here. +### Added + +- Added the ability for caller workflows for the `_reusable-test-docs.yml` and `_reusable-test-code.yml` workflows to specify to use the `pyproject.toml` file as the source of the Python version instead of always requiring a hard-coded Python version. + ### Changed - Bumped dependency versions. From 65edef50e1cf71cc19c9f543d4b35dc53d81e70a Mon Sep 17 00:00:00 2001 From: "Felt, Nicholas" Date: Wed, 13 Nov 2024 12:33:31 -0800 Subject: [PATCH 3/3] fix: Add known words to avoid doc build failures --- doc_config/known_words.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc_config/known_words.txt b/doc_config/known_words.txt index 8d5f7b78..dc8eb0db 100644 --- a/doc_config/known_words.txt +++ b/doc_config/known_words.txt @@ -30,6 +30,7 @@ pr pre pypa pypi +pyproject repo sarif sbom @@ -39,6 +40,7 @@ stefanzweifel sublicense tektronix testpypi +toml update_development_dependencies vimtor white_check_mark