Skip to content

Manage versioning of Poetry tool dependency #604

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

Merged
merged 2 commits into from
Jun 19, 2025
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
6 changes: 0 additions & 6 deletions .github/workflows/check-python-task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ jobs:
with:
python-version-file: pyproject.toml

- name: Install Poetry
run: pip install poetry

- name: Install Task
uses: arduino/setup-task@v2
with:
Expand Down Expand Up @@ -102,9 +99,6 @@ jobs:
with:
python-version-file: pyproject.toml

- name: Install Poetry
run: pip install poetry

- name: Install Task
uses: arduino/setup-task@v2
with:
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/check-yaml-task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,6 @@ jobs:
with:
python-version-file: pyproject.toml

- name: Install Poetry
run: pip install poetry

- name: Install Task
uses: arduino/setup-task@v2
with:
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/spell-check-task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ jobs:
with:
python-version-file: pyproject.toml

- name: Install Poetry
run: pip install poetry

- name: Install Task
uses: arduino/setup-task@v2
with:
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/test-python-poetry-task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ jobs:
with:
python-version-file: pyproject.toml

- name: Install Poetry
run: pip install poetry

- name: Install Task
uses: arduino/setup-task@v2
with:
Expand Down
51 changes: 51 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -827,15 +827,66 @@ tasks:
-r "{{.STYLELINTRC_SCHEMA_PATH}}" \
-d "{{.INSTANCE_PATH}}"

# Print the version constraint for the project's Poetry tool dependency.
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
poetry:get-version:
cmds:
- |
if ! which yq &>/dev/null; then
echo "yq not found or not in PATH."
echo "Please install: https://github.com/mikefarah/yq/#install"
exit 1
fi
- |
yq \
--input-format toml \
--output-format yaml \
'.tool.poetry.group.pipx.dependencies.poetry' \
< pyproject.toml

# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
poetry:install:
desc: Install Poetry
run: once
vars:
POETRY_VERSION:
sh: task poetry:get-version
cmds:
- |
if ! which python &>/dev/null; then
echo "Python not found or not in PATH."
echo "Please install a version of Python meeting the constraint {{.POETRY_VERSION}}:"
echo "https://wiki.python.org/moin/BeginnersGuide/Download"
exit 1
fi
- |
if ! which pipx &>/dev/null; then
echo "pipx not found or not in PATH."
echo "Please install: https://pipx.pypa.io/stable/installation/#installing-pipx"
exit 1
fi
- |
export PIPX_DEFAULT_PYTHON="$( \
task utility:normalize-path \
RAW_PATH="$(which python)" \
)"
pipx install \
--force \
"poetry=={{.POETRY_VERSION}}"

# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
poetry:install-deps:
desc: Install dependencies managed by Poetry
deps:
- task: poetry:install
cmds:
- poetry install --no-root

# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
poetry:update-deps:
desc: Update all dependencies managed by Poetry to their newest versions
deps:
- task: poetry:install
cmds:
- poetry update

Expand Down
1 change: 0 additions & 1 deletion docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ The following development tools must be available in your local environment:
- The **Node.js** version in use is defined by the `engines.node` key of [`package.json`](../package.json).
- [**Python**](https://wiki.python.org/moin/BeginnersGuide/Download)
- The **Python** version in use is defined by the `tool.poetry.dependencies.python` key of [`pyproject.toml`](../pyproject.toml).
- [**Poetry**](https://python-poetry.org/docs/#installation) - Python dependencies management tool
- [**Task**](https://taskfile.dev/installation/) - task runner tool

## Building the Project
Expand Down
1,454 changes: 1,431 additions & 23 deletions poetry.lock

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ pep8-naming = "^0.15.1"
pytest = "^8.4.1"
GitPython = "^3.1.44"

# The dependencies in this group are installed using pipx; NOT Poetry. The use of the `tool.poetry.group` super-table
# is a hack required in order to be able to manage updates of these dependencies via Dependabot.
[tool.poetry.group.pipx]
optional = true

[tool.poetry.group.pipx.dependencies]
poetry = "2.1.3"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
51 changes: 51 additions & 0 deletions workflow-templates/assets/poetry-task/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,65 @@
version: "3"

tasks:
# Print the version constraint for the project's Poetry tool dependency.
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
poetry:get-version:
cmds:
- |
if ! which yq &>/dev/null; then
echo "yq not found or not in PATH."
echo "Please install: https://github.com/mikefarah/yq/#install"
exit 1
fi
- |
yq \
--input-format toml \
--output-format yaml \
'.tool.poetry.group.pipx.dependencies.poetry' \
< pyproject.toml

# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
poetry:install:
desc: Install Poetry
run: once
vars:
POETRY_VERSION:
sh: task poetry:get-version
cmds:
- |
if ! which python &>/dev/null; then
echo "Python not found or not in PATH."
echo "Please install a version of Python meeting the constraint {{.POETRY_VERSION}}:"
echo "https://wiki.python.org/moin/BeginnersGuide/Download"
exit 1
fi
- |
if ! which pipx &>/dev/null; then
echo "pipx not found or not in PATH."
echo "Please install: https://pipx.pypa.io/stable/installation/#installing-pipx"
exit 1
fi
- |
export PIPX_DEFAULT_PYTHON="$( \
task utility:normalize-path \
RAW_PATH="$(which python)" \
)"
pipx install \
--force \
"poetry=={{.POETRY_VERSION}}"

# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
poetry:install-deps:
desc: Install dependencies managed by Poetry
deps:
- task: poetry:install
cmds:
- poetry install --no-root

# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
poetry:update-deps:
desc: Update all dependencies managed by Poetry to their newest versions
deps:
- task: poetry:install
cmds:
- poetry update
10 changes: 9 additions & 1 deletion workflow-templates/assets/poetry/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,13 @@ build-backend = "poetry.core.masonry.api"
[tool.poetry]
package-mode = false

# The dependencies in this group are installed using pipx; NOT Poetry. The use of the `tool.poetry.group` super-table
# is a hack required in order to be able to manage updates of these dependencies via Dependabot.
[tool.poetry.group.pipx]
optional = true

[tool.poetry.group.pipx.dependencies]
poetry = "2.1.3"

[tool.poetry.dependencies]
python = "^3.9"
python = "~3.9"
3 changes: 0 additions & 3 deletions workflow-templates/check-mkdocs-task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ jobs:
with:
python-version-file: pyproject.toml

- name: Install Poetry
run: pip install poetry

- name: Install Task
uses: arduino/setup-task@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion workflow-templates/check-python-task.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The code style defined in `pyproject.toml` and `.flake8` is the official standar
Add the tool dependencies using this command:

```
poetry add --dev "black@^25.1.0" "flake8@^7.2.0" "pep8-naming@^0.15.1"
task poetry:install && poetry add --dev "black@^25.1.0" "flake8@^7.2.0" "pep8-naming@^0.15.1"
```

Commit the resulting changes to the `pyproject.toml` and `poetry.lock` files.
Expand Down
6 changes: 0 additions & 6 deletions workflow-templates/check-python-task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ jobs:
with:
python-version-file: pyproject.toml

- name: Install Poetry
run: pip install poetry

- name: Install Task
uses: arduino/setup-task@v2
with:
Expand Down Expand Up @@ -102,9 +99,6 @@ jobs:
with:
python-version-file: pyproject.toml

- name: Install Poetry
run: pip install poetry

- name: Install Task
uses: arduino/setup-task@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion workflow-templates/check-yaml-task.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ The code style defined in this file is the official standardized style to be use
Add the tool dependency using this command:

```
poetry add --dev "yamllint@^1.37.1"
task poetry:install && poetry add --dev "yamllint@^1.37.1"
```

Commit the resulting changes to the `pyproject.toml` and `poetry.lock` files.
Expand Down
3 changes: 0 additions & 3 deletions workflow-templates/check-yaml-task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,6 @@ jobs:
with:
python-version-file: pyproject.toml

- name: Install Poetry
run: pip install poetry

- name: Install Task
uses: arduino/setup-task@v2
with:
Expand Down
5 changes: 0 additions & 5 deletions workflow-templates/deploy-cobra-mkdocs-versioned-poetry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,6 @@ jobs:
with:
python-version-file: pyproject.toml

- name: Install Poetry
run: |
python -m pip install --upgrade pip
python -m pip install poetry

- name: Install Task
uses: arduino/setup-task@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion workflow-templates/deploy-mkdocs-poetry.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Install the [`deploy-mkdocs-poetry.yml`](deploy-mkdocs-poetry.yml) GitHub Action
Add the tool dependencies using this command:

```
poetry add --dev "mkdocs@^1.3.0" "mkdocs-material@^8.2.11" "mdx_truly_sane_lists@^1.2"
task poetry:install && poetry add --dev "mkdocs@^1.3.0" "mkdocs-material@^8.2.11" "mdx_truly_sane_lists@^1.2"
```

Commit the resulting changes to the `pyproject.toml` and `poetry.lock` files.
Expand Down
3 changes: 0 additions & 3 deletions workflow-templates/deploy-mkdocs-poetry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ jobs:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: 3.x

- name: Install Poetry
run: pip install poetry

- name: Install Dependencies
run: |
task \
Expand Down
2 changes: 1 addition & 1 deletion workflow-templates/deploy-mkdocs-versioned-poetry.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ See the ["Deploy Website" workflow (MkDocs, Poetry) documentation](deploy-mkdocs

1. Run this command:
```
poetry add --dev "gitpython@^3.1.44" "mike@^1.1.2"
task poetry:install && poetry add --dev "gitpython@^3.1.44" "mike@^1.1.2"
```
1. Commit the resulting changes to the `pyproject.toml` and `poetry.lock` files.

Expand Down
5 changes: 0 additions & 5 deletions workflow-templates/deploy-mkdocs-versioned-poetry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,6 @@ jobs:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: 3.x

- name: Install Poetry
run: |
python -m pip install --upgrade pip
python -m pip install poetry

- name: Install Dependencies
run: |
task \
Expand Down
3 changes: 0 additions & 3 deletions workflow-templates/spell-check-task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ jobs:
with:
python-version-file: pyproject.toml

- name: Install Poetry
run: pip install poetry

- name: Install Task
uses: arduino/setup-task@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion workflow-templates/test-go-integration-task.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Install the [`test-go-integration-task.yml`](test-go-integration-task.yml) GitHu
Add the tool dependencies using this command:

```
poetry add --dev "pytest@^8.4.1" "invoke@^1.7.0"
task poetry:install && poetry add --dev "pytest@^8.4.1" "invoke@^1.7.0"
```

Commit the resulting changes to the `pyproject.toml` and `poetry.lock` files.
Expand Down
3 changes: 0 additions & 3 deletions workflow-templates/test-go-integration-task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ jobs:
with:
python-version-file: pyproject.toml

- name: Install Poetry
run: pip install poetry

- name: Install Task
uses: arduino/setup-task@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion workflow-templates/test-python-poetry-task.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Install the [`test-python-poetry-task.yml`](test-python-poetry-task.yml) GitHub
Add the tool dependency using this command:

```
poetry add --dev "pytest@^8.4.1"
task poetry:install && poetry add --dev "pytest@^8.4.1"
```

Commit the resulting changes to the `pyproject.toml` and `poetry.lock` files.
Expand Down
3 changes: 0 additions & 3 deletions workflow-templates/test-python-poetry-task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ jobs:
with:
python-version-file: pyproject.toml

- name: Install Poetry
run: pip install poetry

- name: Install Task
uses: arduino/setup-task@v2
with:
Expand Down
Loading