astral-sh / rye

a Hassle-Free Python Experience
https://rye.astral.sh
MIT License
13.76k stars 468 forks source link

"fail_fast=false" for scripts chain #1274

Open chrisjsewell opened 2 months ago

chrisjsewell commented 2 months ago

Currently for https://rye.astral.sh/guide/pyproject/#chain

If any of the commands fails, the rest of the commands won't be executed and the chain fails.

But it would be good if there was an option to make it work similar to how rye test -a works:

If any of the commands fails, the rest of the commands WIILL stil be executed but the chain fails.

This would be useful for running multiple checks and also, for my use case, to run mypy against each package in a monorepo (since unfortunately at present it does not support monorepos), e.g.

[tool.rye.scripts]
"mypy:package_a" = "mypy --config-file python/package_a/pyproject.toml python/package_a/src"
"mypy:package_b" = "mypy --config-file python/package_b/pyproject.toml python/package_b/src"
"mypy:all" = { chain = ["mypy:package_a", "mypy:package_b"], fail_fast = false }
nikhilweee commented 2 months ago

Another use case is running coverage report after tests, regardless of whether they pass or fail. We could also name this new option is keep_going, in line with what PDM uses. Reference: https://pdm-project.org/latest/usage/scripts/#composite

[tool.rye.scripts]
"tests:coverage" = "coverage run -m unittest discover tests"
"tests:report" = "coverage report"
"tests" = { chain = ["tests:coverage", "tests:report"], keep_going = true }