Skip to content

Fix CWD interation between codspeed.yml and the cli commands#270

Open
GuillaumeLagrange wants to merge 3 commits intomainfrom
cod-2371-fix-clis-cwd-behavior-in-non-ci-usage
Open

Fix CWD interation between codspeed.yml and the cli commands#270
GuillaumeLagrange wants to merge 3 commits intomainfrom
cod-2371-fix-clis-cwd-behavior-in-non-ci-usage

Conversation

@GuillaumeLagrange
Copy link
Contributor

@GuillaumeLagrange GuillaumeLagrange commented Mar 18, 2026

The rule is

  1. When doing codspeed run without argument, the working directory should be by order of priority
    • the codspeed.yml general working directory setting, defined in project level options in codspeed.yml, as relative to the file it is written in
    • the path of the codspeed.yml directory

Note: For this case, CLI overrides of working directory are ignored with a warning

  1. When doing codspeed run -- command or codspeed exec -- command
    • explicit --working-directory cli flag
    • CWD

Note: For this case, we EXPLICITLY ignore the path of the discovered config

@codspeed-hq
Copy link

codspeed-hq bot commented Mar 18, 2026

Merging this PR will not alter performance

✅ 4 untouched benchmarks


Comparing cod-2371-fix-clis-cwd-behavior-in-non-ci-usage (f630ed5) with main (e1b20ac)

Open in CodSpeed

Move config file discovery logic from `ProjectConfig` into a dedicated
`DiscoveredProjectConfig` struct that preserves the config file path.
This removes the side-effect of `set_current_dir()` during discovery
and instead exposes `config_dir()` for callers to resolve paths
relative to the config file location.

Also stop merging `working_directory` from config in the merger since
it needs path resolution relative to the config file directory, which
the merger doesn't have access to.
When running `codspeed run` with config targets, the `working-directory`
option is now resolved relative to the config file's directory instead
of the current working directory. When no `working-directory` is set,
it defaults to the config file's directory.

For `codspeed run -- command` and `codspeed exec`, the config's
`working-directory` is explicitly ignored — only the `--working-directory`
CLI flag is used. A warning is emitted if `--working-directory` is passed
in config targets mode.
@GuillaumeLagrange GuillaumeLagrange force-pushed the cod-2371-fix-clis-cwd-behavior-in-non-ci-usage branch from 70676dc to f630ed5 Compare March 18, 2026 17:32
@GuillaumeLagrange GuillaumeLagrange marked this pull request as ready for review March 18, 2026 17:59
@GuillaumeLagrange GuillaumeLagrange changed the title Cod 2371 fix clis cwd behavior in non ci usage Fix CWD interation between codspeed.yml and the cli commands Mar 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant