`CraftSpreadYaml` should accept the `environment` key
Metadata
Current evaluation
No evaluation has been recorded for this issue yet.
Issue body
### What needs to get done
`CraftSpreadYaml` model at `craft_application/models/spread.py` does not accept the `environment` key which limits the ways in which the spread test can be set up.
## specific example
in [`chisel-releases`](https://github.com/canonical/chisel-releases/) we use the [`environment`](https://github.com/canonical/chisel-releases/) key to add [an entry](https://github.com/canonical/chisel-releases/tree/ubuntu-25.10/tests/spread/lib) to the PATH with extra libraries. there we run the tests with `spread` directly, and all is great.
i've been working on the [`rust-rock`](https://github.com/canonical/rust-rock) recently, and i wanted to implement this kind of pattern (which would eventually hopefully be adopted by into the [`rocks-template`](https://github.com/canonical/rust-rock)), however, when [trying it out](https://github.com/canonical/rust-rock/blob/2308e92ca6ea860c4e4f4c9a83afe1b6e509257d/rust-rock/1.84-25.04/spread.yaml#L10), the test [fails in the cli](https://github.com/canonical/rust-rock/actions/runs/18040922328/job/51339387123?pr=3#step:5:2882) (relevant logs pasted below in case the cli logs are no longer available). i've tracked the issue down to the fact that the builder [calls `rockcraft test`](https://github.com/canonical/craft-actions/blob/6376f70bf549a27bf96786aa6e7e17b5d43c0ff1/src/rockcraft-pack.ts#L65-L66) rather than using `spread` (called by the [`oci-factory`](https://github.com/canonical/oci-factory/blob/a24ea920d8bacfb43c2616672859b491a78d3258/.github/workflows/Build-Rock.yaml#L138-L139)). from there + actually looking at the python stacktrace, i've narrowed it down to [`CraftSpreadYaml`](https://github.com/canonical/craft-application/blob/89382915f754729c6336f6e7b060739033c0ded8/craft_application/models/spread.py#L74-L75) being self-proclaimedly only a simplified version.
```
2025-09-26 14:43:15.904 rockcraft internal error: 1 validation error for CraftSpreadYaml
2025-09-26 14:43:15.904 environment
2025-09-26 14:43:15.904 Extra inputs are not permitted [type=extra_forbidden, input_value={'SHARED_LIBRARIES': '$PR...PATH:$SHARED_LIBRARIES'}, input_type=dict]
2025-09-26 14:43:15.904 For further information visit https://errors.pydantic.dev/2.11/v/extra_forbidden
2025-09-26 14:43:15.911 Traceback (most recent call last):
2025-09-26 14:43:15.912 File "/snap/rockcraft/3592/lib/python3.12/site-packages/craft_application/application.py", line 650, in run
2025-09-26 14:43:15.912 return_code = self._run_inner()
2025-09-26 14:43:15.912 ^^^^^^^^^^^^^^^^^
2025-09-26 14:43:15.912 File "/snap/rockcraft/3592/lib/python3.12/site-packages/craft_application/application.py", line 627, in _run_inner
2025-09-26 14:43:15.912 return_code = dispatcher.run() or os.EX_OK
2025-09-26 14:43:15.912 ^^^^^^^^^^^^^^^^
2025-09-26 14:43:15.912 File "/snap/rockcraft/3592/lib/python3.12/site-packages/craft_cli/dispatcher.py", line 564, in run
2025-09-26 14:43:15.912 return self._loaded_command.run(self._parsed_command_args)
2025-09-26 14:43:15.912 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-09-26 14:43:15.912 File "/snap/rockcraft/3592/lib/python3.12/site-packages/craft_application/commands/base.py", line 200, in run
2025-09-26 14:43:15.912 result = self._run(parsed_args, **kwargs) or result
2025-09-26 14:43:15.912 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-09-26 14:43:15.912 File "/snap/rockcraft/3592/lib/python3.12/site-packages/craft_application/commands/lifecycle.py", line 684, in _run
2025-09-26 14:43:15.912 testing_service.test(
2025-09-26 14:43:15.912 File "/snap/rockcraft/3592/lib/python3.12/site-packages/craft_application/services/testing.py", line 69, in test
2025-09-26 14:43:15.912 self.process_spread_yaml(temp_spread_file, pack_state)
2025-09-26 14:43:15.912 File "/snap/rockcraft/3592/lib/python3.12/site-packages/craft_application/services/testing.py", line 108, in process_spread_yaml
2025-09-26 14:43:15.912 simple = models.CraftSpreadYaml.unmarshal(data)
2025-09-26 14:43:15.912 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-09-26 14:43:15.912 File "/snap/rockcraft/3592/lib/python3.12/site-packages/craft_application/models/base.py", line 64, in unmarshal
2025-09-26 14:43:15.913 return cls.model_validate(data)
2025-09-26 14:43:15.913 ^^^^^^^^^^^^^^^^^^^^^^^^
2025-09-26 14:43:15.913 File "/snap/rockcraft/3592/lib/python3.12/site-packages/pydantic/main.py", line 705, in model_validate
2025-09-26 14:43:15.913 return cls.__pydantic_validator__.validate_python(
2025-09-26 14:43:15.913 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-09-26 14:43:15.913 pydantic_core._pydantic_core.ValidationError: 1 validation error for CraftSpreadYaml
2025-09-26 14:43:15.913 environment
2025-09-26 14:43:15.913 Extra inputs are not permitted [type=extra_forbidden, input_value={'SHARED_LIBRARIES': '$PR...PATH:$SHARED_LIBRARIES'}, input_type=dict]
2025-09-26 14:43:15.913 For further information visit https://errors.pydantic.dev/2.11/v/extra_forbidden
2025-09-26 14:43:15.913 Full execution log: '/home/ubuntu/.local/state/rockcraft/log/rockcraft-20250926-144007.309280.log'
```
### Why it needs to get done
it would be really great if this functionality would be added so we can bump the `craft_application` version in `rockcraft` and configure our tests better. hope it's not tricky and that i've diagnosed the issue correctly.
Evaluation history
No evaluation history available.