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

Allow caller workflows to use pyproject.toml files as the source of the Python version #216

Merged
merged 3 commits into from
Nov 13, 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
13 changes: 11 additions & 2 deletions .github/workflows/_reusable-test-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/_reusable-test-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
2 changes: 1 addition & 1 deletion .github/workflows/test-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]'
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions doc_config/known_words.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pr
pre
pypa
pypi
pyproject
repo
sarif
sbom
Expand All @@ -39,6 +40,7 @@ stefanzweifel
sublicense
tektronix
testpypi
toml
update_development_dependencies
vimtor
white_check_mark
Expand Down
12 changes: 6 additions & 6 deletions workflows/test-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 5 additions & 5 deletions workflows/test-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading